0

First of all, I know that it's impossible to serialize a NSManagedObject in the userInfo.

My question is : Imagine my app using CoreData. When I create a new NSManagedObject, I also schedule a LocalNotification (this is a toy example). Then, when the AppDelegate received the notification, I would like to know the corresponding NSManagedObject to display it.

Does somebody know a trick to handle that?

Thanks in advance. AppPié

AppPié
  • 41
  • 1
  • 5

2 Answers2

0

Matt Gallagher has a great blog post about this: http://cocoawithlove.com/2008/08/safely-fetching-nsmanagedobject-by-uri.html

Essentially, ask the NSManagedObject for it's objectID, fetch the URIRepresentation of that id, and store the URI.

He also covers some of the sharp edges related to getting the NSManagedObject using the URI, so you should really just read the blog post.

Dan Jackson
  • 451
  • 3
  • 5
0

Hmmm ... Store a unique identifier in your Core Data model, which you send in your userInfo dictionary, to be accessed and then fetched (using the uniqueID) in the app delegate.

Benjamin Mayo
  • 6,649
  • 2
  • 26
  • 25