Swift - Load information from Core Data faster -


hey how big amount of information 1000 rows without stuck? try this:

dispatch_async(dispatch_get_main_queue(), { //here code }) 

but when executed request self.context.executefetchrequest returns me fatal error: unexpectedly found nil while unwrapping optional value. have error , have add self. in front of function.

    let queue:dispatch_queue_t = dispatch_get_global_queue(dispatch_queue_priority_default, 0)  dispatch_async(queue, { () -> void in                  //code         }) 

but same error...

i use nsfetchrequest , add results in nsarray , loop results in loop , in loop sort results in dictionaries.

1000 records not core data. fetch them on thread.

i not advise "sort results in dictionaries". should think how app logic interacts data , fetch objects need core data persistent store.

for example, if want display 1000 lines in table view, use `nsfetchedresultscontroller´ optimized sort of situation - avoid memory , performance issues without work.

if need threading core data (which doubt) advise not start gcd use core data's own concurrency apis, such performblock , global queue child contexts. won't have worry those.

finally, error referring code have not posted. has swift's optionals. example, if declare variable type variable : string? (or use api returns such type), can unwrap variable! if sure not nil . if nil above crash.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -