Or Ron
Or Ron

Reputation: 2343

Saving CFDictionaryRef in Core Data

Im trying to save CFDictionaryRef to my core data model and I cant really find information on how to do so.

It will be immensely appreciated if someone could supply more information about it

Thanks!

Upvotes: 0

Views: 307

Answers (2)

amattn
amattn

Reputation: 10065

The canonical way to save an NSDictionary into CoreData is with NSValueTransformers.

I don't know if it works with CFDictionaries however. There is no mention of it working or not. With toll free bridging however it sure seems like it should work.

If it were me, I'd try using the value transformer. If that doesn't work, you can easily convert the CFDictionaryRef into an NSDictionary with:

NSDictionary *dictionaryObject = [NSDictionary dictionaryWithDictionary:(NSDictionary *)dictionaryRef];

Upvotes: 0

Christian Schnorr
Christian Schnorr

Reputation: 10776

You cannot save dictionaries to CoreData.
You could however try to convert it to a NSData first and convert it back to a dictionary when before using it. See this post.

Upvotes: 1

Related Questions