目前,我正在遍历所有计划的本地通知,以根据 userInfo 字典对象中的值查找“匹配”。当我设置了 30 多个本地通知时,这似乎非常慢。有没有办法在不遍历数组的情况下访问单个本地通知?
这是我所拥有的:
NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *row = nil;
for (row in notificationArray) {
NSDictionary *userInfo = row.userInfo;
NSString *identifier = [userInfo valueForKey:@"movieTitle"];
NSDate *currentAlarmDateTime = row.fireDate;
if([identifier isEqualToString:myLookUpName]) {
NSLog(@"Found a match!");
}
}
这是我想要的:
NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *row = " The row in notificationArray where [userInfo valueForKey:@"movieTitle"]=myLookUpName" ;