App/Objective-C
-
ProtocolApp/Objective-C 2017. 4. 2. 08:08
정의 선언만 되고 구현되지 않은 메소드(Java의 인터페이스) 용도1. 다른 객체가 구현해주면 되는 매소드를 선언2. 클래스를 숨기도 인터페이스만 선언하고자 할 때3. 상속관계가 아니지만 비슷한 인터페이스를 만들고자 할 때 사용법1234567891011//@protocol 프로토콜이름 : 상속받을 프로토콜//- 메소드 이름 @protocol MyProtocol : NSObject // 프로토콜은 다른 프로토콜을 상속할 수 있다.-(void)requiredMethod;@optional-(void)anOptionalMethod;-(void)anotherOptionalMethod;@required-(void)anotherRequiredMethod;@endColored by Color Scriptercs @op..
-
GCM(Google Cloud Messaging)App/Objective-C 2017. 2. 24. 14:32
GCM이란? 말그대로 구글에서 제공하는 알림 메시지 기능이다. 서버측에서 데이터를 조작하여 앱에 알림바 형태로 제공할 수 있는 기능이며, 이전에는 IOS에서는 APNS Android에서는 GCM을 이용하곤 했는데, 몇년전에 통합되어 GCM으로 두 서비스 제공이 가능해졌다. //AppDelegate.h12345678910111213#import #import @interface AppDelegate : UIResponder @property(nonatomic, strong) UIWindow *window;@property(nonatomic, readonly, strong) NSString *registrationKey;@property(nonatomic, readonly, strong) NSString *..
-
AVAudioSessionApp/Objective-C 2017. 2. 21. 10:02
AVAudioSession 은 Audio를 동시재생될 수 있도록 해주는 기능이며 background mode로 진입시에도 Audio/TTS가 Play될 수 있도록 해주는 기능 사용법 //AppDelegate.m1234567891011121314- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSError *error = NULL; AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryPlayback error:&error]; if..
-
new와 alloc의 차이App/Objective-C 2017. 2. 13. 09:59
alloc initNSObject의 인스턴스 메소드. 인스턴스를 초기화 newNSObject의 클래스 메소스. 클래스의 새로운 인스턴스를 alloc할 뿐 아니라,alloc된 인스턴스를 init하여 초기화까지 시킴 releaseNSObject delegate의 인스턴스 메소드로 참조 카운트를 감소시킴 autoreleaseNSObject delegate의 인스턴스 메소드로 the current autorelease pool에 인스턴스를 추가함 retainNSObject delegate의 인스턴스 메소드. 참조카운트를 증가시킴 - 사용 시 유의점!!![[class alloc] init]은 [class new]로 바꾸는 것이 가독성에 좋다.[[class alloc] iniWith~]를 사용할 경우 [class ..
-
ARC(Automatic Reference Counting)App/Objective-C 2017. 2. 13. 09:44
ARC란? Automatic Reference Counting의 약자로 자동 참조 카운트라는 용어한마디로 자동으로 메모리 관리를 해준다는 개념이다.자바의 가비지컬렉션과 비슷한 개념이지만, 차이점은 프로그램할 때 코딩에 release코드를 넣지 않을 뿐이지기계어로 번역된 바이너리에는 컴파일러가 프로그래머 대신 넣어준 release코드로 동작이 진행된다. strong보통 객체를 생성하면 어느시점 죽을 때까지는 살아있다.또한 그 객체를 여러군데에서 필요에 의해 사용할 수 있다.그럴 경우 포인터로 이루어진 객체가 갈 곳 잃은, 집도 없은 댕글링 포인터가 될 수 있다.이를 방지하고자 strong속성을 프로퍼티에 설정한다.프로퍼티 속성이 strong이라면 대입되는 값을 소유하고자 하는 의도가 있는 것으로 판단되어,..
-
AppDelegate 함수 정리App/Objective-C 2017. 2. 7. 13:46
application(_:didFinishLaunching:) - 앱이 처음 시작될 때 실행 applicationWillResignActive : - 앱이 active에서 inactive로 이동될 때 실행 applicationDidEnterBackground: - 앱이 background상태일 때 실행 applicationWillEnterForeground: - 앱이 background에서 foreground로 이동될 때 실행(아직 foreground에서 실행중이지 않음 applicationDidBecomeActive: - 앱이 active상태가 되어 실행중일 때 applicationWillTerminate: - 앱이 종료될 때 실행 App 생명주기 - Not Running : 앱이 실행되지 않은 상태 ..