'전체보기'에 해당되는 글 126건

  1. 2013.02.01 iOS 버전 체크 매크로 1
  2. 2013.01.15 NSString의 유용한 메서드 몇가지
  3. 2012.11.19 iOS & Android MD5 Hash
  4. 2012.02.28 [IOS] 이미지를 서버로 업로드하기 2
  5. 2012.02.22 [Objective C] Tabbar Custom 하기
  6. 2012.02.11 앱 내에서 카카오톡 호출하기
  7. 2012.02.11 [Objective c] URL스키마를 이용한 다른 어플리케이션 실행하기
  8. 2012.02.11 웹뷰로 페이스북 공유하기 URL
  9. 2012.02.11 웹뷰로 트위터 연동시 글전송방법
  10. 2012.02.11 [objective c] POST 데이터 전송
2013. 2. 1. 11:48

iOS 버전 체크 매크로

#define SYSTEM_VERSION_EQUAL_TO(v)
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)

#define SYSTEM_VERSION_GREATER_THAN(v)
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN(v)
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)
([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)


'아이폰' 카테고리의 다른 글

NSString의 유용한 메서드 몇가지  (0) 2013.01.15
iOS & Android MD5 Hash  (0) 2012.11.19
[IOS] 이미지를 서버로 업로드하기  (2) 2012.02.28
[Objective C] Tabbar Custom 하기  (0) 2012.02.22
앱 내에서 카카오톡 호출하기  (0) 2012.02.11
2013. 1. 15. 15:22

NSString의 유용한 메서드 몇가지

출처 : http://qkraudgns.tistory.com/423


문자열 길이 구하기
[file length]


토큰으로 문자열 쪼개 배열로 만들기
NSArray *array = [file componentsSeparatedByString:@"_"];



문자열 대소문자 변경하기
[file capitalizedString]; // 첫 글자만 대문자
[file lowercaseString]; // 소문자로
[file uppercaseString]; // 대문자로
 


파일 이름에서 확장자만 따기
[file pathExtension];


파일 이름에서 확장자만 빼고 가져오기
[file stringByDeletingPathExtension];



전체 경로에서 파일명만 가져오기

[file lastPathComponent];



전체 경로에서 파일을 제외한 나머지 경로

[file stringByDeletingLastPathComponent];



파일 이름에 붙이고 싶은 확장자 붙인 새 String 생성하기
(ext는 물론 NSString* 타입.)
[file stringByAppendingPathExtension:ext];



특정확장자가 존재하는지 확인하는데에 쓰일수 있다.
[[file stringByDeletingPathExtension] stringByAppendingPathExtension:@"smi"]

'아이폰' 카테고리의 다른 글

iOS 버전 체크 매크로  (1) 2013.02.01
iOS & Android MD5 Hash  (0) 2012.11.19
[IOS] 이미지를 서버로 업로드하기  (2) 2012.02.28
[Objective C] Tabbar Custom 하기  (0) 2012.02.22
앱 내에서 카카오톡 호출하기  (0) 2012.02.11
2012. 11. 19. 14:42

iOS & Android MD5 Hash

아이폰용

#import <CommonCrypto/CommonDigest.h>


+ (NSString *)uniqueIDFromString:(NSString *)source

{

    const char *src = [[source lowercaseString] UTF8String];

    unsigned char result[CC_MD5_DIGEST_LENGTH];

    CC_MD5(src, (CC_LONG)strlen(src), result);

    

    NSString *ret = [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",

                      result[0], result[1], result[2], result[3],

                      result[4], result[5], result[6], result[7],

                      result[8], result[9], result[10], result[11],

                      result[12], result[13], result[14], result[15]

                      ];

    

    return ret;

}


안드로이드용

import java.math.BigInteger;

import java.security.MessageDigest;

import java.security.NoSuchAlgorithmException;


public static String getMD5Hash(String s) {

     MessageDigest m = null;

     String hash = null;

    

     try {

          m = MessageDigest.getInstance("MD5");

          m.update(s.getBytes(),0,s.length());

          hash = new BigInteger(1, m.digest()).toString(16);

     } catch (NoSuchAlgorithmException e) {

          e.printStackTrace();

     }

    

     return hash;

}


사용법

String src = "123qwe";

String enc = getMD5Hash(src);

2012. 2. 28. 11:02

[IOS] 이미지를 서버로 업로드하기

2012. 2. 22. 11:17

[Objective C] Tabbar Custom 하기

2012. 2. 11. 23:07

앱 내에서 카카오톡 호출하기

2012. 2. 11. 23:04

[Objective c] URL스키마를 이용한 다른 어플리케이션 실행하기

2012. 2. 11. 23:01

웹뷰로 페이스북 공유하기 URL

출처 : http://www.facebook.com/note.php?note_id=174905752537963

일반적으로 제공되는 facebook share 버튼을 클릭 시 나타나는 소스 링크의 URL은 다음과 같다.

 

http://www.facebook.com/sharer.php?u=http://tv.adobe.com/watch/max-2010-keynotes/adobe-max-2010-keynote-day-1-welcome-to-the-revolution-creative-tooling/

 

위의 소스에서 http://www.facebook.com/sharer.php?u= 다음의 http:// ~ 시작되는 부분인 원본 소스링크

 

http://tv.adobe.com/watch/max-2010-keynotes/adobe-max-2010-keynote-day-1-welcome-to-the-revolution-creative-tooling/

 

를 복사한 다음 페이지 상태 탭에서 링크를 클릭하고 URL입력 창에 붙여넣은 다음 [첨부] 버튼을 클릭하면 상태스트림에서 재생이 가능한 형태로 보여지는 정상적인 공유가 이루어 진다.


2012. 2. 11. 22:48

웹뷰로 트위터 연동시 글전송방법

http://twitter.com/share?url=<url>&text=<message>

<message> <url> 형식으로 트윗작성 페이지가 뜬다.
예)
http://twitter.com/share?url=http://www.naver.com&text=네이버

네이버 http://www.naver.com 으로 표시된다.
2012. 2. 11. 11:24

[objective c] POST 데이터 전송

- (void)connectToServer
{
    NSString *url = @"http://192.168.0.103/p/Login/CheckEmailDuplicate.php";
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
   
    NSString *post = [NSString stringWithFormat:@"email=동해물과백두산이마르고닳도록"];
    NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
   
    [request setURL:[NSURL URLWithString:url]];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"Mozilla/4.0 (compatible;)" forHTTPHeaderField:@"User-Agent"];
    [request setHTTPBody:postData];
   
    [NSURLConnection connectionWithRequest:request delegate:self];
}

// HTML이 처리되고 난 뒤 얻는 데이터
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    NSString *returnString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];   
    NSLog(@"recieved : %@",returnString);
   
    //
    if ([returnString isEqualToString:@""]) {

    }
}

 
// post를 보낸 후 쿠키 수신
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)aResponse
{
        NSHTTPCookie *cookie;
       
        for (cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies])       
        {
            NSLog(@"%@",[cookie description]);       
        }
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
   
}