Swift - 'init()' was deprecated in iOS 9.0: Use -initWithConcurrencyType: instead
Change it to:
var managedObjectContext = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
You can download Apple's document to see more details.
NSConfinementConcurrencyType
Specifies that the context will use the thread confinement pattern.
Available in iOS 3.0 and later.
Deprecated in iOS 9.0.
Or Command+Click "NSManagedObjectContext" direct to NSManagedObjectContext.h:
@available(iOS, introduced=3.0, deprecated=9.0, message="Use another NSManagedObjectContextConcurrencyType")
case ConfinementConcurrencyType
@available(iOS, introduced=3.0, deprecated=9.0, message="Use -initWithConcurrencyType: instead")
public convenience init()
So it seems NSManagedObjectContext() use "ConfinementConcurrencyType" to init.When Apple deprecated "ConfinementConcurrencyType" in iOS 9.0,for the sake of coherence,Apple did not change the behavior of init() method.
So you'd better use another NSManagedObjectContextConcurrencyTypes( PrivateQueueConcurrencyType, MainQueueConcurrencyType) with another init method:
init(concurrencyType: NSManagedObjectContextConcurrencyType)
NSManagedObjectContext(): `init()` was deprecated in iOS 9.0: Use -initWithConcurrencyType
You essentially will always have at least 1 context with NSMainQueueConcurrencyType
and many contexts with NSPrivateQueueConcurrencyType
. NSPrivateQueueConcurrencyType
is used typically for saving or fetching things to core data in the background (like if attempting to sync records with a Web Service).
The NSMainQueueConcurrencyType
creates a context associated with the main queue which is perfect for use with NSFetchedResultsController
.
The default core data stack uses a single context with NSMainQueueConcurrencyType
, but you can create a much better app by leveraging multiple NSPrivateQueueConcurrencyType
to do any work that does not affect the UI.
NSURLConnection initWithRequest is deprecated
It seems that the whole NSURLConnection
API has been deprecated in iOS 9. Existing apps will continue to work, but new builds (linked against iOS SDK) must use the newer NSURLSession
API.
Ray Wenderlich has a good tutorial here.
Also, of course, check the official documentation.
Related Topics
Tab Bar Item Icons Appear Darker
Protocol Variable Implementing Another Protocol
Sharing Screenshot of Swiftui View Causes Crash
Issue with Optional Core Data Relationship Using Nspersistentcloudkitcontainer
Cannot Increment Beyond Endindex
How to Use Protocols for Stucts to Emulate Classes Inheritance
Double Variable in Mkmapitem Array
How to Fix Dylib with Invalid Signature
Expose an Interface of a Class Loaded from a Framework at Runtime
How to Stop Playback of Avplayerviewcontroller as UIviewrepresentable After Dismissal
Swift: How to Get Image Name from Assets
Exc_Badinstruction When Computing a Hash Value
Access Environment Variable Inside Global Function - Swiftui + Coredata
Generic Return Type Based on Class
Animate Line Under One Button to Another
Trim Video Always Fail When Use Avassetexportpresetpassthrough