Friday, 28 November 2014

iOS 8.2 makes the view property of UIViewController an implicitly-unwrapped optional

Refer: API-Diff

This change documents the fact, that view should not be accessed until a UIViewController's viewDidLoad() method is called. Accessing the view of a UIViewController before it was loaded causes an NSInternalInconsistencyException.

Wednesday, 26 November 2014

Notes for Core Data

* Use performBlock to do tasks on NSManagedObjectContext

* Three types of concurrency available for NSManagedObjectContext
  - Main thread linked to UI (NSMainQueueConcurrencyType)
  - Private queue for background tasks (NSPrivateQueueConcurrencyType)
  - Confinement for legacy (NSConfinementConcurrencyType)

* NSConfinementConcurrencyType
  - used with 
    - serialised dispatch_queue or
    - NSOperationQueue with max concurrency one
  - harder to manage

* To simplify usage of Core Data APIs, use NSMainQueueConcurrencyType
  - View controllers and other UI components can use directly and are not required to know about performBlock: APIs.

* NSManagedObject owned by NSManagedObjectContext it was created in
  - Access allowed in only the NSOperationQueue (or dispatch_queue) the related NSManagedObjectContext is related to.
  - Use objectID of NSManagedObject to pass around objects.

* New in iOS 8 to check (advanced use):
  - NSBatchUpdateRequest
  - NSAsynchronousFetchRequest - returns immediately and on completion, runs the given block