So here's my problem. I have a pinterest-like application with a collection view that shows images.The "pins" al downloaded from a web service and stored in core data. This web service returns the data organized in pages.
What's the correct way to face this problem? If data were all stored in core data, I could implement as NSFetchedResultsController to fetch a batch of 10 or 20 pins, but each batch needs to make the appropriate request to the web service. I've also been looking into NSIncrementalStore, which also seems promising, but I still don't know how would that work.
Right now, I have the web service working, the core data model implemented and a special class called DataManager that is responsible of the managedObjectContext, inserting, fetching, deleting, etc., from the database. I'm implementing the FetchedResultsController creator inside this class, but I still don't understand how to implement the incrementalStore or the web service call.
Any idea on how to implement this architecture will be highly appreciated.
Best regards
答案 0 :(得分:1)
不要使用NSIncrementalStore
,这不是你想要的。 NSIncrementalStore
是一种抽象,允许您在Core Data中实现自己的商店类型。
您正在寻找的是如何跨越网络应用“思考”与移动应用应该如何“思考”之间的差距。
就个人而言,我会构建NSOperation
个实例来获取这些页面并将它们全部(或合理数量)粘贴到Core Data中,让你的移动应用程序按照它应该的方式运行,显示所有可用的数据。 / p>
Pagination是一种懒惰的Web解决方案,无法在Web浏览器中本地缓存数据。您的应用程序不是Web浏览器,不遵循那些糟糕的UI约定。