블로그 이미지
Unusual and beautiful mastership

카테고리

분류 전체보기 (27)
日常 (9)
斷想 (7)
音樂 (3)
(2)
(6)
Total35,902
Today2
Yesterday6


현재 장비의 MAC Address 와 IP Address 를 알아내보자.

먼저 IPAddress.c, IPAddress.h 를 자신의 프로젝트에 추가한 후,

#import "IPAddress.h"

헤더를 추가하고; 
 

사용하고자 하는 함수 안에 다음과 같이 작성해 준다.

 
실행해 보면

현재 장비의 네트워크 주소를 출력할 수 있다.



wifi, 3g 상태에서 모두 IP 주소를 얻을 수 있다.

Posted by mastership

Application Cycle ?!

/ 2011/04/26 15:49
iPhone Application 의 경우 실행하고, 홈 버튼을 눌러서 종료 하고,

멀티태스킹을 지원하는 Application 일 경우 홈 버튼을 눌러서 Background 로 이동하고,

다시 실행해서 Foreground 로 이동하는 일종의 사이클이 있다.


각각의 경우에 이벤트를 처리하는 함수들은 다음과 같다.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

- (void)applicationWillResignActive:(UIApplication *)application

- (void)applicationDidEnterBackground:(UIApplication *)application

- (void)applicationWillEnterForeground:(UIApplication *)application

- (void)applicationDidBecomeActive:(UIApplication *)application

- (void)applicationWillTerminate:(UIApplication *)application



각 함수가 호출 되는 경우를 알아보면 다음과 같다.

1. 프로그램 처음 실행 시


(1) didFinishLaunchingWithOptions 호출


(2) applicationDidBecomeActive 호출



2. 홈 버튼을 한번 누를 경우


(1) applicationWillResignActive 호출


(2) applicationDidEnterBackground 호출



3. 위 상태에서 다시 어플 실행 시


(1) applicationWillEnterForeground 호출


(2) applicationDidBecomeActive 호출



4. 홈 버튼을 두번 누를 경우


(1) applicationWillResignActive 호출



추가적으로 XXX-info.plist 파일에


Application does not run in background (멀티태스킹 지원 해제) 항목을 추가 하고 체크 하면


홈 버튼을 한번 누를 경우 applicationWillTerminate 를 호출한다.

Posted by mastership

iPhone 에서 MD5 생성하기

/ 2011/04/20 13:48

iPhone에서 string을 MD5로 암호화 해보자


우선 헤더에 CommonCrypto/CommonDigest.h 파일을 import 시킨다.



그리고  MD5를 구하는 함수를 생성 해서 사용하면 된다.


- (NSString*)md5:(NSString*)srcStr
{
const char *cStr = [srcStr UTF8String];
 
 unsigned char result[CC_MD5_DIGEST_LENGTH];
 
 CC_MD5(cStr, strlen(cStr), result);
 
 return [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]];
}


테스트를 해보면....


변환이 잘 되는 것을 확인할 수 있다.

 
 

Posted by mastership

Xcode4 는 귀찮게도 기존의 버전에 비해 상당한 부분이 변했다.

그 중 하나로 네비게이터에서 마우스 우클릭을 하면 나오던 프레임워크 추가 메뉴가 없어졌다.

아무튼 방법이 좀 변했는데...


우선 왼쪽 네비게이터에서 프로젝트를 클릭한 후,



오른쪽 화면의 TARGET을 클릭한 후, Build Phases 탭을 클릭한다.

쭉 나오는 항목 중에 Link Binary With Libraries 를 펼쳐서 + 을 클릭하면,



다음과 같이 추가할 수 있는 Framework 목록이 나타난다.


그러면 원하는 Framework를 선택하고  Add 하면 완료;



Posted by mastership

최근에 달린 댓글

최근에 받은 트랙백

글 보관함