투케이2K

143. (Objective-C/objc) [withCompletionHandler] 핸들러 동작 에러 발생 Error Null 체크 및 로그 출력 본문

Objective-C

143. (Objective-C/objc) [withCompletionHandler] 핸들러 동작 에러 발생 Error Null 체크 및 로그 출력

투케이2K 2024. 4. 12. 10:29
반응형

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : OBJECTIVE-C

 

[소스 코드]

 

                UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
                
                [center setBadgeCount:0 withCompletionHandler:^(NSError * _Nullable error) {
                    if (error != NULL){
                        [S_Log _D_WithC_:[NSString stringWithFormat:@"%s", __FILE__]
                                M_:[NSString stringWithFormat:@"%s :: %d", __FUNCTION__, __LINE__]
                                description:@"IOS 17 이상 : 뱃지 초기화 에러" data:[NSArray arrayWithObjects:
                                                                           [NSString stringWithFormat:@"error :: %s", error.description.UTF8String],
                                                                           nil]];
                    }
                    else {
                        [S_Log _D_WithC_:[NSString stringWithFormat:@"%s", __FILE__]
                                M_:[NSString stringWithFormat:@"%s :: %d", __FUNCTION__, __LINE__]
                                description:@"IOS 17 이상 : 뱃지 초기화 성공" data:nil];
                    }
                }];

반응형
Comments