Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在特定日期和时间通知_Iphone_Objective C - Fatal编程技术网

Iphone 在特定日期和时间通知

Iphone 在特定日期和时间通知,iphone,objective-c,Iphone,Objective C,所以我需要你的帮助:我必须在特定的日期和时间内设置代码notify。请帮我修改代码 UILocalNotification* n1 = [[UILocalNotification alloc] init]; n1.fireDate = [NSDate dateWithTimeIntervalSinceNow: 6]; n1.alertBody = @"one"; UILocalNotification* n2 = [[UILocalNotification alloc] init]; n2.fi

所以我需要你的帮助:我必须在特定的日期和时间内设置代码notify。请帮我修改代码

UILocalNotification* n1 = [[UILocalNotification alloc] init];
n1.fireDate = [NSDate dateWithTimeIntervalSinceNow: 6];
n1.alertBody = @"one";
UILocalNotification* n2 = [[UILocalNotification alloc] init];
n2.fireDate = [NSDate dateWithTimeIntervalSinceNow: 15];
n2.alertBody = @"two";
[[UIApplication sharedApplication] scheduleLocalNotification: n1];
[[UIApplication sharedApplication] scheduleLocalNotification: n2];

您似乎不知道如何创建一个特定时间的
NSDate
。用于将字符串转换为日期

NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm"];
NSDate *myDate = [df dateFromString:@"2014-04-05 23:30"];

UILocalNotification* n1 = [[UILocalNotification alloc] init];
n1.fireDate = myDate;

有什么问题吗?什么不起作用?这两种代码?什么不起作用(即,您的具体问题是什么)?通知应在特定日期起作用您的意思是您需要创建
NSDate
而不是
datewithtimeintervals自现在起:
?但它必须与datewithtimeinterval一起工作请有人在我运行第一个(@“one”)时帮助我修复通知必须在特定时间运行