2012-09-03 89 views
2

下面是代碼:如何解決此錯誤消息:「未聲明的標識符」?

EKEventStore *store = [[EKEventStore alloc] 
         initWithAccessToEntityTypes:EKEntityMaskEvent]; 
NSArray *eventCalendars = [store calendarsForEntityType:EKEntityTypeEvent]; 

NSDate *monday, *sunday; 
NSPredicate *predicate; 
predicate = [store predicateForEventsWithStartDate:monday 
              endDate:sunday 
             calendars:eventCalendars]; 
NSArray *events = [store eventsMatchingPredicate:predicate]; 
NSLog(@"Events this week:"); 
for (EKEvent *event in events) { 
    NSLog(@"%@ - starts at %@", event.title, event.startDate); 
} 

我收到一個錯誤說「未聲明的標識符的使用‘EKEntityMaskEvent’」 與使用未聲明的標識符的「EKEntityTypeEvent」

我該如何解決這個問題?

回答

0

看起來您可能正在使用尚未公開的未來版本的iOS SDK。爲了完成這項工作,您必須使用支持新SDK的未發佈版本的Xcode。 (也許它是Xcode 4.5你需要使用?)

如果您對將來未發佈的SDK有任何疑問,請發帖到蘋果開發者論壇!

+0

這是不正確的。 Apple文檔狀態:使用initWithAccessToEntityTypes:方法初始化事件存儲對象。可接受的實體類型是用於事件的EKEntityMaskEvent和用於提醒的EKEntityMaskReminder。 供貨情況\t 適用於iOS 4.0及更高版本。 –

+0

在iOS 6的文檔中?這是一種新的方法,在iOS 6之前甚至都無法使用提示。如果我不是,請不要說我錯了,請:http://developer.apple.com/library/ios/#documentation/EventKit/參考/ EKEventStoreClassRef/Reference/Reference.html –

+0

在iOS5的文檔中。我沒有安裝iOS6 SDK,只有5.1。它在IOS 5.1庫 - >核心服務層 - > EventKit - > EKEventStore類參考。 Xcode 4.4.1這裏順便說一句。 –