2010-08-22 4 views
1

내가 만들고있는 앱에서 로컬 알림을 사용하고 있습니다.iOS4 이전 버전의 OS에서 UILocalNotification을 무시하려면 어떻게해야합니까?

나는 이것을 사용 :

Class myClass = NSClassFromString(@"UILocalNotification"); 
if (myClass) { 
//Local Notification code 
} 

지원하지 않을 경우 UILocalNotifications을 사용하지 않도록합니다. 이 오류 코드와 함께 출시에

하지만 내 응용 프로그램 충돌 :

경고 : "/Library/MobileSubstrate/MobileSubstrate.dylib" 에 대한 기호를 읽을 수 없습니다 (파일이 없습니다). dyld : 기호를 찾을 수 없습니다 :에 /var/mobile/Applications/FCFFFCB2-A60B-4A8D-B19B-C3F5DE93DAD2/MyApp.app/MyApp 예상 : /시스템/라이브러리/프레임 워크/UIKit _OBJC_CLASS _ $이 _ UILocalNotification에서 참조 .framework/UIKit

데이터 포맷터는 임시로 을 사용할 수 없으며 '계속'후에 다시 시도합니다. (현재 dlopen 을 호출하는 것은 안전하지 않습니다.) mi_cmd_stack_list_frames : 프레임이 스택에 없습니다. mi_cmd_stack_list_frames : 스택에 프레임이 충분하지 않습니다.

어떻게 방지 할 수 있습니까?

Class myClass = NSClassFromString(@"UILocalNotification"); 
if (myClass) { 
    //Local Notification code 
    UILocalNotification *notification = [[myClass alloc] init]; 
} 

대신 :

+0

:-) 예측할 수없는/정의되지 않은 개발 플랫폼? – Eiko

답변

6

이 작업을 수행하는 적절한 방법은 다음과 같습니다

Class localNotificationClass = NSClassFromString(@"UILocalNotification"); 
if (localNotificationClass != nil) { 
    // The UILocalNotification class is available 
    UILocalNotification* localNotification = 
     [[localNotificationClass alloc] initWith....]; 
} 

코드가 클래스를 사용할 수없는 이전 iOS에서로드 할 때 당신은 링크 오류의 원인이됩니다하지 사용 [UILocalNotificationClass alloc] 수 있기 때문이다. 그리고 그것이 바로 당신이 막으려 고 시도하는 것입니다.

은 BTW : 그 MobileSubstrate 오류는 휴대 전화를 탈옥 할 때 무엇을 얻을 수 있습니다 : 감옥으로

+0

을 실행하십시오. 내 2g를 iPhone 4로 교체 할 때까지 기다릴 필요가 없습니다. sim 잠금 해제 및 jailbreaking이 필요하지 않습니다. – LarsJK

-1

신경 쓰지 마 .. 내가 사용

Class myClass = NSClassFromString(@"UILocalNotification"); 
if (myClass) { 
    //Local Notification code 
    UILocalNotification *notification = [[UILocalNotification alloc] init]; 
} 

하고 일했다!

수정 됨!

+0

iOS4에서 작동하지만 이전 버전에서는 실패합니다. 내 대답을 보라. –

+0

그러나 이전 장치에서는 IF 문이 false가되어 코드가 실행되지 않습니다. 아니면 그렇지 않은가요? –

+0

죄송합니다 더 분명해야하지만 내부 : 클래스 localNotificationClass = NSClassFromString (@ "UILocalNotification"); if (localNotificationClass! = nil) { 블록 .. 그래서 기본적으로 st3fan과 동일한 작업을 수행합니다. @Tom Irving 이전 장치에서는 실행되지 않지만 [[UILocalNotification alloc] init]; 부분이 충돌하게 만든다 .. – LarsJK

관련 문제