Zel*_*lko 5 twitter core-data ios afincrementalstore ios7
你如何映射AFIncrementalStore
到Twitter API v1.1?
AFNetworking的核心数据持久性,完成正确
https://github.com/AFNetworking/AFIncrementalStore
REST API v1.1资源
https://dev.twitter.com/docs/api/1.1
- (id)representationOrArrayOfRepresentationsOfEntity:(NSEntityDescription *)entity
fromResponseObject:(id)responseObject;
- (NSDictionary *)representationsForRelationshipsFromRepresentation:(NSDictionary *)representation
ofEntity:(NSEntityDescription *)entity
fromResponse:(NSHTTPURLResponse *)response;
- (NSString *)resourceIdentifierForRepresentation:(NSDictionary *)representation
ofEntity:(NSEntityDescription *)entity
fromResponse:(NSHTTPURLResponse *)response;
- (NSDictionary *)attributesForRepresentation:(NSDictionary *)representation
ofEntity:(NSEntityDescription *)entity
fromResponse:(NSHTTPURLResponse *)response;
- (NSMutableURLRequest *)requestForFetchRequest:(NSFetchRequest *)fetchRequest
withContext:(NSManagedObjectContext *)context;
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
pathForObjectWithID:(NSManagedObjectID *)objectID
withContext:(NSManagedObjectContext *)context;
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
pathForRelationship:(NSRelationshipDescription *)relationship
forObjectWithID:(NSManagedObjectID *)objectID
withContext:(NSManagedObjectContext *)context;
Run Code Online (Sandbox Code Playgroud)
我不知道我写的是否完全有帮助,但这是我所知道的:
AFIncrementalStore 存在一些严重问题,显然已被其创建者放弃,因为它与 AFNetworking v. 2 不兼容
问题的产生是因为 AFIS 试图不仅仅是增量存储。增量存储仅在其重写方法内运行,AFIS 这样做是为了立即从后备存储返回对象。然而,当请求最终到来时,它不能以这种方式添加对象。它将它们添加到后备存储中,然后尝试刷新其上下文中的对象。核心数据创建者没有预见到这种行为,并会导致不稳定的行为 - AFIS 有时响应时间很长,有时对象无法正确刷新。此外,如果您使用 NSFetchedResultsController 来提供表视图,则某些回调会经常被调用,而有些则从不被调用。
我花了很多时间试图让它工作,但这可能是不可能的 - 你必须欺骗核心数据,你正在将对象添加到上下文中,但从不这样做。
回到你的问题 - 如果你真的想使用它 - 你基本上必须为 twitter 编写所有这些方法。这是一项艰巨的工作,但 Twitter 必须有一些对象模型,并为每个对象分配一些 id。我为我的 API 这样做了,但这就像一两天的辛苦工作 - 而且我没有那么多时间在这里写它。
归档时间: |
|
查看次数: |
110 次 |
最近记录: |