2011-05-04 54 views
0

我試圖從已經設置通知iPhone - UILocalNotification fireDate問題

繼承人我的代碼獲得fireDate:

NSArray *notificationArray = [[NSArray alloc] initWithObjects:[[UIApplication sharedApplication] scheduledLocalNotifications], nil]; 



if ([notificationArray count] > 0) { 

    NSDate *now = [NSDate date]; 

    UILocalNotification *locNotification = [[UILocalNotification alloc] init]; 
    locNotification = [notificationArray objectAtIndex:0]; 

    NSDate *otherDate = locNotification.fireDate; 
} 

的locNotification有值,但最後一行時,我嘗試實例otherDate我越來越

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM fireDate]: unrecognized selector sent to instance 0x1e4e20' 

*調用堆棧在第一擲:

我真的不知道我在做什麼錯。

在此先感謝

回答

3

您正在使用錯誤的init方法。相反NSArray-initWithObjects:的,你想:

NSArray *notificationArray = [[ NSArray alloc ] initWithArray: 
            [[ UIApplication sharedApplication ] 
             scheduledLocalNotifications ]]; 

你得到的異常,因爲notificationArray只包含一個對象,通過-scheduledLocalNotifications返回的數組。

+0

就是這樣。奇怪的是,我得到了我的錯誤初始化數組內的結果。抱歉。新手問題=)非常感謝 – Chompas 2011-05-04 03:23:42