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