ios - Saving images in core data using app's default global queue leads to freeze? -
i working on application app fetches images facebook. using core data save image. use dispatch_asyc
function save image in core data. use
dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0)
to save image main thread doesn't block.
but times observed app freezes , doesn't respond. use same way of saving image core data @ different places in app, if user goes signed user profile, app saves album photos in same way. if user goes full screen of image, starts fetching of comments, likes , saves in same way.
if use private queue , use same saving app doesn't freeze.
since using global queue @ many places in app, reason freeze of app?
thanks.
you should read core data programming guide section concurrency here. sounds you're accessing managedobjectcontext outside of thread created illegal. better off using child context performblock perform task. this:
nsmanagedobjectcontext *context = [[nsmanagedobjectcontext alloc] initwithconcurrencytype:nsprivatequeueconcurrencytype]; [context setparentcontext:parentcontext]; [context performblock:^{ //save image }];
Comments
Post a Comment