iOS/Mac
-
NSMutableData TipsiOS/Mac 2011. 2. 17. 21:01
NSMutableData는 byte배열을 wrapping해 놓은 객체. 특정 영역을 제거하는 방법 replaceBytesInRange 이용 ex) “1234567890 abcdef” 가 있는 배열에서 5번째부터 3개(678)를 제거. NSString *myString = @"1234567890 abcdef"; const char *utfString = [myString UTF8String]; NSMutableData *data = [NSMutableData dataWithBytes:utfString length:strlen(utfString)]; NSRange r = NSMakeRange(5, 3); NSString *strBefore = [[NSString alloc] initWithData:data ..
-
protocol type-castingiOS/Mac 2011. 2. 17. 20:54
ex1 if([self.myViewController conformsToProtocol:@protocol(MyProtocol)]) { id p = (id)self.myViewController; [p protocolMethod]; } ex2 if ([self.myViewController conformsToProtocol:@protocol(MyProtocol)]) { UIViewController *vc = (UIViewController *) self.myViewController; [vc protocolMethod]; }
-
XCode Project에 라이브러리 프로젝트 추가iOS/Mac 2011. 2. 17. 20:51
라이브러리 프로젝트를 만들고, 필요한 타겟을 만들고.. 다른 프로젝트에 이 프로젝트를 추가해서 사용한다. 우선 두 프로젝트를 같은 디렉토리 레벨로 위치.(필요?) Group & Files 최상위에서 추가하기에서 기존 프로젝트를 추가한다. .a 파일을 Target - – Link Binary With Libraries 에 끌어다 복사한다.(Alt키로) 타겟의 정보보기 General탭에서 Linked Libraries에 끌어다 놓은 .a 파일이 보인다. 그리면 위에 Direct Dependencies 창의 [+]를 눌러 필요한 라이브러리 프로제트의 타겟을 추가한다. 헤더파일을 못찾으면, Target info에서 Search Paths의 Header Search Paths 항목에 라이브러리 경로를 추가 해준다.