[obj-c] Local Notification

iPhone 2012. 12. 6. 15:06





<< AppDelegate >>


/**      Local Notificaiton      **/


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

{

    

    

    NSLog(@"didFinishLaunchingWithOptions");

    

    UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

    

    if (notification) {

    //어플리케이션이 시작될때, 노티피케이션에 의한것?

    //어플리케이션이 액티브이지 않을때, 노티피케이션에 의해 불린다면

        

        [self showAlarm:notification.alertBody];

        NSLog(@"AppDelegate didFinishLaunchingWithOptions");

        application.applicationIconBadgeNumber = 0;

    }

    

    [self.window makeKeyAndVisible];

    

    

    

    // Override point for customization after application launch.

    return YES;

}




- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

    //어플리케이션이 액티브일때, 노티피케이션 수신

    

    [self showAlarm:notification.alertBody];

    application.applicationIconBadgeNumber = 0;

    NSLog(@"AppDelegate didReceiveLocalNotification %@", notification.userInfo);

    

}


- (void)showAlarm:(NSString *)text {

    

    

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alarm"

                                                        message:text delegate:nil

                                              cancelButtonTitle:@"OK"

                                              otherButtonTitles:nil];

[alertView show];

}







<< 노티피케이션을 등록할 곳 >>



    [[UIApplication sharedApplication] cancelAllLocalNotifications];

    

    UILocalNotification *localNotification = [[UILocalNotification alloc] init];

    

    // 10초후 노티피케이션 등록

    NSDate *now = [NSDate date];

    NSDate *dateToFire = [now dateByAddingTimeInterval:5];

    

    NSLog(@"now time: %@", now);

    NSLog(@"fire time: %@", dateToFire);

    

    

    localNotification.fireDate = dateToFire;

    localNotification.alertBody = @"Time to get up!";

    localNotification.soundName = UILocalNotificationDefaultSoundName;

    localNotification.applicationIconBadgeNumber = 1; // increment

   

     NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Object 1", @"Key 1", @"Object 2", @"Key 2", nil];

    

    localNotification.userInfo = infoDict;

    

    

     

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];







Posted by tenn
,

File Merge 간단 사용법



1. xcode의 상단의 메뉴바에서

Xcode > Open Developer Tool > FileMerge


2. 병합할 파일을 Left… Right…에 드래그 해서 설정.

    마지의 결과를 기록할 파일을 Merge에 비교할 파일을 Ancestor에 설정. 


3. 변경부분중 병합하고 싶은 부분을 선택하고 오른쪽하단의 Action버튼을 눌러 병합결정을 한다.

    선택된 부분쪽으로 화살표가 향한다.


4. File > Save Merge As... 로 저장

   Merge를 지정한 경우는 Cmd + S 만으로 저장이 된다.



xcodeproj 파일안의 project.pbxproj파일을 마지할때 편리


Posted by tenn
,

[obj-c] mach-0 linker error

iPhone 2012. 12. 3. 13:56

소스를 프로젝트에 추가도 안해주고 헤더파일을 import 하니 발생했다.

Posted by tenn
,