Slide 1

Slide 1 text

Realm meetup #16 [email protected]

Slide 2

Slide 2 text

Katsumi Kishikawa Realm Inc. [email protected]

Slide 3

Slide 3 text

Recent Updates [email protected]

Slide 4

Slide 4 text

Recent Updates • Realm Objective-C/Swift 1.0.1 (was 1.0.0) • Realm Java 1.0.1 (was 1.0.0) • Realm React Native 0.13.0 • Realm Xamarin 0.76.0 [email protected] [email protected]

Slide 5

Slide 5 text

Realm Objective-C/Swift 1.0.1 (was 1.0.1) [email protected]

Slide 6

Slide 6 text

Realm Objective-C/Swift 1.0.1 • RealmϑΝΠϧΛ։͘ࡍͷύϑΥʔϚϯε޲্ • ॻ͖ࠐΈτϥϯβΫγϣϯͷύϑΥʔϚϯε޲্ • RealmOptionalܕͷϓϥΠϚϦΩʔΛ࣋ͭΦϒδΣΫ τΛߋ৽Ͱ͖ͳ͍໰୊ͷमਖ਼ • objectForPrimaryKey(_:key:)ͷύϥϝʔλ͕Φϓγϣ φϧʹ • ෆ۩߹ͷमਖ਼ [email protected] [email protected]

Slide 7

Slide 7 text

Already compatible with Swift 3 & Xcode 8 https://github.com/realm/realm-cocoa/issues/3796 [email protected]

Slide 8

Slide 8 text

Realm Objective-C/Swift 1.0.2 will be very soon! [email protected]

Slide 9

Slide 9 text

Realm Video Tutorial [email protected]

Slide 10

Slide 10 text

Beginning Realm on iOS www.raywenderlich.com/video-tutorials#begrealm [email protected]

Slide 11

Slide 11 text

Beginning Realm on iOS raywenderlich.com [email protected]

Slide 12

Slide 12 text

Beginning Realm on iOS raywenderlich.com [email protected]

Slide 13

Slide 13 text

WWDC 2016 [email protected]

Slide 14

Slide 14 text

What’s new in Core Data [email protected]

Slide 15

Slide 15 text

What’s new in Core Data • Simple Core Data Stack • NSPersistentStoreDescription (Like RealmConfiguratin?) • Type safety • Subclass generation • Version Pinning [email protected] [email protected]

Slide 16

Slide 16 text

Simpler Core Data Stack [email protected] lazy var managedObjectModel: NSManagedObjectModel = { let modelURL = NSBundle.mainBundle().URLForResource("Example", withExtension: "momd")! return NSManagedObjectModel(contentsOfURL: modelURL)! }() lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = { var coordinator: NSPersistentStoreCoordinator? = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel) let url = self.applicationDocumentsDirectory.URLByAppendingPathComponent("Example.sqlite") var error: NSError? = nil var failureReason = "There was an error creating or loading the application's saved data." if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil { coordinator = nil NSLog("Unresolved error \(error), \(error!.userInfo)") abort() } return coordinator }() lazy var managedObjectContext: NSManagedObjectContext? = { let coordinator = self.persistentStoreCoordinator if coordinator == nil { return nil } var managedObjectContext = NSManagedObjectContext() managedObjectContext.persistentStoreCoordinator = coordinator return managedObjectContext }()

Slide 17

Slide 17 text

Simpler Core Data Stack [email protected] lazy var persistentContainer: NSPersistentContainer = { let container = NSPersistentContainer(name: "Example") container .loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error { fatalError("Unresolved error \(error), \(error.userInfo)") } }) return container }()

Slide 18

Slide 18 text

Typed fetch request [email protected] let request: NSFetchRequest = Dog.fetchRequest() request.predicate = Predicate(format: "...") request.fetchBatchSize = 20 let dogs = try! persistentContainer.viewContext.fetch(request) print(dogs)

Slide 19

Slide 19 text

Typed fetch request [email protected] let request: NSFetchRequest = Dog.fetchRequest() request.predicate = Predicate(format: "...") request.fetchBatchSize = 20 let dogs = try! persistentContainer.viewContext.fetch(request) print(dogs)

Slide 20

Slide 20 text

Insert [email protected] let dog = Dog(context: persistentContainer.viewContext) ... try! persistentContainer.viewContext.save()

Slide 21

Slide 21 text

Backgroud task [email protected] let context = persistentContainer.newBackgroundContext() ...

Slide 22

Slide 22 text

Backgroud task [email protected] persistentContainer.performBackgroundTask { (context) in ... }

Slide 23

Slide 23 text

Auto generation subclasses [email protected] import Foundation import CoreData class Dog: NSManagedObject { } extension Dog { @nonobjc class func fetchRequest() -> NSFetchRequest { return NSFetchRequest(entityName: "Dog"); } @NSManaged var age: Int64 @NSManaged var name: String? }

Slide 24

Slide 24 text

Where to find us • ! Realm Japan User Group: facebook.com/groups/realmjp • ! Twitter: twitter.com/realmJapan • GitHub: github.com/realm • ! StackOverflow: ja.stackoverflow.com/questions/tagged/realm • ! Email: [email protected] • ! Slack: slack.realm.io/ [email protected] [email protected]

Slide 25

Slide 25 text

Realm Japan User Group Facebook [email protected]

Slide 26

Slide 26 text

Support Chat Slack [email protected]

Slide 27

Slide 27 text

Ξϯέʔτ http://bit.ly/RealmJP_16 [email protected]

Slide 28

Slide 28 text

Questions? Katsuma Kishikawa [email protected] www.realm.io/jp @k_katsumi