简体   繁体   中英

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!

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.

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM