Question

I'm trying to attach an NSManagedObjectID to a UILocalNotification but keep getting the error: Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType')

Here's my code (taskID is an NSManagedObjectID):

// Create the new notification
UILocalNotification *newNotice = [[notificationClass alloc] init];
[newNotice setFireDate:date];
[newNotice setTimeZone:[NSTimeZone defaultTimeZone]];
[newNotice setAlertBody:@"Test text"];

// Add the object ID to the userinfo
NSDictionary *myUserInfo = [NSDictionary dictionaryWithObject:taskID forKey:@"TaskID"];
newNotice.userInfo = myUserInfo;

taskID is passed into the function with this code (first parameter):

addNotification([task objectID], [task taskname], [task taskexpiry]);

task is an NSManagedObject and that code has been tested and working fine for a long time.

From everything I've read this should work. Any help would be greatly appreciated.

Jason

Was it helpful?

Solution

The userInfo must be a valid property list. See What is a Property List?. NSManagedObjectID is not any of the types allowed in a property list.

Try using [[taskID URIRepresentation] absoluteString] as your userInfo. You'll have to use -[NSPersistentStoreCoordinator managedObjectIDForURIRepresentation:] later to turn it back into an NSManagedObjectID.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top