Iphone 在特定日期和时间通知
所以我需要你的帮助:我必须在特定的日期和时间内设置代码notify。请帮我修改代码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
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”)时帮助我修复通知必须在特定时间运行