2013-02-09 16 views
0

剛開始學習iPhone,我收到以下錯誤爲「的UIApplication ..本地通知教程失敗沒有明顯的@interface

[app scheduledLocalNotifications:notification]; 

的UIApplication的不可見的@interface聲明選擇schedulelocalnotifications

有人能請幫助我。我敢肯定它的東西簡單,我只是沒有意識到,因爲這是我的第一個教程

感謝

-(IBAction)createNotification{ 

NSLog(@"createNotification"); 

NSString *dateString = dateTextField.text; 
NSString *textString = textTextField.text; 

NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; 
[formatter setDateFormat:@"MM-dd-yyyy HH:mm"]; 
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:-18000]]; 

NSDate *alertTime = [formatter dateFromString:dateString]; 

UIApplication* app = [UIApplication sharedApplication]; 

UILocalNotification *notification = [[UILocalNotification alloc] init]; 
if (notification) { 
    notification.fireDate = alertTime; 
    notification.timeZone = [NSTimeZone defaultTimeZone]; 
    notification.repeatInterval = 0; 
    notification.alertBody = textString; 

    [app scheduledLocalNotifications:notification]; 
    [app presentLocalNotificationNow:notification]; 

} 

}

回答

3

scheduledLocalNotifications是財產。

這個屬性保存UILocalNotification實例的數組 表示當前調度的本地通知。您可以設置或 重置陣列中的本地通知以及訪問它們。

讀一個文檔:http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html

變化一樣下面的代碼。

NSMutableArray *notifications = [[NSMutableArray alloc] init]; 
[notifications addObject:notification]; 
app.scheduledLocalNotifications = notifications; 
//Equivalent: [app setScheduledLocalNotifications:notifications]; 
+0

謝謝!!!欣賞幫助 – solarissf 2013-02-09 02:40:46

+0

滿意如果,upvote。 V檢查請^^ – 2013-02-09 02:41:59

+0

所以我使用模擬器...和通知只顯示一個橫幅...我怎樣才能改變它的警報? – solarissf 2013-02-09 03:18:20

相關問題