swift2 - Swift 2 Syntax Error -


so, tells me:

init() deprecated in ios 9.0: use -initwithconcurrencytype: instead

var managedobjectcontext = nsmanagedobjectcontext() 

that's code. gave error too, how should change it?

since ios 9 nsmanagedobjectcontext() deprecated , recommended create nsmanagedobjectcontext with, hinted, -initwithconcurrencytype: instead.

usage when creating nsmanagedobjectcontext in ios 9:

let managedobjectcontext = nsmanagedobjectcontext(concurrencytype: .mainqueueconcurrencytype) 

with -initwithconcurrencytype:, need specify concurrency type.

the above example creates 1 .mainqueueconcurrencytype, 1 of 3 1 can specify:

case confinementconcurrencytype 

specifies context use thread confinement pattern.

case privatequeueconcurrencytype 

specifies context associated private dispatch queue.

case mainqueueconcurrencytype 

specifies context associated main queue.

with deprecated nsmanagedobjectcontext(), if memory serves, default of type .confinementconcurrencyqueue.

to stay on topic, if dealing ui elements (i.e., updating textlabel thereby), use .mainqueueconcurrencyqueue.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

android - Go back to previous fragment -