본문 바로가기
반응형

objc4

[IOS] [Objective-C] 함수, function, method Implementation 의 함수만들기 예) 파라메터와 리턴값이 없는 것 함수타입(리턴타입)함수명 -(void)printInfo // .h @interface TestUtil : NSObject - (void)printInfo; @end // .m @implementation TestUtil -(void)printInfo{ NSLog(@"hello-bryan"); } @end // 사용 TestUtil *testUtil = [[TestUtil alloc] init]; [testUtil printInfo]; // hello-bryan 예) 파라메터와 리턴값이 있는 것 함수타입(리턴타입)함수명:(파라메터1의 타입)파라메터명 두번째파라메터별칭:(두번째파라메터타입)두번째파라메터명 -(NSString*)setI.. 2022. 2. 8.
[IOS] [Objective-C] Date Formatting, 날짜포멧 Objective-C Date Format Formatter 정하기 NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss:SSS"]; 현재 시간 가져오기 NSDate *currentDate = [NSDate date]; 현재 시간을 정해진 format 으로 변환 NSString *dateString = [formatter stringFromDate:currentDate]; NSLog(@"%@", dateString); // 2022-02-06 21:14:38:509 2022. 2. 8.
[IOS] [Objective-C] 10진수를 16진수 문자열로 바꾸기 코드 // 문자열일 때 NSString *dec = @"10"; NSString *hex = [NSString stringWithFormat:@"%2lX", (unsigned long)[dec integerValue]]; NSLog(@"10 -> hex -> %@", hex); // 10 -> hex -> A // 숫자일 때 NSInteger dec = 10; NSString *hex = [NSString stringWithFormat:@"%2lX", (unsigned long)dec]; NSLog(@"10 -> hex -> %@", hex); // 10 -> hex -> A 테스트 for(int i=0; i 2022. 2. 6.
[IOS] Objective-C 에서 Realm 사용하기 Realm Objective-C, Swift 에서 사용하기 직접 테스트 해보시려면 아래 두 링크를 참고하세요. 한 프로젝트에서 Objective-C, Swift 둘 다 사용하기 [IOS (Swift, Objective-c)] - [IOS] Objective-c, Swift 혼합 프로젝트 CocoaPod 설치, Realm 설치 [IOS (Swift, Objective-c)] - [IOS] CocoaPod 설치. 프로젝트 설정하기 [참고] realm 이란? Objective-C 에서 Realm 사용하기 Objective-C ViewController.m 에서 (전체 소스는 하단에 접은글에 있습니다.) import #import Model 객체 정의 // Define your models @interface .. 2022. 2. 5.
728x90
반응형