2
我想每天開槍上午12:01本地通知,但我不知道爲什麼我的代碼不工作,每天的iOS消防本地通知。你能幫我找到問題嗎?在特定的時間
local = [[UILocalNotification alloc]init];
NSCalendar *calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSPersianCalendar];
NSDateComponents *dateComps = [[NSDateComponents alloc] init];
//edited:
[dateComps setYear:1390]; //2012
[dateComps setMonth:10]; //1
[dateComps setDay:9]; //29
local.repeatInterval = 5;
[dateComps setHour:00];
[dateComps setMinute:1];
[dateComps setSecond:00];
local.fireDate = [calendar dateFromComponents:dateComps];
local.alertBody = @"HELLO";
local.alertAction = @"View";
local.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication]scheduleLocalNotification:local];
因爲日期和時間基於波斯日曆,所以我應該爲我的日期聲明NSPersianCalendar,我還添加了年,日和月以及'repeatInterval',你會看到我的編輯代碼: – 2012-01-28 15:09:07
'repeatInterval'應該是一個'NSCalendarUnit',如'NSDayCalendarUnit',不是一個整數。此外,您可能需要設置通知的'repeatCalendar'因爲你正在與波斯日曆中工作(我沒有與這雖然任何經驗)。 – omz 2012-01-28 18:15:13
請你寫NSGregorianCalendar的示例代碼?那麼我可以把它轉換成波斯語, – 2012-01-29 09:54:40