Realm Objective-C & Swift 0.94
We just pushed version 0.94 of Realm Objective-C and Realm Swift. Along with many bug fixes and performance enhancements, this release improves support for Xcode 7 Beta 4, watchOS, Swift 2.0, Objective-C generics, and bitcode.
We’ve also exposed the ability to swap & move objects in an
RLMArray or a
Finally, to allow us to make more informed product decisions moving forward, this release introduces the collection of development analytics.
Read on for an overview of all the changes included in 0.94.
RLMRealm notification listener threads should now consume less memory than ever before. This is part of an ongoing effort to reduce the memory footprint of apps using Realm.
Filtering and sorting results is now done lazily, which will further reduce the overhead of chaining queries together.
Support for New Apple Features
The Objective-C API has been fully annotated for nullability semantics to provide enhanced compiler warnings and bridging to Swift. Here’s what that looks like when using Realm Objective-C from Swift:
// Before nullability annotations class func ignoredProperties() -> [AnyObject]! // After nullability annotations class func ignoredProperties() -> [AnyObject]
RLMArrays now support native Objective-C generics if available (Xcode 7 or later), which should help catch more type errors at compile-time.
Here’s how you can make use of these new generics:
// Define a Company model with a generic array of employees @interface Company : RLMObject @property RLMArray<Employee *><Employee> *employees; @end // Retrieve all employees and store in a generic RLMResults RLMResults<Employee *> *allEmployees = [Employee allObjects];
Here’s what the different components of the RLMArray property definition mean and why they are useful:
RLMArray: The property type.
<Object *>: The generic specialization. This helps prevent using the array with the wrong object type at compile-time.
<Object>: The protocol this
RLMArrayconforms to. This enables Realm to know how to specialize the schema of this model at runtime.
Objective-C generics are unfortunately type-erased, which means Realm can’t determine the specialization at runtime. This is why the protocol conformance declaration is still necessary, even though it’s unsightly. We apologize for the angle-bracket blindness!
Bitcode, watchOS & Swift 2.0
iOS & watchOS builds of Realm now include bitcode. Our zip archives distributed via this website, GitHub Releases, and Carthage now include builds for all these configurations:
- Objective-C / Swift 1.2 / Swift 2.0 Beta 4
- Mac / iOS / watchOS
Yikes! And people say Android is fragmented!
- The exceptions thrown in getters and setters are more informative.
List.swap(_:_:)to allow exchanging the location of two objects in the given
List.move(from:to:)to allow moving objects in the given
- Processes crashing due to an uncaught exception inside a write transaction will
- Fix incorrect results when querying for < or <= on ints that require 64 bits to represent with a CPU that supports SSE 4.2.
- An exception will no longer be thrown when attempting to reset the schema version or encryption key on an open Realm to the current value.
- Date properties on 32 bit devices will retain 64 bit second precision.
- Wrap calls to the block passed to
enumeratein an autoreleasepool to reduce memory growth when migrating a large amount of objects.
- In-memory realms no longer write to the Documents directory on iOS or Application Support on OS X.
Realm now asynchronously submits build information to Realm if running in an iOS Simulator or on OS X if a debugger is attached. Nothing is done when running on a physical iOS / watchOS device or if a debugger is not attached.
To be clear: this does not run when your app is in production or on your end-user’s devices; it will only run in the simulator or when a debugger is attached.
For more information, see PR #2276 which introduced this change.