[[NSThreaed alloc] initWithTarget:self selector:@selector(method) object:obj];

- (void)method:(NSData *)data
{
}


실행시 method 가 없다고 에러난다. 
method 에는 인자값이 하나가 있으므로 @selector(method:) 로 명시해줘야한다.
 
OPT 키를 누르면 포인트 점 2개가 나타난다.
이후 클릭시 두군데를 동시에 누른것처럼 동작한다. 
1. Frameworks 에 CoreData.framework 추가.
2. Data Model 파일 (<Project-Name>.xcdatamodeld) 추가.
3. <Project-Name>.pch 에 "#import <CoreData/CoreData.h>" 추가. (위치는 눈치봐서 맞춰서 넣을 것)
4. AppDelegate 선언부에 다음을 추가.

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;

- (NSURL *)applicationDocumentsDirectory; 



5. AppDelegate 구현부에 다음을 추가. <Project-Name> 이 두군데 있으니 잘 찾아서 수정.

#pragma mark - Core Data stack

/**
 Returns the managed object context for the application.
 If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
 */
- (NSManagedObjectContext *)managedObjectContext
{
    if (__managedObjectContext != nil)
    {
        return __managedObjectContext;
    }
    
    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
    if (coordinator != nil)
    {
        __managedObjectContext = [[NSManagedObjectContext alloc] init];
        [__managedObjectContext setPersistentStoreCoordinator:coordinator];
    }
    return __managedObjectContext;
}

/**
 Returns the managed object model for the application.
 If the model doesn't already exist, it is created from the application's model.
 */
- (NSManagedObjectModel *)managedObjectModel
{
    if (__managedObjectModel != nil)
    {
        return __managedObjectModel;
    }
    NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"<Project-Name>" withExtension:@"momd"];
    __managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
    return __managedObjectModel;
}

/**
 Returns the persistent store coordinator for the application.
 If the coordinator doesn't already exist, it is created and the application's store added to it.
 */
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
    if (__persistentStoreCoordinator != nil)
    {
        return __persistentStoreCoordinator;
    }
    
    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"<Project-Name>.sqlite"];
    
    NSError *error = nil;
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
    {
        /*
         Replace this implementation with code to handle the error appropriately.
         
         abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 
         
         Typical reasons for an error here include:
         * The persistent store is not accessible;
         * The schema for the persistent store is incompatible with current managed object model.
         Check the error message to determine what the actual problem was.
         
         
         If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory.
         
         If you encounter schema incompatibility errors during development, you can reduce their frequency by:
         * Simply deleting the existing store:
         [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]
         
         * Performing automatic lightweight migration by passing the following dictionary as the options parameter: 
         [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
         
         Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
         
         */
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }    
    
    return __persistentStoreCoordinator;
}

#pragma mark - Application's Documents directory

/**
 Returns the URL to the application's Documents directory.
 */
- (NSURL *)applicationDocumentsDirectory
{
    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}


 
1. 문제발생
갑자기 코드에디터의 컬러링이 일부가 안되기 시작했다.
특정 파일 하나만 그런 것이다.

2. 문제내용
각종 라이브러리와 관련된 코드들이 색이 없이 기본 글자색으로 나와서 보기도 힘들고 눈도 아파서 해결책을 찾아보았는데 다 안된다.

3. 원인확인
그러다 오늘 SVN 업데이트중 해당 파일이 다른 경로에 있는 것을 보고 이상하게 생각했다.
en.lproj 에 있는걸 보니 Localization 과 관련이 있어보였다.
어제 다국어 처리를 하면서 해당 파일에도 모르고 언어를 추가하였나보다.

4. 문제해결
Localization 을 모두 제거해버리니 다른 소스파일들과 같은 위치로 오면서 컬러링도 동작하게 되었다. 

enum CFSocketCallBackType {

kCFSocketNoCallBack = 0,
kCFSocketReadCallBack = 1,
kCFSocketAcceptCallBack = 2,
kCFSocketDataCallBack = 3,
kCFSocketConnectCallBack = 4,
kCFSocketWriteCallBack = 8
};
typedef enum CFSocketCallBackType CFSocketCallBackType;

상수
kCFSocketNoCallBack

어떠한 활동도 콜백이 구성되지 않는다.

iOS 2.0 이상에서 지원.

CFSocket.h 에 선언됨.

kCFSocketReadCallBack

읽을 수 있는 자료가 있거나 새로운 연결 요청이 있을 경우 콜백이 호출된다. 자료는 자동으로 읽어지지 않는다; 콜백은 자료를 읽어야만 한다.

iOS 2.0 이상에서 지원.

CFSocket.h 에 선언됨.

kCFSocketAcceptCallBack

새로운 연결이 자동으로 수락되고 자식 소켓의 CFSocketNativeHandle 포인터를 포함한 데이터와 함께 콜백이 호출될 것이다. 이 콜백은 listening 소켓에서만 사용가능하다.

iOS 2.0 이상에서 지원.

CFSocket.h 에 선언됨.

kCFSocketDataCallBack

백그라운드에서 수신된 데이터를 읽고 이를 포함한 CFData 개체와 함께 콜백이 호출 될 것이다.

iOS 2.0 이상에서 지원.

CFSocket.h 에 선언됨.

kCFSocketConnectCallBack

CFSocketConnectToAddress 또는 CFSocketCreateConnectedToSocketSignature 호출로 백그라운드에서 연결을 시도할 경우 연결이 되었을 때 이 콜백은 이루어집니다. 이경우 데이터 인자는 NULL 이거나, 연결이 실패했을 경우  SInt32 포인터 에러 코드입니다. 이 콜백은 특정 소켓에 대하여 두번 이상 발생하지 않습니다.

iOS 2.0 이상에서 지원.

CFSocket.h 에 선언됨.

kCFSocketWriteCallBack

소켓이 쓰기가능할 때 콜백이 호출된다. 이 콜백은 소켓을 통해 대용량의 데이터를 보내고난 뒤 커널 버퍼에 여유가 생겼을 때 알림을 받기 원할때 유용하다.

iOS 2.0 이상에서 지원.

CFSocket.h 에 선언됨.


1. Storyboard 가져오기

"[iOS] 기기에 맞는 UIStoryboard 찾기" 참고


2. ViewController 생성

이전
[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

변경
스토리보드에서 해당 ViewController 의 Identifier 를 "ViewController" 로 설정
[storyboard instantiateViewControllerWithIdentifier:@"ViewController"];




'Mobile > iOS' 카테고리의 다른 글

[iOS] CoreData 추가하기  (0) 2012.02.24
[iOS] CFOptionFlags  (0) 2012.02.21
[iOS] 기기에 맞는 UIStoryboard 찾기  (0) 2012.02.20
[iOS] 함수 포인터를 이용하여 핸들러 만들기  (0) 2012.02.20
[iOS] iOS Application Life-cycle  (0) 2012.02.17

1. 스토리보드 이름 찾기

[ProjectName]-Info.plist 파일에서 확인할 수 있다.

iPhone 은 "Main storyboard file base name", iPad 는 "Main storyboard file base name (iPad)" 에서 확인할 수 있다.


2. 기기에 맞는 스토리보드 이름 가져오기

NSString *storyboardName = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad? @"MainStoryboard_iPad": @"MainStoryboard_iPhone");


3. 스토리보드 찾기

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];

typedef void (^Handler)(int result);
Handler handler = ^(int result) {
    NSLog(@"Handler called by result: %d", result);
};

'Mobile > iOS' 카테고리의 다른 글

[iOS] Storyboard 사용시 ViewController 의 initWithNibName 대응법  (0) 2012.02.20
[iOS] 기기에 맞는 UIStoryboard 찾기  (0) 2012.02.20
[iOS] iOS Application Life-cycle  (0) 2012.02.17
[iOS] boolean type  (0) 2012.02.17
[iOS] Multitasking  (0) 2012.02.17

상태변화시 호출되는 메서드를 정리해보았다.


 

'Mobile > iOS' 카테고리의 다른 글

[iOS] 기기에 맞는 UIStoryboard 찾기  (0) 2012.02.20
[iOS] 함수 포인터를 이용하여 핸들러 만들기  (0) 2012.02.20
[iOS] boolean type  (0) 2012.02.17
[iOS] Multitasking  (0) 2012.02.17
[iOS] Gesture Recognizer  (0) 2012.02.16

bool 을 치면 Code Completion 에 "BOOL", "bool", "Boolean", "boolean_t" 네개가 뜬다.
궁금해서 찾아보았다.

1. BOOL (iPhoneOS5.0 > usr/include > objc > objc.h)
   typedef signed char BOOL;

2. bool (stdbool.h)
    #define bool _Bool

3. Boolean (iPhoneOS5.0 > usr/include > MacTypes.h)
    typedef unsigned char Boolean;

4. boolean_t (iPhoneOS5.0 > usr/include > mach > arm > boolean.h)
    typedef int boolean_t;


_Bool 은 Symbol 을 찾을 수 없다고 나와 무엇인지 모르겠다.

'Mobile > iOS' 카테고리의 다른 글

[iOS] 함수 포인터를 이용하여 핸들러 만들기  (0) 2012.02.20
[iOS] iOS Application Life-cycle  (0) 2012.02.17
[iOS] Multitasking  (0) 2012.02.17
[iOS] Gesture Recognizer  (0) 2012.02.16
[iOS] Touches  (0) 2012.02.16

+ Recent posts