缓存结构对象 [英] Caching the struct Object
本文介绍了缓存结构对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Objective-C中为结构指针对象创建缓存?是否有任何第三方组件可以像Java和.NET一样缓存对象?
How do I create a cache for a struct pointer object in Objective-C? Is there any third party component for caching objects as Java and .NET have?
我具有以下结构:
typedef struct _news {
references
char *headline;
char *story_url;
} news;
在接口类中,我有一个以上结构的双指针。我想使用Objective-C将其缓存一段时间。
I have a double pointer for the above struct in an interface class. I would like to cache it for some time using Objective-C.
推荐答案
您是否正在搜索类似的内容?
Are you searching for something like this?
// save
NSMutableData *data = [[NSMutableData alloc] init];
[data appendBytes:&p length:sizeof(news)];
// read
struct news *begin = (struct news *)[data bytes];
这篇关于缓存结构对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文