在Core Data中存储ABRecordRef [英] Storing ABRecordRef in Core Data

查看:209
本文介绍了在Core Data中存储ABRecordRef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在核心数据中的客户端实体中存储ABRecordRef。



我已经阅读苹果文档,ABRecordRef是一个原始的C数据类型。据我所知,你只能在核心数据中插入对象。考虑到这一点,什么是将它存储在核心数据的最好方法?



我想将它转换为NSNumber存储,但不知道如何转换回到ABRecordRef使用。



我也以为我可以把它放在一个NSArray / NSSet / NSDictionary自己只是作为一个包装器,但不知道这是否



非常感谢









$ b在我的一个应用程序中,我刚刚将ABRecordGetRecordID()作为INT32存储在CoreData存储中(因为ABRecordID是一个i​​nt32_t),并且还存储了联系人名称在CoreData存储中以便快速显示。这样,记录信息存储在它所属的AddressBook中,您刚刚存储了一个指向您的CoreData存储中的记录的指针。



然后可以创建方便您的自定义客户端NSManagedObject中的包装访问器,将包装C调用到AB框架以满足您的需要。


I would like to store a ABRecordRef in a 'Client' entity in core data.

I have read in apples documentation that ABRecordRef is a primitive C data type. As far as I am aware, you can only insert objects in core data. With this in mind, what is the best way to store it in core data?

I thought about converting it into a NSNumber for storage, but dont know how to convert it back to ABRecordRef for use.

I also thought I could just put it in a NSArray/NSSet/NSDictionary on its own just acting as a wrapper but didnt know if this was silly/inefficient/would even work.

Thoughts appreciated.

Many thanks

解决方案

In one of my apps I just stored the ABRecordGetRecordID() as a INT32 in the CoreData store (since an ABRecordID is a int32_t) and also stored the contact name in the CoreData store for quick display purposes. That way the Record information is stored in the AddressBook where it belongs and you have just stored a "pointer" to the record in your CoreData store.

You could then create handy wrapper accessors in your custom Client NSManagedObject that would wrap the C calls to the AB framework to suit your needs.

这篇关于在Core Data中存储ABRecordRef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆