开发者

CoreData: Fetching an Object from an unsaved Context

开发者 https://www.devze.com 2023-01-06 19:03 出处:网络
after I insert a ManagedObject into a context I\'d like to fetch it later but before saving the context (I\'d save after all objects are inserted). It appears that querying the context later with开发者

after I insert a ManagedObject into a context I'd like to fetch it later but before saving the context (I'd save after all objects are inserted). It appears that querying the context later with开发者_JS百科 a fetch concerning those objects returns nothing if the context wasn't previously saved. Is there a way to save only in the end ?(I guess i can save my objects in an array or dictionary and query that but i thought coredata would do this for me)


Try this:

[myFetchRequest setIncludesPendingChanges:YES];

From the documentation:

Sets if, when the fetch is executed, it matches against currently unsaved changes in the managed object context.

0

精彩评论

暂无评论...
验证码 换一张
取 消