我正在处理本地通知,为了识别每个通知,它需要从核心数据模型中获取一个作为NSDictionary
该ManagedObjectID
字典的键。
问题是当我这样做时,我收到以下错误:
Property list invalid for format: 200 (property list dictionaries may only have keys which are CFStrings, not 'CFType')
这与字典只能存储某些数据类型而不是 NSManagedObjectID 的事实有关。
所以我的问题是,有没有办法将其转换NSManagedObjectId
为 a NSString
orNSNumber
例如。我真的需要那个特定的 id 以便稍后识别它以删除该特定通知。
到目前为止的代码:
-(void) scheduleNotificationAtDate:(NSDate*)date WithBody:(NSString*) body WithBillEventId:(NSManagedObjectID*) billEventId{
// Schedule the notification
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = date;
localNotification.alertBody = body;
localNotification.alertAction = @"Ga naar de Rekening Delen app";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
//set the dictionary here,
NSDictionary *billEventIdentifier = [NSDictionary dictionaryWithObject:@"billevent_notification" forKey: billEventId];
localNotification.userInfo = billEventIdentifier;
NSLog(@"set local notification");
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}