commit
b356883311
@ -0,0 +1 @@ |
||||
github "realm/realm-cocoa" "v3.16.1" |
||||
@ -0,0 +1,43 @@ |
||||
{ |
||||
"Mac" : [ |
||||
{ |
||||
"name" : "RealmSwift", |
||||
"hash" : "6bed3139837241b5dfb29be8649f16f19c4da2a94c5f3e4fd007a4118a9f9777" |
||||
}, |
||||
{ |
||||
"name" : "Realm", |
||||
"hash" : "550b928fcdcf2e970f6c37b837d929c1e95b8a7d98e88793dd9f872759a07384" |
||||
} |
||||
], |
||||
"watchOS" : [ |
||||
{ |
||||
"name" : "RealmSwift", |
||||
"hash" : "195363bd867646d19b7d45b9ccc2b99c88430ac0f68b6b4123fbe025793b503a" |
||||
}, |
||||
{ |
||||
"name" : "Realm", |
||||
"hash" : "88182d76a6b04db7223e5c1e4c5293bf0951fab1592a02e53f6b255b19b68ecf" |
||||
} |
||||
], |
||||
"tvOS" : [ |
||||
{ |
||||
"name" : "RealmSwift", |
||||
"hash" : "dc43ccb5b526ea8ee6f94bd354023ac1829f3c3b43f7ed3cc25b576f9505c65e" |
||||
}, |
||||
{ |
||||
"name" : "Realm", |
||||
"hash" : "269a239efade2fc65250f094bd068523a5b13179e741a3aae6b481fd6564c537" |
||||
} |
||||
], |
||||
"commitish" : "v3.16.1", |
||||
"iOS" : [ |
||||
{ |
||||
"name" : "RealmSwift", |
||||
"hash" : "3fb8453e6a4651993c895deba5c6f6e0851c4a78614afb4b298f9f89f492301f" |
||||
}, |
||||
{ |
||||
"name" : "Realm", |
||||
"hash" : "2d2d5dee27469c62b73806d61424f6d7ef45fed9a722ac3e622e377dfc2aa2dc" |
||||
} |
||||
] |
||||
} |
||||
@ -0,0 +1,20 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>English</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>com.apple.xcode.dsym.io.Realm.Realm</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>dSYM</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>3.16.1</string> |
||||
<key>CFBundleVersion</key> |
||||
<string>3.16.1</string> |
||||
</dict> |
||||
</plist> |
||||
Binary file not shown.
@ -0,0 +1 @@ |
||||
Versions/Current/Headers |
||||
@ -0,0 +1 @@ |
||||
Versions/Current/Modules |
||||
@ -0,0 +1 @@ |
||||
Versions/Current/PrivateHeaders |
||||
@ -0,0 +1 @@ |
||||
Versions/Current/Realm |
||||
@ -0,0 +1 @@ |
||||
Versions/Current/Resources |
||||
@ -0,0 +1,46 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2017 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMSyncErrorActionToken; |
||||
|
||||
/// NSError category extension providing methods to get data out of Realm's
|
||||
/// "client reset" error.
|
||||
@interface NSError (RLMSync) |
||||
|
||||
/**
|
||||
Given an appropriate Realm Object Server error, return the token that |
||||
can be passed into `+[RLMSyncSession immediatelyHandleError:]` to |
||||
immediately perform error clean-up work, or nil if the error isn't of |
||||
a type that provides a token. |
||||
*/ |
||||
- (nullable RLMSyncErrorActionToken *)rlmSync_errorActionToken NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Given a Realm Object Server client reset error, return the path where the |
||||
backup copy of the Realm will be placed once the client reset process is |
||||
complete. |
||||
*/ |
||||
- (nullable NSString *)rlmSync_clientResetBackedUpRealmPath NS_SWIFT_UNAVAILABLE(""); |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,440 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMCollection.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMObject, RLMResults<RLMObjectType>; |
||||
|
||||
/**
|
||||
`RLMArray` is the container type in Realm used to define to-many relationships. |
||||
|
||||
Unlike an `NSArray`, `RLMArray`s hold a single type, specified by the `objectClassName` property. |
||||
This is referred to in these docs as the “type” of the array. |
||||
|
||||
When declaring an `RLMArray` property, the type must be marked as conforming to a |
||||
protocol by the same name as the objects it should contain (see the |
||||
`RLM_ARRAY_TYPE` macro). In addition, the property can be declared using Objective-C |
||||
generics for better compile-time type safety. |
||||
|
||||
RLM_ARRAY_TYPE(ObjectType) |
||||
... |
||||
@property RLMArray<ObjectType *><ObjectType> *arrayOfObjectTypes; |
||||
|
||||
`RLMArray`s can be queried with the same predicates as `RLMObject` and `RLMResult`s. |
||||
|
||||
`RLMArray`s cannot be created directly. `RLMArray` properties on `RLMObject`s are |
||||
lazily created when accessed, or can be obtained by querying a Realm. |
||||
|
||||
### Key-Value Observing |
||||
|
||||
`RLMArray` supports array key-value observing on `RLMArray` properties on `RLMObject` |
||||
subclasses, and the `invalidated` property on `RLMArray` instances themselves is |
||||
key-value observing compliant when the `RLMArray` is attached to a managed |
||||
`RLMObject` (`RLMArray`s on unmanaged `RLMObject`s will never become invalidated). |
||||
|
||||
Because `RLMArray`s are attached to the object which they are a property of, they |
||||
do not require using the mutable collection proxy objects from |
||||
`-mutableArrayValueForKey:` or KVC-compatible mutation methods on the containing |
||||
object. Instead, you can call the mutation methods on the `RLMArray` directly. |
||||
*/ |
||||
|
||||
@interface RLMArray<RLMObjectType> : NSObject<RLMCollection, NSFastEnumeration> |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The number of objects in the array. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) NSUInteger count; |
||||
|
||||
/**
|
||||
The type of the objects in the array. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) RLMPropertyType type; |
||||
|
||||
/**
|
||||
Indicates whether the objects in the collection can be `nil`. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isOptional) BOOL optional; |
||||
|
||||
/**
|
||||
The class name of the objects contained in the array. |
||||
|
||||
Will be `nil` if `type` is not RLMPropertyTypeObject. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *objectClassName; |
||||
|
||||
/**
|
||||
The Realm which manages the array. Returns `nil` for unmanaged arrays. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) RLMRealm *realm; |
||||
|
||||
/**
|
||||
Indicates if the array can no longer be accessed. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
#pragma mark - Accessing Objects from an Array |
||||
|
||||
/**
|
||||
Returns the object at the index specified. |
||||
|
||||
@param index The index to look up. |
||||
|
||||
@return An object of the type contained in the array. |
||||
*/ |
||||
- (RLMObjectType)objectAtIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Returns the first object in the array. |
||||
|
||||
Returns `nil` if called on an empty array. |
||||
|
||||
@return An object of the type contained in the array. |
||||
*/ |
||||
- (nullable RLMObjectType)firstObject; |
||||
|
||||
/**
|
||||
Returns the last object in the array. |
||||
|
||||
Returns `nil` if called on an empty array. |
||||
|
||||
@return An object of the type contained in the array. |
||||
*/ |
||||
- (nullable RLMObjectType)lastObject; |
||||
|
||||
|
||||
|
||||
#pragma mark - Adding, Removing, and Replacing Objects in an Array |
||||
|
||||
/**
|
||||
Adds an object to the end of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param object An object of the type contained in the array. |
||||
*/ |
||||
- (void)addObject:(RLMObjectType)object; |
||||
|
||||
/**
|
||||
Adds an array of objects to the end of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param objects An enumerable object such as `NSArray` or `RLMResults` which contains objects of the |
||||
same class as the array. |
||||
*/ |
||||
- (void)addObjects:(id<NSFastEnumeration>)objects; |
||||
|
||||
/**
|
||||
Inserts an object at the given index. |
||||
|
||||
Throws an exception if the index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param anObject An object of the type contained in the array. |
||||
@param index The index at which to insert the object. |
||||
*/ |
||||
- (void)insertObject:(RLMObjectType)anObject atIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Removes an object at the given index. |
||||
|
||||
Throws an exception if the index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param index The array index identifying the object to be removed. |
||||
*/ |
||||
- (void)removeObjectAtIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Removes the last object in the array. |
||||
|
||||
This is a no-op if the array is already empty. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
*/ |
||||
- (void)removeLastObject; |
||||
|
||||
/**
|
||||
Removes all objects from the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
*/ |
||||
- (void)removeAllObjects; |
||||
|
||||
/**
|
||||
Replaces an object at the given index with a new object. |
||||
|
||||
Throws an exception if the index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param index The index of the object to be replaced. |
||||
@param anObject An object (of the same type as returned from the `objectClassName` selector). |
||||
*/ |
||||
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(RLMObjectType)anObject; |
||||
|
||||
/**
|
||||
Moves the object at the given source index to the given destination index. |
||||
|
||||
Throws an exception if the index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param sourceIndex The index of the object to be moved. |
||||
@param destinationIndex The index to which the object at `sourceIndex` should be moved. |
||||
*/ |
||||
- (void)moveObjectAtIndex:(NSUInteger)sourceIndex toIndex:(NSUInteger)destinationIndex; |
||||
|
||||
/**
|
||||
Exchanges the objects in the array at given indices. |
||||
|
||||
Throws an exception if either index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param index1 The index of the object which should replace the object at index `index2`. |
||||
@param index2 The index of the object which should replace the object at index `index1`. |
||||
*/ |
||||
- (void)exchangeObjectAtIndex:(NSUInteger)index1 withObjectAtIndex:(NSUInteger)index2; |
||||
|
||||
#pragma mark - Querying an Array |
||||
|
||||
/**
|
||||
Returns the index of an object in the array. |
||||
|
||||
Returns `NSNotFound` if the object is not found in the array. |
||||
|
||||
@param object An object (of the same type as returned from the `objectClassName` selector). |
||||
*/ |
||||
- (NSUInteger)indexOfObject:(RLMObjectType)object; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the array matching the predicate. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the array. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the array matching the predicate. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the array. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns all the objects matching the given predicate in the array. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` of objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)objectsWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMResults<RLMObjectType> *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns all the objects matching the given predicate in the array. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` of objects that match the given predicate |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)objectsWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from the array. |
||||
|
||||
@param keyPath The key path to sort by. |
||||
@param ascending The direction to sort in. |
||||
|
||||
@return An `RLMResults` sorted by the specified key path. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)sortedResultsUsingKeyPath:(NSString *)keyPath ascending:(BOOL)ascending; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from the array. |
||||
|
||||
@param properties An array of `RLMSortDescriptor`s to sort by. |
||||
|
||||
@return An `RLMResults` sorted by the specified properties. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)sortedResultsUsingDescriptors:(NSArray<RLMSortDescriptor *> *)properties; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMObjectType)objectAtIndexedSubscript:(NSUInteger)index; |
||||
|
||||
/// :nodoc:
|
||||
- (void)setObject:(RLMObjectType)newValue atIndexedSubscript:(NSUInteger)index; |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
Registers a block to be called each time the array changes. |
||||
|
||||
The block will be asynchronously called with the initial array, and then |
||||
called again after each write transaction which changes any of the objects in |
||||
the array, which objects are in the results, or the order of the objects in the |
||||
array. |
||||
|
||||
The `changes` parameter will be `nil` the first time the block is called. |
||||
For each call after that, it will contain information about |
||||
which rows in the array were added, removed or modified. If a write transaction |
||||
did not modify any objects in the array, the block is not called at all. |
||||
See the `RLMCollectionChange` documentation for information on how the changes |
||||
are reported and an example of updating a `UITableView`. |
||||
|
||||
If an error occurs the block will be called with `nil` for the results |
||||
parameter and a non-`nil` error. Currently the only errors that can occur are |
||||
when opening the Realm on the background worker thread. |
||||
|
||||
Notifications are delivered via the standard run loop, and so can't be |
||||
delivered while the run loop is blocked by other activity. When |
||||
notifications can't be delivered instantly, multiple notifications may be |
||||
coalesced into a single notification. This can include the notification |
||||
with the initial results. For example, the following code performs a write |
||||
transaction immediately after adding the notification block, so there is no |
||||
opportunity for the initial notification to be delivered first. As a |
||||
result, the initial notification will reflect the state of the Realm after |
||||
the write transaction. |
||||
|
||||
Person *person = [[Person allObjectsInRealm:realm] firstObject]; |
||||
NSLog(@"person.dogs.count: %zu", person.dogs.count); // => 0
|
||||
self.token = [person.dogs addNotificationBlock(RLMArray<Dog *> *dogs, |
||||
RLMCollectionChange *changes, |
||||
NSError *error) { |
||||
// Only fired once for the example
|
||||
NSLog(@"dogs.count: %zu", dogs.count) // => 1
|
||||
}]; |
||||
[realm transactionWithBlock:^{ |
||||
Dog *dog = [[Dog alloc] init]; |
||||
dog.name = @"Rex"; |
||||
[person.dogs addObject:dog]; |
||||
}]; |
||||
// end of run loop execution context
|
||||
|
||||
You must retain the returned token for as long as you want updates to continue |
||||
to be sent to the block. To stop receiving updates, call `-invalidate` on the token. |
||||
|
||||
@warning This method cannot be called during a write transaction, or when the |
||||
containing Realm is read-only. |
||||
@warning This method may only be called on a managed array. |
||||
|
||||
@param block The block to be called each time the array changes. |
||||
@return A token which must be held for as long as you want updates to be delivered. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(void (^)(RLMArray<RLMObjectType> *__nullable array, |
||||
RLMCollectionChange *__nullable changes, |
||||
NSError *__nullable error))block __attribute__((warn_unused_result)); |
||||
|
||||
#pragma mark - Aggregating Property Values |
||||
|
||||
/**
|
||||
Returns the minimum (lowest) value of the given property among all the objects in the array. |
||||
|
||||
NSNumber *min = [object.arrayProperty minOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose minimum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The minimum value of the property, or `nil` if the array is empty. |
||||
*/ |
||||
- (nullable id)minOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the maximum (highest) value of the given property among all the objects in the array. |
||||
|
||||
NSNumber *max = [object.arrayProperty maxOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose maximum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The maximum value of the property, or `nil` if the array is empty. |
||||
*/ |
||||
- (nullable id)maxOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the sum of the values of a given property over all the objects in the array. |
||||
|
||||
NSNumber *sum = [object.arrayProperty sumOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose values should be summed. Only properties of |
||||
types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The sum of the given property. |
||||
*/ |
||||
- (NSNumber *)sumOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the average value of a given property over the objects in the array. |
||||
|
||||
NSNumber *average = [object.arrayProperty averageOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose average value should be calculated. Only |
||||
properties of types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The average value of the given property, or `nil` if the array is empty. |
||||
*/ |
||||
- (nullable NSNumber *)averageOfProperty:(NSString *)property; |
||||
|
||||
|
||||
#pragma mark - Unavailable Methods |
||||
|
||||
/**
|
||||
`-[RLMArray init]` is not available because `RLMArray`s cannot be created directly. |
||||
`RLMArray` properties on `RLMObject`s are lazily created when accessed. |
||||
*/ |
||||
- (instancetype)init __attribute__((unavailable("RLMArrays cannot be created directly"))); |
||||
|
||||
/**
|
||||
`+[RLMArray new]` is not available because `RLMArray`s cannot be created directly. |
||||
`RLMArray` properties on `RLMObject`s are lazily created when accessed. |
||||
*/ |
||||
+ (instancetype)new __attribute__((unavailable("RLMArrays cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
/// :nodoc:
|
||||
@interface RLMArray (Swift) |
||||
// for use only in Swift class definitions
|
||||
- (instancetype)initWithObjectClassName:(NSString *)objectClassName; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,401 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import <Realm/RLMConstants.h> |
||||
#import <Realm/RLMThreadSafeReference.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMRealm, RLMResults, RLMSortDescriptor, RLMNotificationToken, RLMCollectionChange; |
||||
typedef RLM_CLOSED_ENUM(int32_t, RLMPropertyType); |
||||
|
||||
/**
|
||||
A homogenous collection of Realm-managed objects. Examples of conforming types |
||||
include `RLMArray`, `RLMResults`, and `RLMLinkingObjects`. |
||||
*/ |
||||
@protocol RLMCollection <NSFastEnumeration, RLMThreadConfined> |
||||
|
||||
@required |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The number of objects in the collection. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) NSUInteger count; |
||||
|
||||
/**
|
||||
The type of the objects in the collection. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) RLMPropertyType type; |
||||
|
||||
/**
|
||||
Indicates whether the objects in the collection can be `nil`. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isOptional) BOOL optional; |
||||
|
||||
/**
|
||||
The class name of the objects contained in the collection. |
||||
|
||||
Will be `nil` if `type` is not RLMPropertyTypeObject. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *objectClassName; |
||||
|
||||
/**
|
||||
The Realm which manages the collection, or `nil` for unmanaged collections. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMRealm *realm; |
||||
|
||||
#pragma mark - Accessing Objects from a Collection |
||||
|
||||
/**
|
||||
Returns the object at the index specified. |
||||
|
||||
@param index The index to look up. |
||||
|
||||
@return An object of the type contained in the collection. |
||||
*/ |
||||
- (id)objectAtIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Returns the first object in the collection. |
||||
|
||||
Returns `nil` if called on an empty collection. |
||||
|
||||
@return An object of the type contained in the collection. |
||||
*/ |
||||
- (nullable id)firstObject; |
||||
|
||||
/**
|
||||
Returns the last object in the collection. |
||||
|
||||
Returns `nil` if called on an empty collection. |
||||
|
||||
@return An object of the type contained in the collection. |
||||
*/ |
||||
- (nullable id)lastObject; |
||||
|
||||
#pragma mark - Querying a Collection |
||||
|
||||
/**
|
||||
Returns the index of an object in the collection. |
||||
|
||||
Returns `NSNotFound` if the object is not found in the collection. |
||||
|
||||
@param object An object (of the same type as returned from the `objectClassName` selector). |
||||
*/ |
||||
- (NSUInteger)indexOfObject:(id)object; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the collection matching the predicate. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the collection. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the collection matching the predicate. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the collection. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns all objects matching the given predicate in the collection. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` containing objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults *)objectsWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMResults *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns all objects matching the given predicate in the collection. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` containing objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults *)objectsWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from the collection. |
||||
|
||||
@param keyPath The keyPath to sort by. |
||||
@param ascending The direction to sort in. |
||||
|
||||
@return An `RLMResults` sorted by the specified key path. |
||||
*/ |
||||
- (RLMResults *)sortedResultsUsingKeyPath:(NSString *)keyPath ascending:(BOOL)ascending; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from the collection. |
||||
|
||||
@param properties An array of `RLMSortDescriptor`s to sort by. |
||||
|
||||
@return An `RLMResults` sorted by the specified properties. |
||||
*/ |
||||
- (RLMResults *)sortedResultsUsingDescriptors:(NSArray<RLMSortDescriptor *> *)properties; |
||||
|
||||
/// :nodoc:
|
||||
- (id)objectAtIndexedSubscript:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Returns an `NSArray` containing the results of invoking `valueForKey:` using `key` on each of the collection's objects. |
||||
|
||||
@param key The name of the property. |
||||
|
||||
@return An `NSArray` containing results. |
||||
*/ |
||||
- (nullable id)valueForKey:(NSString *)key; |
||||
|
||||
/**
|
||||
Invokes `setValue:forKey:` on each of the collection's objects using the specified `value` and `key`. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param value The object value. |
||||
@param key The name of the property. |
||||
*/ |
||||
- (void)setValue:(nullable id)value forKey:(NSString *)key; |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
Registers a block to be called each time the collection changes. |
||||
|
||||
The block will be asynchronously called with the initial collection, and then |
||||
called again after each write transaction which changes either any of the |
||||
objects in the collection, or which objects are in the collection. |
||||
|
||||
The `change` parameter will be `nil` the first time the block is called. |
||||
For each call after that, it will contain information about |
||||
which rows in the collection were added, removed or modified. If a write transaction |
||||
did not modify any objects in this collection, the block is not called at all. |
||||
See the `RLMCollectionChange` documentation for information on how the changes |
||||
are reported and an example of updating a `UITableView`. |
||||
|
||||
If an error occurs the block will be called with `nil` for the collection |
||||
parameter and a non-`nil` error. Currently the only errors that can occur are |
||||
when opening the Realm on the background worker thread. |
||||
|
||||
At the time when the block is called, the collection object will be fully |
||||
evaluated and up-to-date, and as long as you do not perform a write transaction |
||||
on the same thread or explicitly call `-[RLMRealm refresh]`, accessing it will |
||||
never perform blocking work. |
||||
|
||||
Notifications are delivered via the standard run loop, and so can't be |
||||
delivered while the run loop is blocked by other activity. When |
||||
notifications can't be delivered instantly, multiple notifications may be |
||||
coalesced into a single notification. This can include the notification |
||||
with the initial collection. For example, the following code performs a write |
||||
transaction immediately after adding the notification block, so there is no |
||||
opportunity for the initial notification to be delivered first. As a |
||||
result, the initial notification will reflect the state of the Realm after |
||||
the write transaction. |
||||
|
||||
id<RLMCollection> collection = [Dog allObjects]; |
||||
NSLog(@"dogs.count: %zu", dogs.count); // => 0
|
||||
self.token = [collection addNotificationBlock:^(id<RLMCollection> dogs, |
||||
RLMCollectionChange *changes, |
||||
NSError *error) { |
||||
// Only fired once for the example
|
||||
NSLog(@"dogs.count: %zu", dogs.count); // => 1
|
||||
}]; |
||||
[realm transactionWithBlock:^{ |
||||
Dog *dog = [[Dog alloc] init]; |
||||
dog.name = @"Rex"; |
||||
[realm addObject:dog]; |
||||
}]; |
||||
// end of run loop execution context
|
||||
|
||||
You must retain the returned token for as long as you want updates to continue |
||||
to be sent to the block. To stop receiving updates, call `-invalidate` on the token. |
||||
|
||||
@warning This method cannot be called during a write transaction, or when the |
||||
containing Realm is read-only. |
||||
|
||||
@param block The block to be called each time the collection changes. |
||||
@return A token which must be held for as long as you want collection notifications to be delivered. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(void (^)(id<RLMCollection> __nullable collection, |
||||
RLMCollectionChange *__nullable change, |
||||
NSError *__nullable error))block __attribute__((warn_unused_result)); |
||||
|
||||
#pragma mark - Aggregating Property Values |
||||
|
||||
/**
|
||||
Returns the minimum (lowest) value of the given property among all the objects |
||||
in the collection. |
||||
|
||||
NSNumber *min = [results minOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose minimum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The minimum value of the property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable id)minOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the maximum (highest) value of the given property among all the objects |
||||
in the collection. |
||||
|
||||
NSNumber *max = [results maxOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose maximum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The maximum value of the property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable id)maxOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the sum of the values of a given property over all the objects in the collection. |
||||
|
||||
NSNumber *sum = [results sumOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose values should be summed. Only properties of |
||||
types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The sum of the given property. |
||||
*/ |
||||
- (NSNumber *)sumOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the average value of a given property over the objects in the collection. |
||||
|
||||
NSNumber *average = [results averageOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose average value should be calculated. Only |
||||
properties of types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The average value of the given property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable NSNumber *)averageOfProperty:(NSString *)property; |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
An `RLMSortDescriptor` stores a property name and a sort order for use with |
||||
`sortedResultsUsingDescriptors:`. It is similar to `NSSortDescriptor`, but supports |
||||
only the subset of functionality which can be efficiently run by Realm's query |
||||
engine. |
||||
|
||||
`RLMSortDescriptor` instances are immutable. |
||||
*/ |
||||
@interface RLMSortDescriptor : NSObject |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The key path which the sort descriptor orders results by. |
||||
*/ |
||||
@property (nonatomic, readonly) NSString *keyPath; |
||||
|
||||
/**
|
||||
Whether the descriptor sorts in ascending or descending order. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL ascending; |
||||
|
||||
#pragma mark - Methods |
||||
|
||||
/**
|
||||
Returns a new sort descriptor for the given key path and sort direction. |
||||
*/ |
||||
+ (instancetype)sortDescriptorWithKeyPath:(NSString *)keyPath ascending:(BOOL)ascending; |
||||
|
||||
/**
|
||||
Returns a copy of the receiver with the sort direction reversed. |
||||
*/ |
||||
- (instancetype)reversedSortDescriptor; |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
A `RLMCollectionChange` object encapsulates information about changes to collections |
||||
that are reported by Realm notifications. |
||||
|
||||
`RLMCollectionChange` is passed to the notification blocks registered with |
||||
`-addNotificationBlock` on `RLMArray` and `RLMResults`, and reports what rows in the |
||||
collection changed since the last time the notification block was called. |
||||
|
||||
The change information is available in two formats: a simple array of row |
||||
indices in the collection for each type of change, and an array of index paths |
||||
in a requested section suitable for passing directly to `UITableView`'s batch |
||||
update methods. A complete example of updating a `UITableView` named `tv`: |
||||
|
||||
[tv beginUpdates]; |
||||
[tv deleteRowsAtIndexPaths:[changes deletionsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic]; |
||||
[tv insertRowsAtIndexPaths:[changes insertionsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic]; |
||||
[tv reloadRowsAtIndexPaths:[changes modificationsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic]; |
||||
[tv endUpdates]; |
||||
|
||||
All of the arrays in an `RLMCollectionChange` are always sorted in ascending order. |
||||
*/ |
||||
@interface RLMCollectionChange : NSObject |
||||
/// The indices of objects in the previous version of the collection which have
|
||||
/// been removed from this one.
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *deletions; |
||||
|
||||
/// The indices in the new version of the collection which were newly inserted.
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *insertions; |
||||
|
||||
/**
|
||||
The indices in the new version of the collection which were modified. |
||||
|
||||
For `RLMResults`, this means that one or more of the properties of the object at |
||||
that index were modified (or an object linked to by that object was |
||||
modified). |
||||
|
||||
For `RLMArray`, the array itself being modified to contain a |
||||
different object at that index will also be reported as a modification. |
||||
*/ |
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *modifications; |
||||
|
||||
/// Returns the index paths of the deletion indices in the given section.
|
||||
- (NSArray<NSIndexPath *> *)deletionsInSection:(NSUInteger)section; |
||||
|
||||
/// Returns the index paths of the insertion indices in the given section.
|
||||
- (NSArray<NSIndexPath *> *)insertionsInSection:(NSUInteger)section; |
||||
|
||||
/// Returns the index paths of the modification indices in the given section.
|
||||
- (NSArray<NSIndexPath *> *)modificationsInSection:(NSUInteger)section; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,224 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
// For compatibility with Xcode 7, before extensible string enums were introduced,
|
||||
#ifdef NS_EXTENSIBLE_STRING_ENUM |
||||
#define RLM_EXTENSIBLE_STRING_ENUM NS_EXTENSIBLE_STRING_ENUM |
||||
#define RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(_, extensible_string_enum) NS_SWIFT_NAME(extensible_string_enum) |
||||
#else |
||||
#define RLM_EXTENSIBLE_STRING_ENUM |
||||
#define RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(fully_qualified, _) NS_SWIFT_NAME(fully_qualified) |
||||
#endif |
||||
|
||||
// Swift 5 considers NS_ENUM to be "open", meaning there could be values present
|
||||
// other than the defined cases (which allows adding more cases later without
|
||||
// it being a breaking change), while older versions consider it "closed".
|
||||
#ifdef NS_CLOSED_ENUM |
||||
#define RLM_CLOSED_ENUM NS_CLOSED_ENUM |
||||
#else |
||||
#define RLM_CLOSED_ENUM NS_ENUM |
||||
#endif |
||||
|
||||
#if __has_attribute(ns_error_domain) && (!defined(__cplusplus) || !__cplusplus || __cplusplus >= 201103L) |
||||
#define RLM_ERROR_ENUM(type, name, domain) \ |
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wignored-attributes\"") \
|
||||
NS_ENUM(type, __attribute__((ns_error_domain(domain))) name) \
|
||||
_Pragma("clang diagnostic pop") |
||||
#else |
||||
#define RLM_ERROR_ENUM(type, name, domain) NS_ENUM(type, name) |
||||
#endif |
||||
|
||||
|
||||
#pragma mark - Enums |
||||
|
||||
/**
|
||||
`RLMPropertyType` is an enumeration describing all property types supported in Realm models. |
||||
|
||||
For more information, see [Realm Models](https://realm.io/docs/objc/latest/#models).
|
||||
*/ |
||||
typedef RLM_CLOSED_ENUM(int32_t, RLMPropertyType) { |
||||
|
||||
#pragma mark - Primitive types |
||||
|
||||
/** Integers: `NSInteger`, `int`, `long`, `Int` (Swift) */ |
||||
RLMPropertyTypeInt = 0, |
||||
/** Booleans: `BOOL`, `bool`, `Bool` (Swift) */ |
||||
RLMPropertyTypeBool = 1, |
||||
/** Floating-point numbers: `float`, `Float` (Swift) */ |
||||
RLMPropertyTypeFloat = 5, |
||||
/** Double-precision floating-point numbers: `double`, `Double` (Swift) */ |
||||
RLMPropertyTypeDouble = 6, |
||||
|
||||
#pragma mark - Object types |
||||
|
||||
/** Strings: `NSString`, `String` (Swift) */ |
||||
RLMPropertyTypeString = 2, |
||||
/** Binary data: `NSData` */ |
||||
RLMPropertyTypeData = 3, |
||||
/**
|
||||
Any object: `id`. |
||||
|
||||
This property type is no longer supported for new models. However, old files |
||||
with any-typed properties are still supported for migration purposes. |
||||
*/ |
||||
RLMPropertyTypeAny = 9, |
||||
/** Dates: `NSDate` */ |
||||
RLMPropertyTypeDate = 4, |
||||
|
||||
#pragma mark - Linked object types |
||||
|
||||
/** Realm model objects. See [Realm Models](https://realm.io/docs/objc/latest/#models) for more information. */ |
||||
RLMPropertyTypeObject = 7, |
||||
/** Realm linking objects. See [Realm Models](https://realm.io/docs/objc/latest/#models) for more information. */ |
||||
RLMPropertyTypeLinkingObjects = 8, |
||||
}; |
||||
|
||||
/** An error domain identifying Realm-specific errors. */ |
||||
extern NSString * const RLMErrorDomain; |
||||
|
||||
/** An error domain identifying non-specific system errors. */ |
||||
extern NSString * const RLMUnknownSystemErrorDomain; |
||||
|
||||
/**
|
||||
`RLMError` is an enumeration representing all recoverable errors. It is associated with the |
||||
Realm error domain specified in `RLMErrorDomain`. |
||||
*/ |
||||
typedef RLM_ERROR_ENUM(NSInteger, RLMError, RLMErrorDomain) { |
||||
/** Denotes a general error that occurred when trying to open a Realm. */ |
||||
RLMErrorFail = 1, |
||||
|
||||
/** Denotes a file I/O error that occurred when trying to open a Realm. */ |
||||
RLMErrorFileAccess = 2, |
||||
|
||||
/**
|
||||
Denotes a file permission error that ocurred when trying to open a Realm. |
||||
|
||||
This error can occur if the user does not have permission to open or create |
||||
the specified file in the specified access mode when opening a Realm. |
||||
*/ |
||||
RLMErrorFilePermissionDenied = 3, |
||||
|
||||
/** Denotes an error where a file was to be written to disk, but another file with the same name already exists. */ |
||||
RLMErrorFileExists = 4, |
||||
|
||||
/**
|
||||
Denotes an error that occurs if a file could not be found. |
||||
|
||||
This error may occur if a Realm file could not be found on disk when trying to open a |
||||
Realm as read-only, or if the directory part of the specified path was not found when |
||||
trying to write a copy. |
||||
*/ |
||||
RLMErrorFileNotFound = 5, |
||||
|
||||
/**
|
||||
Denotes an error that occurs if a file format upgrade is required to open the file, |
||||
but upgrades were explicitly disabled. |
||||
*/ |
||||
RLMErrorFileFormatUpgradeRequired = 6, |
||||
|
||||
/**
|
||||
Denotes an error that occurs if the database file is currently open in another |
||||
process which cannot share with the current process due to an |
||||
architecture mismatch. |
||||
|
||||
This error may occur if trying to share a Realm file between an i386 (32-bit) iOS |
||||
Simulator and the Realm Browser application. In this case, please use the 64-bit |
||||
version of the iOS Simulator. |
||||
*/ |
||||
RLMErrorIncompatibleLockFile = 8, |
||||
|
||||
/** Denotes an error that occurs when there is insufficient available address space. */ |
||||
RLMErrorAddressSpaceExhausted = 9, |
||||
|
||||
/** Denotes an error that occurs if there is a schema version mismatch, so that a migration is required. */ |
||||
RLMErrorSchemaMismatch = 10, |
||||
|
||||
/** Denotes an error that occurs when attempting to open an incompatible synchronized Realm file.
|
||||
|
||||
This error occurs when the Realm file was created with an older version of Realm and an automatic migration |
||||
to the current version is not possible. When such an error occurs, the original file is moved to a backup |
||||
location, and future attempts to open the synchronized Realm will result in a new file being created. |
||||
If you wish to migrate any data from the backup Realm, you can open it using the provided Realm configuration. |
||||
*/ |
||||
RLMErrorIncompatibleSyncedFile = 11, |
||||
}; |
||||
|
||||
#pragma mark - Constants |
||||
|
||||
#pragma mark - Notification Constants |
||||
|
||||
/**
|
||||
A notification indicating that changes were made to a Realm. |
||||
*/ |
||||
typedef NSString * RLMNotification RLM_EXTENSIBLE_STRING_ENUM; |
||||
|
||||
/**
|
||||
This notification is posted by a Realm when the data in that Realm has changed. |
||||
|
||||
More specifically, this notification is posted after a Realm has been refreshed to |
||||
reflect a write transaction. This can happen when an autorefresh occurs, when |
||||
`-[RLMRealm refresh]` is called, after an implicit refresh from `-[RLMRealm beginWriteTransaction]`, |
||||
or after a local write transaction is completed. |
||||
*/ |
||||
extern RLMNotification const RLMRealmRefreshRequiredNotification |
||||
RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(RLMRealmRefreshRequiredNotification, RefreshRequired); |
||||
|
||||
/**
|
||||
This notification is posted by a Realm when a write transaction has been |
||||
committed to a Realm on a different thread for the same file. |
||||
|
||||
It is not posted if `-[RLMRealm autorefresh]` is enabled, or if the Realm is |
||||
refreshed before the notification has a chance to run. |
||||
|
||||
Realms with autorefresh disabled should normally install a handler for this |
||||
notification which calls `-[RLMRealm refresh]` after doing some work. Refreshing |
||||
the Realm is optional, but not refreshing the Realm may lead to large Realm |
||||
files. This is because Realm must keep an extra copy of the data for the stale |
||||
Realm. |
||||
*/ |
||||
extern RLMNotification const RLMRealmDidChangeNotification |
||||
RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(RLMRealmDidChangeNotification, DidChange); |
||||
|
||||
#pragma mark - Error keys |
||||
|
||||
/** Key to identify the associated backup Realm configuration in an error's `userInfo` dictionary */ |
||||
extern NSString * const RLMBackupRealmConfigurationErrorKey; |
||||
|
||||
#pragma mark - Other Constants |
||||
|
||||
/** The schema version used for uninitialized Realms */ |
||||
extern const uint64_t RLMNotVersioned; |
||||
|
||||
/** The corresponding value is the name of an exception thrown by Realm. */ |
||||
extern NSString * const RLMExceptionName; |
||||
|
||||
/** The corresponding value is a Realm file version. */ |
||||
extern NSString * const RLMRealmVersionKey; |
||||
|
||||
/** The corresponding key is the version of the underlying database engine. */ |
||||
extern NSString * const RLMRealmCoreVersionKey; |
||||
|
||||
/** The corresponding key is the Realm invalidated property name. */ |
||||
extern NSString * const RLMInvalidatedKey; |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,127 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMSchema; |
||||
@class RLMArray; |
||||
@class RLMObject; |
||||
|
||||
/**
|
||||
A block type which provides both the old and new versions of an object in the Realm. Object |
||||
properties can only be accessed using keyed subscripting. |
||||
|
||||
@see `-[RLMMigration enumerateObjects:block:]` |
||||
|
||||
@param oldObject The object from the original Realm (read-only). |
||||
@param newObject The object from the migrated Realm (read-write). |
||||
*/ |
||||
typedef void (^RLMObjectMigrationBlock)(RLMObject * __nullable oldObject, RLMObject * __nullable newObject); |
||||
|
||||
/**
|
||||
`RLMMigration` instances encapsulate information intended to facilitate a schema migration. |
||||
|
||||
A `RLMMigration` instance is passed into a user-defined `RLMMigrationBlock` block when updating |
||||
the version of a Realm. This instance provides access to the old and new database schemas, the |
||||
objects in the Realm, and provides functionality for modifying the Realm during the migration. |
||||
*/ |
||||
@interface RLMMigration : NSObject |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
Returns the old `RLMSchema`. This is the schema which describes the Realm before the |
||||
migration is applied. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSchema *oldSchema; |
||||
|
||||
/**
|
||||
Returns the new `RLMSchema`. This is the schema which describes the Realm after the |
||||
migration is applied. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSchema *newSchema; |
||||
|
||||
|
||||
#pragma mark - Altering Objects during a Migration |
||||
|
||||
/**
|
||||
Enumerates all the objects of a given type in the Realm, providing both the old and new versions |
||||
of each object. Within the block, object properties can only be accessed using keyed subscripting. |
||||
|
||||
@param className The name of the `RLMObject` class to enumerate. |
||||
|
||||
@warning All objects returned are of a type specific to the current migration and should not be cast |
||||
to `className`. Instead, treat them as `RLMObject`s and use keyed subscripting to access |
||||
properties. |
||||
*/ |
||||
- (void)enumerateObjects:(NSString *)className block:(__attribute__((noescape)) RLMObjectMigrationBlock)block; |
||||
|
||||
/**
|
||||
Creates and returns an `RLMObject` instance of type `className` in the Realm being migrated. |
||||
|
||||
The `value` argument is used to populate the object. It can be a key-value coding compliant object, an array or |
||||
dictionary returned from the methods in `NSJSONSerialization`, or an array containing one element for each managed |
||||
property. An exception will be thrown if any required properties are not present and those properties were not defined |
||||
with default values. |
||||
|
||||
When passing in an `NSArray` as the `value` argument, all properties must be present, valid and in the same order as |
||||
the properties defined in the model. |
||||
|
||||
@param className The name of the `RLMObject` class to create. |
||||
@param value The value used to populate the object. |
||||
*/ |
||||
- (RLMObject *)createObject:(NSString *)className withValue:(id)value; |
||||
|
||||
/**
|
||||
Deletes an object from a Realm during a migration. |
||||
|
||||
It is permitted to call this method from within the block passed to `-[enumerateObjects:block:]`. |
||||
|
||||
@param object Object to be deleted from the Realm being migrated. |
||||
*/ |
||||
- (void)deleteObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Deletes the data for the class with the given name. |
||||
|
||||
All objects of the given class will be deleted. If the `RLMObject` subclass no longer exists in your program, |
||||
any remaining metadata for the class will be removed from the Realm file. |
||||
|
||||
@param name The name of the `RLMObject` class to delete. |
||||
|
||||
@return A Boolean value indicating whether there was any data to delete. |
||||
*/ |
||||
- (BOOL)deleteDataForClassName:(NSString *)name; |
||||
|
||||
/**
|
||||
Renames a property of the given class from `oldName` to `newName`. |
||||
|
||||
@param className The name of the class whose property should be renamed. This class must be present |
||||
in both the old and new Realm schemas. |
||||
@param oldName The old name for the property to be renamed. There must not be a property with this name in the |
||||
class as defined by the new Realm schema. |
||||
@param newName The new name for the property to be renamed. There must not be a property with this name in the |
||||
class as defined by the old Realm schema. |
||||
*/ |
||||
- (void)renamePropertyForClass:(NSString *)className oldName:(NSString *)oldName newName:(NSString *)newName; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,650 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import <Realm/RLMObjectBase.h> |
||||
#import <Realm/RLMThreadSafeReference.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMNotificationToken; |
||||
@class RLMObjectSchema; |
||||
@class RLMPropertyChange; |
||||
@class RLMPropertyDescriptor; |
||||
@class RLMRealm; |
||||
@class RLMResults<RLMObjectType>; |
||||
|
||||
/**
|
||||
`RLMObject` is a base class for model objects representing data stored in Realms. |
||||
|
||||
Define your model classes by subclassing `RLMObject` and adding properties to be managed. |
||||
Then instantiate and use your custom subclasses instead of using the `RLMObject` class directly. |
||||
|
||||
// Dog.h
|
||||
@interface Dog : RLMObject |
||||
@property NSString *name; |
||||
@property BOOL adopted; |
||||
@end |
||||
|
||||
// Dog.m
|
||||
@implementation Dog |
||||
@end //none needed
|
||||
|
||||
### Supported property types |
||||
|
||||
- `NSString` |
||||
- `NSInteger`, `int`, `long`, `float`, and `double` |
||||
- `BOOL` or `bool` |
||||
- `NSDate` |
||||
- `NSData` |
||||
- `NSNumber<X>`, where `X` is one of `RLMInt`, `RLMFloat`, `RLMDouble` or `RLMBool`, for optional number properties |
||||
- `RLMObject` subclasses, to model many-to-one relationships. |
||||
- `RLMArray<X>`, where `X` is an `RLMObject` subclass, to model many-to-many relationships. |
||||
|
||||
### Querying |
||||
|
||||
You can initiate queries directly via the class methods: `allObjects`, `objectsWhere:`, and `objectsWithPredicate:`. |
||||
These methods allow you to easily query a custom subclass for instances of that class in the default Realm. |
||||
|
||||
To search in a Realm other than the default Realm, use the `allObjectsInRealm:`, `objectsInRealm:where:`, |
||||
and `objectsInRealm:withPredicate:` class methods. |
||||
|
||||
@see `RLMRealm` |
||||
|
||||
### Relationships |
||||
|
||||
See our [Cocoa guide](https://realm.io/docs/objc/latest#relationships) for more details.
|
||||
|
||||
### Key-Value Observing |
||||
|
||||
All `RLMObject` properties (including properties you create in subclasses) are |
||||
[Key-Value Observing compliant](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html),
|
||||
except for `realm` and `objectSchema`. |
||||
|
||||
Keep the following tips in mind when observing Realm objects: |
||||
|
||||
1. Unlike `NSMutableArray` properties, `RLMArray` properties do not require |
||||
using the proxy object returned from `-mutableArrayValueForKey:`, or defining |
||||
KVC mutation methods on the containing class. You can simply call methods on |
||||
the `RLMArray` directly; any changes will be automatically observed by the containing |
||||
object. |
||||
2. Unmanaged `RLMObject` instances cannot be added to a Realm while they have any |
||||
observed properties. |
||||
3. Modifying managed `RLMObject`s within `-observeValueForKeyPath:ofObject:change:context:` |
||||
is not recommended. Properties may change even when the Realm is not in a write |
||||
transaction (for example, when `-[RLMRealm refresh]` is called after changes |
||||
are made on a different thread), and notifications sent prior to the change |
||||
being applied (when `NSKeyValueObservingOptionPrior` is used) may be sent at |
||||
times when you *cannot* begin a write transaction. |
||||
*/ |
||||
|
||||
@interface RLMObject : RLMObjectBase <RLMThreadConfined> |
||||
|
||||
#pragma mark - Creating & Initializing Objects |
||||
|
||||
/**
|
||||
Creates an unmanaged instance of a Realm object. |
||||
|
||||
Call `addObject:` on an `RLMRealm` instance to add an unmanaged object into that Realm. |
||||
|
||||
@see `[RLMRealm addObject:]` |
||||
*/ |
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER; |
||||
|
||||
|
||||
/**
|
||||
Creates an unmanaged instance of a Realm object. |
||||
|
||||
Pass in an `NSArray` or `NSDictionary` instance to set the values of the object's properties. |
||||
|
||||
Call `addObject:` on an `RLMRealm` instance to add an unmanaged object into that Realm. |
||||
|
||||
@see `[RLMRealm addObject:]` |
||||
*/ |
||||
- (instancetype)initWithValue:(id)value NS_DESIGNATED_INITIALIZER; |
||||
|
||||
|
||||
/**
|
||||
Returns the class name for a Realm object subclass. |
||||
|
||||
@warning Do not override. Realm relies on this method returning the exact class |
||||
name. |
||||
|
||||
@return The class name for the model class. |
||||
*/ |
||||
+ (NSString *)className; |
||||
|
||||
/**
|
||||
Creates an instance of a Realm object with a given value, and adds it to the default Realm. |
||||
|
||||
If nested objects are included in the argument, `createInDefaultRealmWithValue:` will be recursively called |
||||
on them. |
||||
|
||||
The `value` argument can be a key-value coding compliant object, an array or dictionary returned from the methods in |
||||
`NSJSONSerialization`, or an array containing one element for each managed property. |
||||
|
||||
An exception will be thrown if any required properties are not present and those properties |
||||
were not defined with default values. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues` |
||||
*/ |
||||
+ (instancetype)createInDefaultRealmWithValue:(id)value; |
||||
|
||||
/**
|
||||
Creates an instance of a Realm object with a given value, and adds it to the specified Realm. |
||||
|
||||
If nested objects are included in the argument, `createInRealm:withValue:` will be recursively called |
||||
on them. |
||||
|
||||
The `value` argument can be a key-value coding compliant object, an array or dictionary returned from the methods in |
||||
`NSJSONSerialization`, or an array containing one element for each managed property. |
||||
|
||||
An exception will be thrown if any required properties are not present and those properties |
||||
were not defined with default values. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param realm The Realm which should manage the newly-created object. |
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues` |
||||
*/ |
||||
+ (instancetype)createInRealm:(RLMRealm *)realm withValue:(id)value; |
||||
|
||||
/**
|
||||
Creates or updates a Realm object within the default Realm. |
||||
|
||||
This method may only be called on Realm object types with a primary key defined. If there is already |
||||
an object with the same primary key value in the default Realm, its values are updated and the object |
||||
is returned. Otherwise, this method creates and populates a new instance of the object in the default Realm. |
||||
|
||||
If nested objects are included in the argument, `createOrUpdateInDefaultRealmWithValue:` will be |
||||
recursively called on them if they have primary keys, `createInDefaultRealmWithValue:` if they do not. |
||||
|
||||
The `value` argument is used to populate the object. It can be a Realm object, a key-value coding |
||||
compliant object, an array or dictionary returned from the methods in `NSJSONSerialization`, or an |
||||
array containing one element for each managed property. |
||||
|
||||
If the object is being created, an exception will be thrown if any required properties |
||||
are not present and those properties were not defined with default values. |
||||
|
||||
If the `value` argument is a Realm object already managed by the default Realm, the |
||||
argument's type is the same as the receiver, and the objects have identical values for |
||||
their managed properties, this method does nothing. |
||||
|
||||
If the object is being updated, each property defined in its schema will be set by copying from |
||||
`value` using key-value coding. If the `value` argument does not respond to `valueForKey:` for a |
||||
given property name (or getter name, if defined), that value will remain untouched. |
||||
Nullable properties on the object can be set to nil by using `NSNull` as the updated value. |
||||
Each property is set even if the existing value is the same as the new value being set, and |
||||
notifications will report them all being changed. See `createOrUpdateModifiedInDefaultRealmWithValue:` |
||||
for a version of this function which only sets the values which have changed. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues`, `primaryKey` |
||||
*/ |
||||
+ (instancetype)createOrUpdateInDefaultRealmWithValue:(id)value; |
||||
|
||||
/**
|
||||
Creates or updates a Realm object within the default Realm. |
||||
|
||||
This method may only be called on Realm object types with a primary key defined. If there is already |
||||
an object with the same primary key value in the default Realm, its values are updated and the object |
||||
is returned. Otherwise, this method creates and populates a new instance of the object in the default Realm. |
||||
|
||||
If nested objects are included in the argument, `createOrUpdateModifiedInDefaultRealmWithValue:` will be |
||||
recursively called on them if they have primary keys, `createInDefaultRealmWithValue:` if they do not. |
||||
|
||||
The `value` argument is used to populate the object. It can be a Realm object, a key-value coding |
||||
compliant object, an array or dictionary returned from the methods in `NSJSONSerialization`, or an |
||||
array containing one element for each managed property. |
||||
|
||||
If the object is being created, an exception will be thrown if any required properties |
||||
are not present and those properties were not defined with default values. |
||||
|
||||
If the `value` argument is a Realm object already managed by the default Realm, the |
||||
argument's type is the same as the receiver, and the objects have identical values for |
||||
their managed properties, this method does nothing. |
||||
|
||||
If the object is being updated, each property defined in its schema will be set by copying from |
||||
`value` using key-value coding. If the `value` argument does not respond to `valueForKey:` for a |
||||
given property name (or getter name, if defined), that value will remain untouched. |
||||
Nullable properties on the object can be set to nil by using `NSNull` as the updated value. |
||||
Unlike `createOrUpdateInDefaultRealmWithValue:`, only properties which have changed in value are |
||||
set, and any change notifications produced by this call will report only which properies have |
||||
actually changed. |
||||
|
||||
Checking which properties have changed imposes a small amount of overhead, and so this method |
||||
may be slower when all or nearly all of the properties being set have changed. If most or all |
||||
of the properties being set have not changed, this method will be much faster than unconditionally |
||||
setting all of them, and will also reduce how much data has to be written to the Realm, saving |
||||
both i/o time and disk space. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues`, `primaryKey` |
||||
*/ |
||||
+ (instancetype)createOrUpdateModifiedInDefaultRealmWithValue:(id)value; |
||||
|
||||
/**
|
||||
Creates or updates an Realm object within a specified Realm. |
||||
|
||||
This method may only be called on Realm object types with a primary key defined. If there is already |
||||
an object with the same primary key value in the given Realm, its values are updated and the object |
||||
is returned. Otherwise this method creates and populates a new instance of this object in the given Realm. |
||||
|
||||
If nested objects are included in the argument, `createOrUpdateInRealm:withValue:` will be |
||||
recursively called on them if they have primary keys, `createInRealm:withValue:` if they do not. |
||||
|
||||
The `value` argument is used to populate the object. It can be a Realm object, a key-value coding |
||||
compliant object, an array or dictionary returned from the methods in `NSJSONSerialization`, or an |
||||
array containing one element for each managed property. |
||||
|
||||
If the object is being created, an exception will be thrown if any required properties |
||||
are not present and those properties were not defined with default values. |
||||
|
||||
If the `value` argument is a Realm object already managed by the given Realm, the |
||||
argument's type is the same as the receiver, and the objects have identical values for |
||||
their managed properties, this method does nothing. |
||||
|
||||
If the object is being updated, each property defined in its schema will be set by copying from |
||||
`value` using key-value coding. If the `value` argument does not respond to `valueForKey:` for a |
||||
given property name (or getter name, if defined), that value will remain untouched. |
||||
Nullable properties on the object can be set to nil by using `NSNull` as the updated value. |
||||
Each property is set even if the existing value is the same as the new value being set, and |
||||
notifications will report them all being changed. See `createOrUpdateModifiedInRealm:withValue:` |
||||
for a version of this function which only sets the values which have changed. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param realm The Realm which should own the object. |
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues`, `primaryKey` |
||||
*/ |
||||
+ (instancetype)createOrUpdateInRealm:(RLMRealm *)realm withValue:(id)value; |
||||
|
||||
/**
|
||||
Creates or updates an Realm object within a specified Realm. |
||||
|
||||
This method may only be called on Realm object types with a primary key defined. If there is already |
||||
an object with the same primary key value in the given Realm, its values are updated and the object |
||||
is returned. Otherwise this method creates and populates a new instance of this object in the given Realm. |
||||
|
||||
If nested objects are included in the argument, `createOrUpdateInRealm:withValue:` will be |
||||
recursively called on them if they have primary keys, `createInRealm:withValue:` if they do not. |
||||
|
||||
The `value` argument is used to populate the object. It can be a Realm object, a key-value coding |
||||
compliant object, an array or dictionary returned from the methods in `NSJSONSerialization`, or an |
||||
array containing one element for each managed property. |
||||
|
||||
If the object is being created, an exception will be thrown if any required properties |
||||
are not present and those properties were not defined with default values. |
||||
|
||||
If the `value` argument is a Realm object already managed by the given Realm, the |
||||
argument's type is the same as the receiver, and the objects have identical values for |
||||
their managed properties, this method does nothing. |
||||
|
||||
If the object is being updated, each property defined in its schema will be set by copying from |
||||
`value` using key-value coding. If the `value` argument does not respond to `valueForKey:` for a |
||||
given property name (or getter name, if defined), that value will remain untouched. |
||||
Nullable properties on the object can be set to nil by using `NSNull` as the updated value. |
||||
Unlike `createOrUpdateInRealm:withValue:`, only properties which have changed in value are |
||||
set, and any change notifications produced by this call will report only which properies have |
||||
actually changed. |
||||
|
||||
Checking which properties have changed imposes a small amount of overhead, and so this method |
||||
may be slower when all or nearly all of the properties being set have changed. If most or all |
||||
of the properties being set have not changed, this method will be much faster than unconditionally |
||||
setting all of them, and will also reduce how much data has to be written to the Realm, saving |
||||
both i/o time and disk space. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param realm The Realm which should own the object. |
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues`, `primaryKey` |
||||
*/ |
||||
+ (instancetype)createOrUpdateModifiedInRealm:(RLMRealm *)realm withValue:(id)value; |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The Realm which manages the object, or `nil` if the object is unmanaged. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) RLMRealm *realm; |
||||
|
||||
/**
|
||||
The object schema which lists the managed properties for the object. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMObjectSchema *objectSchema; |
||||
|
||||
/**
|
||||
Indicates if the object can no longer be accessed because it is now invalid. |
||||
|
||||
An object can no longer be accessed if the object has been deleted from the Realm that manages it, or |
||||
if `invalidate` is called on that Realm. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
|
||||
#pragma mark - Customizing your Objects |
||||
|
||||
/**
|
||||
Returns an array of property names for properties which should be indexed. |
||||
|
||||
Only string, integer, boolean, and `NSDate` properties are supported. |
||||
|
||||
@return An array of property names. |
||||
*/ |
||||
+ (NSArray<NSString *> *)indexedProperties; |
||||
|
||||
/**
|
||||
Override this method to specify the default values to be used for each property. |
||||
|
||||
@return A dictionary mapping property names to their default values. |
||||
*/ |
||||
+ (nullable NSDictionary *)defaultPropertyValues; |
||||
|
||||
/**
|
||||
Override this method to specify the name of a property to be used as the primary key. |
||||
|
||||
Only properties of types `RLMPropertyTypeString` and `RLMPropertyTypeInt` can be designated as the primary key. |
||||
Primary key properties enforce uniqueness for each value whenever the property is set, which incurs minor overhead. |
||||
Indexes are created automatically for primary key properties. |
||||
|
||||
@return The name of the property designated as the primary key. |
||||
*/ |
||||
+ (nullable NSString *)primaryKey; |
||||
|
||||
/**
|
||||
Override this method to specify the names of properties to ignore. These properties will not be managed by the Realm |
||||
that manages the object. |
||||
|
||||
@return An array of property names to ignore. |
||||
*/ |
||||
+ (nullable NSArray<NSString *> *)ignoredProperties; |
||||
|
||||
/**
|
||||
Override this method to specify the names of properties that are non-optional (i.e. cannot be assigned a `nil` value). |
||||
|
||||
By default, all properties of a type whose values can be set to `nil` are considered optional properties. |
||||
To require that an object in a Realm always store a non-`nil` value for a property, |
||||
add the name of the property to the array returned from this method. |
||||
|
||||
Properties of `RLMObject` type cannot be non-optional. Array and `NSNumber` properties |
||||
can be non-optional, but there is no reason to do so: arrays do not support storing nil, and |
||||
if you want a non-optional number you should instead use the primitive type. |
||||
|
||||
@return An array of property names that are required. |
||||
*/ |
||||
+ (NSArray<NSString *> *)requiredProperties; |
||||
|
||||
/**
|
||||
Override this method to provide information related to properties containing linking objects. |
||||
|
||||
Each property of type `RLMLinkingObjects` must have a key in the dictionary returned by this method consisting |
||||
of the property name. The corresponding value must be an instance of `RLMPropertyDescriptor` that describes the class |
||||
and property that the property is linked to. |
||||
|
||||
return @{ @"owners": [RLMPropertyDescriptor descriptorWithClass:Owner.class propertyName:@"dogs"] }; |
||||
|
||||
@return A dictionary mapping property names to `RLMPropertyDescriptor` instances. |
||||
*/ |
||||
+ (NSDictionary<NSString *, RLMPropertyDescriptor *> *)linkingObjectsProperties; |
||||
|
||||
|
||||
#pragma mark - Getting & Querying Objects from the Default Realm |
||||
|
||||
/**
|
||||
Returns all objects of this object type from the default Realm. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the default Realm. |
||||
*/ |
||||
+ (RLMResults *)allObjects; |
||||
|
||||
/**
|
||||
Returns all objects of this object type matching the given predicate from the default Realm. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the default Realm that match the given predicate. |
||||
*/ |
||||
+ (RLMResults *)objectsWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
+ (RLMResults<__kindof RLMObject *> *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
|
||||
/**
|
||||
Returns all objects of this object type matching the given predicate from the default Realm. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the default Realm that match the given predicate. |
||||
*/ |
||||
+ (RLMResults *)objectsWithPredicate:(nullable NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Retrieves the single instance of this object type with the given primary key from the default Realm. |
||||
|
||||
Returns the object from the default Realm which has the given primary key, or |
||||
`nil` if the object does not exist. This is slightly faster than the otherwise |
||||
equivalent `[[SubclassName objectsWhere:@"primaryKeyPropertyName = %@", key] firstObject]`. |
||||
|
||||
This method requires that `primaryKey` be overridden on the receiving subclass. |
||||
|
||||
@return An object of this object type, or `nil` if an object with the given primary key does not exist. |
||||
@see `-primaryKey` |
||||
*/ |
||||
+ (nullable instancetype)objectForPrimaryKey:(nullable id)primaryKey NS_SWIFT_NAME(object(forPrimaryKey:)); |
||||
|
||||
|
||||
#pragma mark - Querying Specific Realms |
||||
|
||||
/**
|
||||
Returns all objects of this object type from the specified Realm. |
||||
|
||||
@param realm The Realm to query. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the specified Realm. |
||||
*/ |
||||
+ (RLMResults *)allObjectsInRealm:(RLMRealm *)realm; |
||||
|
||||
/**
|
||||
Returns all objects of this object type matching the given predicate from the specified Realm. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
@param realm The Realm to query. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the specified Realm that match the given predicate. |
||||
*/ |
||||
+ (RLMResults *)objectsInRealm:(RLMRealm *)realm where:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
+ (RLMResults<__kindof RLMObject *> *)objectsInRealm:(RLMRealm *)realm where:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns all objects of this object type matching the given predicate from the specified Realm. |
||||
|
||||
@param predicate A predicate to use to filter the elements. |
||||
@param realm The Realm to query. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the specified Realm that match the given predicate. |
||||
*/ |
||||
+ (RLMResults *)objectsInRealm:(RLMRealm *)realm withPredicate:(nullable NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Retrieves the single instance of this object type with the given primary key from the specified Realm. |
||||
|
||||
Returns the object from the specified Realm which has the given primary key, or |
||||
`nil` if the object does not exist. This is slightly faster than the otherwise |
||||
equivalent `[[SubclassName objectsInRealm:realm where:@"primaryKeyPropertyName = %@", key] firstObject]`. |
||||
|
||||
This method requires that `primaryKey` be overridden on the receiving subclass. |
||||
|
||||
@return An object of this object type, or `nil` if an object with the given primary key does not exist. |
||||
@see `-primaryKey` |
||||
*/ |
||||
+ (nullable instancetype)objectInRealm:(RLMRealm *)realm forPrimaryKey:(nullable id)primaryKey NS_SWIFT_NAME(object(in:forPrimaryKey:)); |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
A callback block for `RLMObject` notifications. |
||||
|
||||
If the object is deleted from the managing Realm, the block is called with |
||||
`deleted` set to `YES` and the other two arguments are `nil`. The block will |
||||
never be called again after this. |
||||
|
||||
If the object is modified, the block will be called with `deleted` set to |
||||
`NO`, a `nil` error, and an array of `RLMPropertyChange` objects which |
||||
indicate which properties of the objects were modified. |
||||
|
||||
If an error occurs, `deleted` will be `NO`, `changes` will be `nil`, and |
||||
`error` will include information about the error. The block will never be |
||||
called again after an error occurs. |
||||
*/ |
||||
typedef void (^RLMObjectChangeBlock)(BOOL deleted, |
||||
NSArray<RLMPropertyChange *> *_Nullable changes, |
||||
NSError *_Nullable error); |
||||
|
||||
/**
|
||||
Registers a block to be called each time the object changes. |
||||
|
||||
The block will be asynchronously called after each write transaction which |
||||
deletes the object or modifies any of the managed properties of the object, |
||||
including self-assignments that set a property to its existing value. |
||||
|
||||
For write transactions performed on different threads or in differen |
||||
processes, the block will be called when the managing Realm is |
||||
(auto)refreshed to a version including the changes, while for local write |
||||
transactions it will be called at some point in the future after the write |
||||
transaction is committed. |
||||
|
||||
Notifications are delivered via the standard run loop, and so can't be |
||||
delivered while the run loop is blocked by other activity. When notifications |
||||
can't be delivered instantly, multiple notifications may be coalesced into a |
||||
single notification. |
||||
|
||||
Unlike with `RLMArray` and `RLMResults`, there is no "initial" callback made |
||||
after you add a new notification block. |
||||
|
||||
Only objects which are managed by a Realm can be observed in this way. You |
||||
must retain the returned token for as long as you want updates to be sent to |
||||
the block. To stop receiving updates, call `-invalidate` on the token. |
||||
|
||||
It is safe to capture a strong reference to the observed object within the |
||||
callback block. There is no retain cycle due to that the callback is retained |
||||
by the returned token and not by the object itself. |
||||
|
||||
@warning This method cannot be called during a write transaction, when the |
||||
containing Realm is read-only, or on an unmanaged object. |
||||
|
||||
@param block The block to be called whenever a change occurs. |
||||
@return A token which must be held for as long as you want updates to be delivered. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(RLMObjectChangeBlock)block; |
||||
|
||||
#pragma mark - Other Instance Methods |
||||
|
||||
/**
|
||||
Returns YES if another Realm object instance points to the same object as the receiver in the Realm managing |
||||
the receiver. |
||||
|
||||
For object types with a primary, key, `isEqual:` is overridden to use the same logic as this |
||||
method (along with a corresponding implementation for `hash`). |
||||
|
||||
@param object The object to compare the receiver to. |
||||
|
||||
@return Whether the object represents the same object as the receiver. |
||||
*/ |
||||
- (BOOL)isEqualToObject:(RLMObject *)object; |
||||
|
||||
#pragma mark - Dynamic Accessors |
||||
|
||||
/// :nodoc:
|
||||
- (nullable id)objectForKeyedSubscript:(NSString *)key; |
||||
|
||||
/// :nodoc:
|
||||
- (void)setObject:(nullable id)obj forKeyedSubscript:(NSString *)key; |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
Information about a specific property which changed in an `RLMObject` change notification. |
||||
*/ |
||||
@interface RLMPropertyChange : NSObject |
||||
|
||||
/**
|
||||
The name of the property which changed. |
||||
*/ |
||||
@property (nonatomic, readonly, strong) NSString *name; |
||||
|
||||
/**
|
||||
The value of the property before the change occurred. This will always be `nil` |
||||
if the change happened on the same thread as the notification and for `RLMArray` |
||||
properties. |
||||
|
||||
For object properties this will give the object which was previously linked to, |
||||
but that object will have its new values and not the values it had before the |
||||
changes. This means that `previousValue` may be a deleted object, and you will |
||||
need to check `invalidated` before accessing any of its properties. |
||||
*/ |
||||
@property (nonatomic, readonly, strong, nullable) id previousValue; |
||||
|
||||
/**
|
||||
The value of the property after the change occurred. This will always be `nil` |
||||
for `RLMArray` properties. |
||||
*/ |
||||
@property (nonatomic, readonly, strong, nullable) id value; |
||||
@end |
||||
|
||||
#pragma mark - RLMArray Property Declaration |
||||
|
||||
/**
|
||||
Properties on `RLMObject`s of type `RLMArray` must have an associated type. A type is associated |
||||
with an `RLMArray` property by defining a protocol for the object type that the array should contain. |
||||
To define the protocol for an object, you can use the macro RLM_ARRAY_TYPE: |
||||
|
||||
RLM_ARRAY_TYPE(ObjectType) |
||||
... |
||||
@property RLMArray<ObjectType *><ObjectType> *arrayOfObjectTypes; |
||||
*/ |
||||
#define RLM_ARRAY_TYPE(RLM_OBJECT_SUBCLASS)\ |
||||
@protocol RLM_OBJECT_SUBCLASS <NSObject> \
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,44 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMRealm; |
||||
@class RLMSchema; |
||||
@class RLMObjectSchema; |
||||
|
||||
/// :nodoc:
|
||||
@interface RLMObjectBase : NSObject |
||||
|
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER; |
||||
|
||||
+ (NSString *)className; |
||||
|
||||
// Returns whether the class is included in the default set of classes managed by a Realm.
|
||||
+ (BOOL)shouldIncludeInDefaultSchema; |
||||
|
||||
+ (nullable NSString *)_realmObjectName; |
||||
+ (nullable NSDictionary<NSString *, NSString *> *)_realmColumnNames; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,82 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMObject.h> |
||||
|
||||
@class RLMObjectSchema, RLMRealm; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
Returns the Realm that manages the object, if one exists. |
||||
|
||||
@warning This function is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is |
||||
recommended to retrieve the Realm that manages the object via `RLMObject`. |
||||
|
||||
@param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. |
||||
|
||||
@return The Realm which manages this object. Returns `nil `for unmanaged objects. |
||||
*/ |
||||
FOUNDATION_EXTERN RLMRealm * _Nullable RLMObjectBaseRealm(RLMObjectBase * _Nullable object); |
||||
|
||||
/**
|
||||
Returns an `RLMObjectSchema` which describes the managed properties of the object. |
||||
|
||||
@warning This function is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is |
||||
recommended to retrieve `objectSchema` via `RLMObject`. |
||||
|
||||
@param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. |
||||
|
||||
@return The object schema which lists the managed properties for the object. |
||||
*/ |
||||
FOUNDATION_EXTERN RLMObjectSchema * _Nullable RLMObjectBaseObjectSchema(RLMObjectBase * _Nullable object); |
||||
|
||||
/**
|
||||
Returns the object corresponding to a key value. |
||||
|
||||
@warning This function is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is |
||||
recommended to retrieve key values via `RLMObject`. |
||||
|
||||
@warning Will throw an `NSUndefinedKeyException` if `key` is not present on the object. |
||||
|
||||
@param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. |
||||
@param key The name of the property. |
||||
|
||||
@return The object for the property requested. |
||||
*/ |
||||
FOUNDATION_EXTERN id _Nullable RLMObjectBaseObjectForKeyedSubscript(RLMObjectBase * _Nullable object, NSString *key); |
||||
|
||||
/**
|
||||
Sets a value for a key on the object. |
||||
|
||||
@warning This function is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is |
||||
recommended to set key values via `RLMObject`. |
||||
|
||||
@warning Will throw an `NSUndefinedKeyException` if `key` is not present on the object. |
||||
|
||||
@param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. |
||||
@param key The name of the property. |
||||
@param obj The object to set as the value of the key. |
||||
*/ |
||||
FOUNDATION_EXTERN void RLMObjectBaseSetObjectForKeyedSubscript(RLMObjectBase * _Nullable object, NSString *key, id _Nullable obj); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,72 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMProperty; |
||||
|
||||
/**
|
||||
This class represents Realm model object schemas. |
||||
|
||||
When using Realm, `RLMObjectSchema` instances allow performing migrations and |
||||
introspecting the database's schema. |
||||
|
||||
Object schemas map to tables in the core database. |
||||
*/ |
||||
@interface RLMObjectSchema : NSObject<NSCopying> |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
An array of `RLMProperty` instances representing the managed properties of a class described by the schema. |
||||
|
||||
@see `RLMProperty` |
||||
*/ |
||||
@property (nonatomic, readonly, copy) NSArray<RLMProperty *> *properties; |
||||
|
||||
/**
|
||||
The name of the class the schema describes. |
||||
*/ |
||||
@property (nonatomic, readonly) NSString *className; |
||||
|
||||
/**
|
||||
The property which serves as the primary key for the class the schema describes, if any. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) RLMProperty *primaryKeyProperty; |
||||
|
||||
#pragma mark - Methods |
||||
|
||||
/**
|
||||
Retrieves an `RLMProperty` object by the property name. |
||||
|
||||
@param propertyName The property's name. |
||||
|
||||
@return An `RLMProperty` object, or `nil` if there is no property with the given name. |
||||
*/ |
||||
- (nullable RLMProperty *)objectForKeyedSubscript:(NSString *)propertyName; |
||||
|
||||
/**
|
||||
Returns whether two `RLMObjectSchema` instances are equal. |
||||
*/ |
||||
- (BOOL)isEqualToObjectSchema:(RLMObjectSchema *)objectSchema; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,22 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if TARGET_OS_IPHONE |
||||
#error Attempting to use Realm's OSX framework in an iOS project. |
||||
#endif |
||||
|
||||
@ -0,0 +1,126 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMConstants.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/// :nodoc:
|
||||
@protocol RLMInt @end |
||||
/// :nodoc:
|
||||
@protocol RLMBool @end |
||||
/// :nodoc:
|
||||
@protocol RLMDouble @end |
||||
/// :nodoc:
|
||||
@protocol RLMFloat @end |
||||
/// :nodoc:
|
||||
@protocol RLMString @end |
||||
/// :nodoc:
|
||||
@protocol RLMDate @end |
||||
/// :nodoc:
|
||||
@protocol RLMData @end |
||||
|
||||
/// :nodoc:
|
||||
@interface NSNumber ()<RLMInt, RLMBool, RLMDouble, RLMFloat> |
||||
@end |
||||
|
||||
/**
|
||||
`RLMProperty` instances represent properties managed by a Realm in the context |
||||
of an object schema. Such properties may be persisted to a Realm file or |
||||
computed from other data from the Realm. |
||||
|
||||
When using Realm, `RLMProperty` instances allow performing migrations and |
||||
introspecting the database's schema. |
||||
|
||||
These property instances map to columns in the core database. |
||||
*/ |
||||
@interface RLMProperty : NSObject |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The name of the property. |
||||
*/ |
||||
@property (nonatomic, readonly) NSString *name; |
||||
|
||||
/**
|
||||
The type of the property. |
||||
|
||||
@see `RLMPropertyType` |
||||
*/ |
||||
@property (nonatomic, readonly) RLMPropertyType type; |
||||
|
||||
/**
|
||||
Indicates whether this property is indexed. |
||||
|
||||
@see `RLMObject` |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL indexed; |
||||
|
||||
/**
|
||||
For `RLMObject` and `RLMArray` properties, the name of the class of object stored in the property. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *objectClassName; |
||||
|
||||
/**
|
||||
For linking objects properties, the property name of the property the linking objects property is linked to. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *linkOriginPropertyName; |
||||
|
||||
/**
|
||||
Indicates whether this property is optional. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL optional; |
||||
|
||||
/**
|
||||
Indicates whether this property is an array. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL array; |
||||
|
||||
#pragma mark - Methods |
||||
|
||||
/**
|
||||
Returns whether a given property object is equal to the receiver. |
||||
*/ |
||||
- (BOOL)isEqualToProperty:(RLMProperty *)property; |
||||
|
||||
@end |
||||
|
||||
|
||||
/**
|
||||
An `RLMPropertyDescriptor` instance represents a specific property on a given class. |
||||
*/ |
||||
@interface RLMPropertyDescriptor : NSObject |
||||
|
||||
/**
|
||||
Creates and returns a property descriptor. |
||||
|
||||
@param objectClass The class of this property descriptor. |
||||
@param propertyName The name of this property descriptor. |
||||
*/ |
||||
+ (instancetype)descriptorWithClass:(Class)objectClass propertyName:(NSString *)propertyName; |
||||
|
||||
/// The class of the property.
|
||||
@property (nonatomic, readonly) Class objectClass; |
||||
|
||||
/// The name of the property.
|
||||
@property (nonatomic, readonly) NSString *propertyName; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,56 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2017 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import "RLMRealm.h" |
||||
|
||||
@class RLMResults, RLMSyncSession; |
||||
|
||||
/**
|
||||
A callback used to vend the results of a partial sync fetch. |
||||
*/ |
||||
typedef void(^RLMPartialSyncFetchCallback)(RLMResults * _Nullable results, NSError * _Nullable error); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
///
|
||||
@interface RLMRealm (Sync) |
||||
|
||||
/**
|
||||
If the Realm is a partially synchronized Realm, fetch and synchronize the objects |
||||
of a given object type that match the given query (in string format). |
||||
|
||||
The results will be returned asynchronously in the callback. |
||||
Use `-[RLMResults addNotificationBlock:]` to be notified to changes to the set of |
||||
synchronized objects. |
||||
|
||||
@warning Partial synchronization is a tech preview. Its APIs are subject to change. |
||||
*/ |
||||
- (void)subscribeToObjects:(Class)type where:(NSString *)query callback:(RLMPartialSyncFetchCallback)callback |
||||
__deprecated_msg("Use -[RLMResults subscribe]"); |
||||
|
||||
/**
|
||||
Get the RLMSyncSession used by this Realm. Will be nil if this is not a |
||||
synchronized Realm. |
||||
*/ |
||||
@property (nonatomic, nullable, readonly) RLMSyncSession *syncSession; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,736 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "RLMConstants.h" |
||||
|
||||
@class RLMRealmConfiguration, RLMRealm, RLMObject, RLMSchema, RLMMigration, RLMNotificationToken, RLMThreadSafeReference; |
||||
struct RLMRealmPrivileges; |
||||
struct RLMClassPrivileges; |
||||
struct RLMObjectPrivileges; |
||||
|
||||
/**
|
||||
A callback block for opening Realms asynchronously. |
||||
|
||||
Returns the Realm if the open was successful, or an error otherwise. |
||||
*/ |
||||
typedef void(^RLMAsyncOpenRealmCallback)(RLMRealm * _Nullable realm, NSError * _Nullable error); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
An `RLMRealm` instance (also referred to as "a Realm") represents a Realm |
||||
database. |
||||
|
||||
Realms can either be stored on disk (see `+[RLMRealm realmWithURL:]`) or in |
||||
memory (see `RLMRealmConfiguration`). |
||||
|
||||
`RLMRealm` instances are cached internally, and constructing equivalent `RLMRealm` |
||||
objects (for example, by using the same path or identifier) multiple times on a single thread |
||||
within a single iteration of the run loop will normally return the same |
||||
`RLMRealm` object. |
||||
|
||||
If you specifically want to ensure an `RLMRealm` instance is |
||||
destroyed (for example, if you wish to open a Realm, check some property, and |
||||
then possibly delete the Realm file and re-open it), place the code which uses |
||||
the Realm within an `@autoreleasepool {}` and ensure you have no other |
||||
strong references to it. |
||||
|
||||
@warning `RLMRealm` instances are not thread safe and cannot be shared across |
||||
threads or dispatch queues. Trying to do so will cause an exception to be thrown. |
||||
You must call this method on each thread you want |
||||
to interact with the Realm on. For dispatch queues, this means that you must |
||||
call it in each block which is dispatched, as a queue is not guaranteed to run |
||||
all of its blocks on the same thread. |
||||
*/ |
||||
|
||||
@interface RLMRealm : NSObject |
||||
|
||||
#pragma mark - Creating & Initializing a Realm |
||||
|
||||
/**
|
||||
Obtains an instance of the default Realm. |
||||
|
||||
The default Realm is used by the `RLMObject` class methods |
||||
which do not take an `RLMRealm` parameter, but is otherwise not special. The |
||||
default Realm is persisted as *default.realm* under the *Documents* directory of |
||||
your Application on iOS, and in your application's *Application Support* |
||||
directory on OS X. |
||||
|
||||
The default Realm is created using the default `RLMRealmConfiguration`, which |
||||
can be changed via `+[RLMRealmConfiguration setDefaultConfiguration:]`. |
||||
|
||||
@return The default `RLMRealm` instance for the current thread. |
||||
*/ |
||||
+ (instancetype)defaultRealm; |
||||
|
||||
/**
|
||||
Obtains an `RLMRealm` instance with the given configuration. |
||||
|
||||
@param configuration A configuration object to use when creating the Realm. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return An `RLMRealm` instance. |
||||
*/ |
||||
+ (nullable instancetype)realmWithConfiguration:(RLMRealmConfiguration *)configuration error:(NSError **)error; |
||||
|
||||
/**
|
||||
Obtains an `RLMRealm` instance persisted at a specified file URL. |
||||
|
||||
@param fileURL The local URL of the file the Realm should be saved at. |
||||
|
||||
@return An `RLMRealm` instance. |
||||
*/ |
||||
+ (instancetype)realmWithURL:(NSURL *)fileURL; |
||||
|
||||
/**
|
||||
Asynchronously open a Realm and deliver it to a block on the given queue. |
||||
|
||||
Opening a Realm asynchronously will perform all work needed to get the Realm to |
||||
a usable state (such as running potentially time-consuming migrations) on a |
||||
background thread before dispatching to the given queue. In addition, |
||||
synchronized Realms wait for all remote content available at the time the |
||||
operation began to be downloaded and available locally. |
||||
|
||||
@param configuration A configuration object to use when opening the Realm. |
||||
@param callbackQueue The dispatch queue on which the callback should be run. |
||||
@param callback A callback block. If the Realm was successfully opened, |
||||
it will be passed in as an argument. |
||||
Otherwise, an `NSError` describing what went wrong will be |
||||
passed to the block instead. |
||||
|
||||
@note The returned Realm is confined to the thread on which it was created. |
||||
Because GCD does not guarantee that queues will always use the same |
||||
thread, accessing the returned Realm outside the callback block (even if |
||||
accessed from `callbackQueue`) is unsafe. |
||||
*/ |
||||
+ (void)asyncOpenWithConfiguration:(RLMRealmConfiguration *)configuration |
||||
callbackQueue:(dispatch_queue_t)callbackQueue |
||||
callback:(RLMAsyncOpenRealmCallback)callback; |
||||
|
||||
/**
|
||||
The `RLMSchema` used by the Realm. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSchema *schema; |
||||
|
||||
/**
|
||||
Indicates if the Realm is currently engaged in a write transaction. |
||||
|
||||
@warning Do not simply check this property and then start a write transaction whenever an object needs to be |
||||
created, updated, or removed. Doing so might cause a large number of write transactions to be created, |
||||
degrading performance. Instead, always prefer performing multiple updates during a single transaction. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL inWriteTransaction; |
||||
|
||||
/**
|
||||
The `RLMRealmConfiguration` object that was used to create this `RLMRealm` instance. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMRealmConfiguration *configuration; |
||||
|
||||
/**
|
||||
Indicates if this Realm contains any objects. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL isEmpty; |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
The type of a block to run whenever the data within the Realm is modified. |
||||
|
||||
@see `-[RLMRealm addNotificationBlock:]` |
||||
*/ |
||||
typedef void (^RLMNotificationBlock)(RLMNotification notification, RLMRealm *realm); |
||||
|
||||
#pragma mark - Receiving Notification when a Realm Changes |
||||
|
||||
/**
|
||||
Adds a notification handler for changes in this Realm, and returns a notification token. |
||||
|
||||
Notification handlers are called after each write transaction is committed, |
||||
either on the current thread or other threads. |
||||
|
||||
Handler blocks are called on the same thread that they were added on, and may |
||||
only be added on threads which are currently within a run loop. Unless you are |
||||
specifically creating and running a run loop on a background thread, this will |
||||
normally only be the main thread. |
||||
|
||||
The block has the following definition: |
||||
|
||||
typedef void(^RLMNotificationBlock)(RLMNotification notification, RLMRealm *realm); |
||||
|
||||
It receives the following parameters: |
||||
|
||||
- `NSString` \***notification**: The name of the incoming notification. See |
||||
`RLMRealmNotification` for information on what |
||||
notifications are sent. |
||||
- `RLMRealm` \***realm**: The Realm for which this notification occurred. |
||||
|
||||
@param block A block which is called to process Realm notifications. |
||||
|
||||
@return A token object which must be retained as long as you wish to continue |
||||
receiving change notifications. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(RLMNotificationBlock)block __attribute__((warn_unused_result)); |
||||
|
||||
#pragma mark - Transactions |
||||
|
||||
|
||||
#pragma mark - Writing to a Realm |
||||
|
||||
/**
|
||||
Begins a write transaction on the Realm. |
||||
|
||||
Only one write transaction can be open at a time for each Realm file. Write |
||||
transactions cannot be nested, and trying to begin a write transaction on a |
||||
Realm which is already in a write transaction will throw an exception. Calls to |
||||
`beginWriteTransaction` from `RLMRealm` instances for the same Realm file in |
||||
other threads or other processes will block until the current write transaction |
||||
completes or is cancelled. |
||||
|
||||
Before beginning the write transaction, `beginWriteTransaction` updates the |
||||
`RLMRealm` instance to the latest Realm version, as if `refresh` had been |
||||
called, and generates notifications if applicable. This has no effect if the |
||||
Realm was already up to date. |
||||
|
||||
It is rarely a good idea to have write transactions span multiple cycles of |
||||
the run loop, but if you do wish to do so you will need to ensure that the |
||||
Realm participating in the write transaction is kept alive until the write |
||||
transaction is committed. |
||||
*/ |
||||
- (void)beginWriteTransaction; |
||||
|
||||
/**
|
||||
Commits all write operations in the current write transaction, and ends the |
||||
transaction. |
||||
|
||||
After saving the changes, all notification blocks registered on this specific |
||||
`RLMRealm` instance are invoked synchronously. Notification blocks registered |
||||
on other threads or on collections are invoked asynchronously. If you do not |
||||
want to receive a specific notification for this write tranaction, see |
||||
`commitWriteTransactionWithoutNotifying:error:`. |
||||
|
||||
This method can fail if there is insufficient disk space available to save the |
||||
writes made, or due to unexpected i/o errors. This version of the method throws |
||||
an exception when errors occur. Use the version with a `NSError` out parameter |
||||
instead if you wish to handle errors. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
*/ |
||||
- (void)commitWriteTransaction NS_SWIFT_UNAVAILABLE(""); |
||||
|
||||
/**
|
||||
Commits all write operations in the current write transaction, and ends the |
||||
transaction. |
||||
|
||||
After saving the changes, all notification blocks registered on this specific |
||||
`RLMRealm` instance are invoked synchronously. Notification blocks registered |
||||
on other threads or on collections are invoked asynchronously. If you do not |
||||
want to receive a specific notification for this write tranaction, see |
||||
`commitWriteTransactionWithoutNotifying:error:`. |
||||
|
||||
This method can fail if there is insufficient disk space available to save the |
||||
writes made, or due to unexpected i/o errors. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return Whether the transaction succeeded. |
||||
*/ |
||||
- (BOOL)commitWriteTransaction:(NSError **)error; |
||||
|
||||
/**
|
||||
Commits all write operations in the current write transaction, without |
||||
notifying specific notification blocks of the changes. |
||||
|
||||
After saving the changes, all notification blocks registered on this specific |
||||
`RLMRealm` instance are invoked synchronously. Notification blocks registered |
||||
on other threads or on collections are scheduled to be invoked asynchronously. |
||||
|
||||
You can skip notifiying specific notification blocks about the changes made |
||||
in this write transaction by passing in their associated notification tokens. |
||||
This is primarily useful when the write transaction is saving changes already |
||||
made in the UI and you do not want to have the notification block attempt to |
||||
re-apply the same changes. |
||||
|
||||
The tokens passed to this method must be for notifications for this specific |
||||
`RLMRealm` instance. Notifications for different threads cannot be skipped |
||||
using this method. |
||||
|
||||
This method can fail if there is insufficient disk space available to save the |
||||
writes made, or due to unexpected i/o errors. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param tokens An array of notification tokens which were returned from adding |
||||
callbacks which you do not want to be notified for the changes |
||||
made in this write transaction. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return Whether the transaction succeeded. |
||||
*/ |
||||
- (BOOL)commitWriteTransactionWithoutNotifying:(NSArray<RLMNotificationToken *> *)tokens error:(NSError **)error; |
||||
|
||||
/**
|
||||
Reverts all writes made during the current write transaction and ends the transaction. |
||||
|
||||
This rolls back all objects in the Realm to the state they were in at the |
||||
beginning of the write transaction, and then ends the transaction. |
||||
|
||||
This restores the data for deleted objects, but does not revive invalidated |
||||
object instances. Any `RLMObject`s which were added to the Realm will be |
||||
invalidated rather than becoming unmanaged. |
||||
Given the following code: |
||||
|
||||
ObjectType *oldObject = [[ObjectType objectsWhere:@"..."] firstObject]; |
||||
ObjectType *newObject = [[ObjectType alloc] init]; |
||||
|
||||
[realm beginWriteTransaction]; |
||||
[realm addObject:newObject]; |
||||
[realm deleteObject:oldObject]; |
||||
[realm cancelWriteTransaction]; |
||||
|
||||
Both `oldObject` and `newObject` will return `YES` for `isInvalidated`, |
||||
but re-running the query which provided `oldObject` will once again return |
||||
the valid object. |
||||
|
||||
KVO observers on any objects which were modified during the transaction will |
||||
be notified about the change back to their initial values, but no other |
||||
notifcations are produced by a cancelled write transaction. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
*/ |
||||
- (void)cancelWriteTransaction; |
||||
|
||||
/**
|
||||
Performs actions contained within the given block inside a write transaction. |
||||
|
||||
@see `[RLMRealm transactionWithBlock:error:]` |
||||
*/ |
||||
- (void)transactionWithBlock:(__attribute__((noescape)) void(^)(void))block NS_SWIFT_UNAVAILABLE(""); |
||||
|
||||
/**
|
||||
Performs actions contained within the given block inside a write transaction. |
||||
|
||||
Write transactions cannot be nested, and trying to execute a write transaction |
||||
on a Realm which is already participating in a write transaction will throw an |
||||
exception. Calls to `transactionWithBlock:` from `RLMRealm` instances in other |
||||
threads will block until the current write transaction completes. |
||||
|
||||
Before beginning the write transaction, `transactionWithBlock:` updates the |
||||
`RLMRealm` instance to the latest Realm version, as if `refresh` had been called, and |
||||
generates notifications if applicable. This has no effect if the Realm |
||||
was already up to date. |
||||
|
||||
@param block The block containing actions to perform. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return Whether the transaction succeeded. |
||||
*/ |
||||
- (BOOL)transactionWithBlock:(__attribute__((noescape)) void(^)(void))block error:(NSError **)error; |
||||
|
||||
/**
|
||||
Updates the Realm and outstanding objects managed by the Realm to point to the |
||||
most recent data. |
||||
|
||||
If the version of the Realm is actually changed, Realm and collection |
||||
notifications will be sent to reflect the changes. This may take some time, as |
||||
collection notifications are prepared on a background thread. As a result, |
||||
calling this method on the main thread is not advisable. |
||||
|
||||
@return Whether there were any updates for the Realm. Note that `YES` may be |
||||
returned even if no data actually changed. |
||||
*/ |
||||
- (BOOL)refresh; |
||||
|
||||
/**
|
||||
Set this property to `YES` to automatically update this Realm when changes |
||||
happen in other threads. |
||||
|
||||
If set to `YES` (the default), changes made on other threads will be reflected |
||||
in this Realm on the next cycle of the run loop after the changes are |
||||
committed. If set to `NO`, you must manually call `-refresh` on the Realm to |
||||
update it to get the latest data. |
||||
|
||||
Note that by default, background threads do not have an active run loop and you |
||||
will need to manually call `-refresh` in order to update to the latest version, |
||||
even if `autorefresh` is set to `YES`. |
||||
|
||||
Even with this property enabled, you can still call `-refresh` at any time to |
||||
update the Realm before the automatic refresh would occur. |
||||
|
||||
Write transactions will still always advance a Realm to the latest version and |
||||
produce local notifications on commit even if autorefresh is disabled. |
||||
|
||||
Disabling `autorefresh` on a Realm without any strong references to it will not |
||||
have any effect, and `autorefresh` will revert back to `YES` the next time the |
||||
Realm is created. This is normally irrelevant as it means that there is nothing |
||||
to refresh (as managed `RLMObject`s, `RLMArray`s, and `RLMResults` have strong |
||||
references to the Realm that manages them), but it means that setting |
||||
`RLMRealm.defaultRealm.autorefresh = NO` in |
||||
`application:didFinishLaunchingWithOptions:` and only later storing Realm |
||||
objects will not work. |
||||
|
||||
Defaults to `YES`. |
||||
*/ |
||||
@property (nonatomic) BOOL autorefresh; |
||||
|
||||
/**
|
||||
Writes a compacted and optionally encrypted copy of the Realm to the given local URL. |
||||
|
||||
The destination file cannot already exist. |
||||
|
||||
Note that if this method is called from within a write transaction, the |
||||
*current* data is written, not the data from the point when the previous write |
||||
transaction was committed. |
||||
|
||||
@param fileURL Local URL to save the Realm to. |
||||
@param key Optional 64-byte encryption key to encrypt the new file with. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return `YES` if the Realm was successfully written to disk, `NO` if an error occurred. |
||||
*/ |
||||
- (BOOL)writeCopyToURL:(NSURL *)fileURL encryptionKey:(nullable NSData *)key error:(NSError **)error; |
||||
|
||||
/**
|
||||
Invalidates all `RLMObject`s, `RLMResults`, `RLMLinkingObjects`, and `RLMArray`s managed by the Realm. |
||||
|
||||
A Realm holds a read lock on the version of the data accessed by it, so |
||||
that changes made to the Realm on different threads do not modify or delete the |
||||
data seen by this Realm. Calling this method releases the read lock, |
||||
allowing the space used on disk to be reused by later write transactions rather |
||||
than growing the file. This method should be called before performing long |
||||
blocking operations on a background thread on which you previously read data |
||||
from the Realm which you no longer need. |
||||
|
||||
All `RLMObject`, `RLMResults` and `RLMArray` instances obtained from this |
||||
`RLMRealm` instance on the current thread are invalidated. `RLMObject`s and `RLMArray`s |
||||
cannot be used. `RLMResults` will become empty. The Realm itself remains valid, |
||||
and a new read transaction is implicitly begun the next time data is read from the Realm. |
||||
|
||||
Calling this method multiple times in a row without reading any data from the |
||||
Realm, or before ever reading any data from the Realm, is a no-op. This method |
||||
may not be called on a read-only Realm. |
||||
*/ |
||||
- (void)invalidate; |
||||
|
||||
#pragma mark - Accessing Objects |
||||
|
||||
/**
|
||||
Returns the same object as the one referenced when the `RLMThreadSafeReference` was first created, |
||||
but resolved for the current Realm for this thread. Returns `nil` if this object was deleted after |
||||
the reference was created. |
||||
|
||||
@param reference The thread-safe reference to the thread-confined object to resolve in this Realm. |
||||
|
||||
@warning A `RLMThreadSafeReference` object must be resolved at most once. |
||||
Failing to resolve a `RLMThreadSafeReference` will result in the source version of the |
||||
Realm being pinned until the reference is deallocated. |
||||
An exception will be thrown if a reference is resolved more than once. |
||||
|
||||
@warning Cannot call within a write transaction. |
||||
|
||||
@note Will refresh this Realm if the source Realm was at a later version than this one. |
||||
|
||||
@see `+[RLMThreadSafeReference referenceWithThreadConfined:]` |
||||
*/ |
||||
- (nullable id)resolveThreadSafeReference:(RLMThreadSafeReference *)reference |
||||
NS_REFINED_FOR_SWIFT; |
||||
|
||||
#pragma mark - Adding and Removing Objects from a Realm |
||||
|
||||
/**
|
||||
Adds an object to the Realm. |
||||
|
||||
Once added, this object is considered to be managed by the Realm. It can be retrieved |
||||
using the `objectsWhere:` selectors on `RLMRealm` and on subclasses of `RLMObject`. |
||||
|
||||
When added, all child relationships referenced by this object will also be added to |
||||
the Realm if they are not already in it. |
||||
|
||||
If the object or any related objects are already being managed by a different Realm |
||||
an exception will be thrown. Use `-[RLMObject createInRealm:withObject:]` to insert a copy of a managed object |
||||
into a different Realm. |
||||
|
||||
The object to be added must be valid and cannot have been previously deleted |
||||
from a Realm (i.e. `isInvalidated` must be `NO`). |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param object The object to be added to this Realm. |
||||
*/ |
||||
- (void)addObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Adds all the objects in a collection to the Realm. |
||||
|
||||
This is the equivalent of calling `addObject:` for every object in a collection. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param objects An enumerable collection such as `NSArray`, `RLMArray`, or `RLMResults`, |
||||
containing Realm objects to be added to the Realm. |
||||
|
||||
@see `addObject:` |
||||
*/ |
||||
- (void)addObjects:(id<NSFastEnumeration>)objects; |
||||
|
||||
/**
|
||||
Adds or updates an existing object into the Realm. |
||||
|
||||
The object provided must have a designated primary key. If no objects exist in the Realm |
||||
with the same primary key value, the object is inserted. Otherwise, the existing object is |
||||
updated with any changed values. |
||||
|
||||
As with `addObject:`, the object cannot already be managed by a different |
||||
Realm. Use `-[RLMObject createOrUpdateInRealm:withValue:]` to copy values to |
||||
a different Realm. |
||||
|
||||
If there is a property or KVC value on `object` whose value is nil, and it corresponds |
||||
to a nullable property on an existing object being updated, that nullable property will |
||||
be set to nil. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param object The object to be added or updated. |
||||
*/ |
||||
- (void)addOrUpdateObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Adds or updates all the objects in a collection into the Realm. |
||||
|
||||
This is the equivalent of calling `addOrUpdateObject:` for every object in a collection. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param objects An enumerable collection such as `NSArray`, `RLMArray`, or `RLMResults`, |
||||
containing Realm objects to be added to or updated within the Realm. |
||||
|
||||
@see `addOrUpdateObject:` |
||||
*/ |
||||
- (void)addOrUpdateObjects:(id<NSFastEnumeration>)objects; |
||||
|
||||
/**
|
||||
Deletes an object from the Realm. Once the object is deleted it is considered invalidated. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param object The object to be deleted. |
||||
*/ |
||||
- (void)deleteObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Deletes one or more objects from the Realm. |
||||
|
||||
This is the equivalent of calling `deleteObject:` for every object in a collection. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param objects An enumerable collection such as `NSArray`, `RLMArray`, or `RLMResults`, |
||||
containing objects to be deleted from the Realm. |
||||
|
||||
@see `deleteObject:` |
||||
*/ |
||||
- (void)deleteObjects:(id<NSFastEnumeration>)objects; |
||||
|
||||
/**
|
||||
Deletes all objects from the Realm. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@see `deleteObject:` |
||||
*/ |
||||
- (void)deleteAllObjects; |
||||
|
||||
|
||||
#pragma mark - Migrations |
||||
|
||||
/**
|
||||
The type of a migration block used to migrate a Realm. |
||||
|
||||
@param migration A `RLMMigration` object used to perform the migration. The |
||||
migration object allows you to enumerate and alter any |
||||
existing objects which require migration. |
||||
|
||||
@param oldSchemaVersion The schema version of the Realm being migrated. |
||||
*/ |
||||
typedef void (^RLMMigrationBlock)(RLMMigration *migration, uint64_t oldSchemaVersion); |
||||
|
||||
/**
|
||||
Returns the schema version for a Realm at a given local URL. |
||||
|
||||
@param fileURL Local URL to a Realm file. |
||||
@param key 64-byte key used to encrypt the file, or `nil` if it is unencrypted. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return The version of the Realm at `fileURL`, or `RLMNotVersioned` if the version cannot be read. |
||||
*/ |
||||
+ (uint64_t)schemaVersionAtURL:(NSURL *)fileURL encryptionKey:(nullable NSData *)key error:(NSError **)error |
||||
NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Performs the given Realm configuration's migration block on a Realm at the given path. |
||||
|
||||
This method is called automatically when opening a Realm for the first time and does |
||||
not need to be called explicitly. You can choose to call this method to control |
||||
exactly when and how migrations are performed. |
||||
|
||||
@param configuration The Realm configuration used to open and migrate the Realm. |
||||
@return The error that occurred while applying the migration, if any. |
||||
|
||||
@see RLMMigration |
||||
*/ |
||||
+ (BOOL)performMigrationForConfiguration:(RLMRealmConfiguration *)configuration error:(NSError **)error; |
||||
|
||||
#pragma mark - Privileges |
||||
|
||||
/**
|
||||
Returns the computed privileges which the current user has for this Realm. |
||||
|
||||
This combines all privileges granted on the Realm by all Roles which the |
||||
current User is a member of into the final privileges which will be enforced by |
||||
the server. |
||||
|
||||
The privilege calculation is done locally using cached data, and inherently may |
||||
be stale. It is possible that this method may indicate that an operation is |
||||
permitted but the server will still reject it if permission is revoked before |
||||
the changes have been integrated on the server. |
||||
|
||||
Non-synchronized Realms always have permission to perform all operations. |
||||
|
||||
@warning This currently returns incorrect results for non-partially-synchronized read-only Realms. |
||||
@return The privileges which the current user has for the current Realm. |
||||
*/ |
||||
- (struct RLMRealmPrivileges)privilegesForRealm; |
||||
|
||||
/**
|
||||
Returns the computed privileges which the current user has for the given object. |
||||
|
||||
This combines all privileges granted on the object by all Roles which the |
||||
current User is a member of into the final privileges which will be enforced by |
||||
the server. |
||||
|
||||
The privilege calculation is done locally using cached data, and inherently may |
||||
be stale. It is possible that this method may indicate that an operation is |
||||
permitted but the server will still reject it if permission is revoked before |
||||
the changes have been integrated on the server. |
||||
|
||||
Non-synchronized Realms always have permission to perform all operations. |
||||
|
||||
The object must be a valid object managed by this Realm. Passing in an |
||||
invalidated object, an unmanaged object, or an object managed by a different |
||||
Realm will throw an exception. |
||||
|
||||
@warning This currently returns incorrect results for non-partially-synchronized read-only Realms. |
||||
@return The privileges which the current user has for the given object. |
||||
*/ |
||||
- (struct RLMObjectPrivileges)privilegesForObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Returns the computed privileges which the current user has for the given class. |
||||
|
||||
This combines all privileges granted on the class by all Roles which the |
||||
current User is a member of into the final privileges which will be enforced by |
||||
the server. |
||||
|
||||
The privilege calculation is done locally using cached data, and inherently may |
||||
be stale. It is possible that this method may indicate that an operation is |
||||
permitted but the server will still reject it if permission is revoked before |
||||
the changes have been integrated on the server. |
||||
|
||||
Non-synchronized Realms always have permission to perform all operations. |
||||
|
||||
@warning This currently returns incorrect results for non-partially-synchronized read-only Realms. |
||||
@return The privileges which the current user has for the given object. |
||||
*/ |
||||
- (struct RLMClassPrivileges)privilegesForClass:(Class)cls; |
||||
|
||||
/**
|
||||
Returns the computed privileges which the current user has for the named class. |
||||
|
||||
This combines all privileges granted on the class by all Roles which the |
||||
current User is a member of into the final privileges which will be enforced by |
||||
the server. |
||||
|
||||
The privilege calculation is done locally using cached data, and inherently may |
||||
be stale. It is possible that this method may indicate that an operation is |
||||
permitted but the server will still reject it if permission is revoked before |
||||
the changes have been integrated on the server. |
||||
|
||||
Non-synchronized Realms always have permission to perform all operations. |
||||
|
||||
@warning This currently returns incorrect results for non-partially-synchronized read-only Realms. |
||||
@return The privileges which the current user has for the given object. |
||||
*/ |
||||
- (struct RLMClassPrivileges)privilegesForClassNamed:(NSString *)className; |
||||
|
||||
#pragma mark - Unavailable Methods |
||||
|
||||
/**
|
||||
RLMRealm instances are cached internally by Realm and cannot be created directly. |
||||
|
||||
Use `+[RLMRealm defaultRealm]`, `+[RLMRealm realmWithConfiguration:error:]` or |
||||
`+[RLMRealm realmWithURL]` to obtain a reference to an RLMRealm. |
||||
*/ |
||||
- (instancetype)init __attribute__((unavailable("Use +defaultRealm, +realmWithConfiguration: or +realmWithURL:."))); |
||||
|
||||
/**
|
||||
RLMRealm instances are cached internally by Realm and cannot be created directly. |
||||
|
||||
Use `+[RLMRealm defaultRealm]`, `+[RLMRealm realmWithConfiguration:error:]` or |
||||
`+[RLMRealm realmWithURL]` to obtain a reference to an RLMRealm. |
||||
*/ |
||||
+ (instancetype)new __attribute__((unavailable("Use +defaultRealm, +realmWithConfiguration: or +realmWithURL:."))); |
||||
|
||||
/// :nodoc:
|
||||
- (void)addOrUpdateObjectsFromArray:(id)array __attribute__((unavailable("Renamed to -addOrUpdateObjects:."))); |
||||
|
||||
@end |
||||
|
||||
// MARK: - RLMNotificationToken
|
||||
|
||||
/**
|
||||
A token which is returned from methods which subscribe to changes to a Realm. |
||||
|
||||
Change subscriptions in Realm return an `RLMNotificationToken` instance, |
||||
which can be used to unsubscribe from the changes. You must store a strong |
||||
reference to the token for as long as you want to continue to receive notifications. |
||||
When you wish to stop, call the `-invalidate` method. Notifications are also stopped if |
||||
the token is deallocated. |
||||
*/ |
||||
@interface RLMNotificationToken : NSObject |
||||
/// Stops notifications for the change subscription that returned this token.
|
||||
- (void)invalidate; |
||||
|
||||
/// Stops notifications for the change subscription that returned this token.
|
||||
- (void)stop __attribute__((unavailable("Renamed to -invalidate."))) NS_REFINED_FOR_SWIFT; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
43
Carthage/Build/Mac/Realm.framework/Versions/A/Headers/RLMRealmConfiguration+Sync.h
generated
vendored
43
Carthage/Build/Mac/Realm.framework/Versions/A/Headers/RLMRealmConfiguration+Sync.h
generated
vendored
@ -0,0 +1,43 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMRealmConfiguration.h> |
||||
|
||||
#import "RLMSyncUtil.h" |
||||
|
||||
@class RLMSyncConfiguration; |
||||
|
||||
/// Realm configuration options related to Sync.
|
||||
@interface RLMRealmConfiguration (Sync) |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
A configuration object representing configuration state for Realms intended |
||||
to sync with a Realm Object Server. |
||||
|
||||
This property is mutually exclusive with both `inMemoryIdentifier` and `fileURL`; |
||||
setting any one of the three properties will automatically nil out the other two. |
||||
|
||||
@see `RLMSyncConfiguration` |
||||
*/ |
||||
@property (nullable, nonatomic) RLMSyncConfiguration *syncConfiguration; |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
|
||||
@end |
||||
123
Carthage/Build/Mac/Realm.framework/Versions/A/Headers/RLMRealmConfiguration.h
generated
vendored
123
Carthage/Build/Mac/Realm.framework/Versions/A/Headers/RLMRealmConfiguration.h
generated
vendored
@ -0,0 +1,123 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import <Realm/RLMRealm.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
A block called when opening a Realm for the first time during the life |
||||
of a process to determine if it should be compacted before being returned |
||||
to the user. It is passed the total file size (data + free space) and the total |
||||
bytes used by data in the file. |
||||
|
||||
Return `YES` to indicate that an attempt to compact the file should be made. |
||||
The compaction will be skipped if another process is accessing it. |
||||
*/ |
||||
typedef BOOL (^RLMShouldCompactOnLaunchBlock)(NSUInteger totalBytes, NSUInteger bytesUsed); |
||||
|
||||
/**
|
||||
An `RLMRealmConfiguration` instance describes the different options used to |
||||
create an instance of a Realm. |
||||
|
||||
`RLMRealmConfiguration` instances are just plain `NSObject`s. Unlike `RLMRealm`s |
||||
and `RLMObject`s, they can be freely shared between threads as long as you do not |
||||
mutate them. |
||||
|
||||
Creating configuration objects for class subsets (by setting the |
||||
`objectClasses` property) can be expensive. Because of this, you will normally want to |
||||
cache and reuse a single configuration object for each distinct configuration rather than |
||||
creating a new object each time you open a Realm. |
||||
*/ |
||||
@interface RLMRealmConfiguration : NSObject<NSCopying> |
||||
|
||||
#pragma mark - Default Configuration |
||||
|
||||
/**
|
||||
Returns the default configuration used to create Realms when no other |
||||
configuration is explicitly specified (i.e. `+[RLMRealm defaultRealm]`). |
||||
|
||||
@return The default Realm configuration. |
||||
*/ |
||||
+ (instancetype)defaultConfiguration; |
||||
|
||||
/**
|
||||
Sets the default configuration to the given `RLMRealmConfiguration`. |
||||
|
||||
@param configuration The new default Realm configuration. |
||||
*/ |
||||
+ (void)setDefaultConfiguration:(RLMRealmConfiguration *)configuration; |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/// The local URL of the Realm file. Mutually exclusive with `inMemoryIdentifier` and `syncConfiguration`;
|
||||
/// setting any one of the three properties will automatically nil out the other two.
|
||||
@property (nonatomic, copy, nullable) NSURL *fileURL; |
||||
|
||||
/// A string used to identify a particular in-memory Realm. Mutually exclusive with `fileURL` and `syncConfiguration`;
|
||||
/// setting any one of the three properties will automatically nil out the other two.
|
||||
@property (nonatomic, copy, nullable) NSString *inMemoryIdentifier; |
||||
|
||||
/// A 64-byte key to use to encrypt the data, or `nil` if encryption is not enabled.
|
||||
@property (nonatomic, copy, nullable) NSData *encryptionKey; |
||||
|
||||
/// Whether to open the Realm in read-only mode.
|
||||
///
|
||||
/// This is required to be able to open Realm files which are not writeable or
|
||||
/// are in a directory which is not writeable. This should only be used on files
|
||||
/// which will not be modified by anyone while they are open, and not just to
|
||||
/// get a read-only view of a file which may be written to by another thread or
|
||||
/// process. Opening in read-only mode requires disabling Realm's reader/writer
|
||||
/// coordination, so committing a write transaction from another process will
|
||||
/// result in crashes.
|
||||
@property (nonatomic) BOOL readOnly; |
||||
|
||||
/// The current schema version.
|
||||
@property (nonatomic) uint64_t schemaVersion; |
||||
|
||||
/// The block which migrates the Realm to the current version.
|
||||
@property (nonatomic, copy, nullable) RLMMigrationBlock migrationBlock; |
||||
|
||||
/**
|
||||
Whether to recreate the Realm file with the provided schema if a migration is required. |
||||
This is the case when the stored schema differs from the provided schema or |
||||
the stored schema version differs from the version on this configuration. |
||||
Setting this property to `YES` deletes the file if a migration would otherwise be required or executed. |
||||
|
||||
@note Setting this property to `YES` doesn't disable file format migrations. |
||||
*/ |
||||
@property (nonatomic) BOOL deleteRealmIfMigrationNeeded; |
||||
|
||||
/**
|
||||
A block called when opening a Realm for the first time during the life |
||||
of a process to determine if it should be compacted before being returned |
||||
to the user. It is passed the total file size (data + free space) and the total |
||||
bytes used by data in the file. |
||||
|
||||
Return `YES` to indicate that an attempt to compact the file should be made. |
||||
The compaction will be skipped if another process is accessing it. |
||||
*/ |
||||
@property (nonatomic, copy, nullable) RLMShouldCompactOnLaunchBlock shouldCompactOnLaunch; |
||||
|
||||
/// The classes managed by the Realm.
|
||||
@property (nonatomic, copy, nullable) NSArray *objectClasses; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,118 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMRealm.h> |
||||
|
||||
#import <Realm/RLMObjectSchema.h> |
||||
#import <Realm/RLMProperty.h> |
||||
|
||||
@class RLMResults<RLMObjectType>; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@interface RLMRealm (Dynamic) |
||||
|
||||
#pragma mark - Getting Objects from a Realm |
||||
|
||||
/**
|
||||
Returns all objects of a given type from the Realm. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. The preferred way to get objects of a single class is to use the class |
||||
methods on `RLMObject`. |
||||
|
||||
@param className The name of the `RLMObject` subclass to retrieve on (e.g. `MyClass.className`). |
||||
|
||||
@return An `RLMResults` containing all objects in the Realm of the given type. |
||||
|
||||
@see `+[RLMObject allObjects]` |
||||
*/ |
||||
- (RLMResults<RLMObject *> *)allObjects:(NSString *)className; |
||||
|
||||
/**
|
||||
Returns all objects matching the given predicate from the Realm. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. The preferred way to get objects of a single class is to use the class |
||||
methods on `RLMObject`. |
||||
|
||||
@param className The type of objects you are looking for (name of the class). |
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` containing results matching the given predicate. |
||||
|
||||
@see `+[RLMObject objectsWhere:]` |
||||
*/ |
||||
- (RLMResults<RLMObject *> *)objects:(NSString *)className where:(NSString *)predicateFormat, ...; |
||||
|
||||
/**
|
||||
Returns all objects matching the given predicate from the Realm. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. The preferred way to get objects of a single class is to use the class |
||||
methods on `RLMObject`. |
||||
|
||||
@param className The type of objects you are looking for (name of the class). |
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` containing results matching the given predicate. |
||||
|
||||
@see `+[RLMObject objectsWhere:]` |
||||
*/ |
||||
- (RLMResults<RLMObject *> *)objects:(NSString *)className withPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns the object of the given type with the given primary key from the Realm. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. The preferred way to get an object of a single class is to use the class |
||||
methods on `RLMObject`. |
||||
|
||||
@param className The class name for the object you are looking for. |
||||
@param primaryKey The primary key value for the object you are looking for. |
||||
|
||||
@return An object, or `nil` if an object with the given primary key does not exist. |
||||
|
||||
@see `+[RLMObject objectForPrimaryKey:]` |
||||
*/ |
||||
- (nullable RLMObject *)objectWithClassName:(NSString *)className forPrimaryKey:(id)primaryKey; |
||||
|
||||
/**
|
||||
Creates an `RLMObject` instance of type `className` in the Realm, and populates it using a given object. |
||||
|
||||
The `value` argument is used to populate the object. It can be a key-value coding compliant object, an array or |
||||
dictionary returned from the methods in `NSJSONSerialization`, or an array containing one element for each managed |
||||
property. An exception will be thrown if any required properties are not present and those properties were not defined |
||||
with default values. |
||||
|
||||
When passing in an array as the `value` argument, all properties must be present, valid and in the same order as the |
||||
properties defined in the model. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is recommended to |
||||
use `[RLMObject createInDefaultRealmWithValue:]`. |
||||
|
||||
@param value The value used to populate the object. |
||||
|
||||
@return An `RLMObject` instance of type `className`. |
||||
*/ |
||||
-(RLMObject *)createObject:(NSString *)className withValue:(id)value; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,351 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMCollection.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMObject; |
||||
|
||||
/**
|
||||
`RLMResults` is an auto-updating container type in Realm returned from object |
||||
queries. It represents the results of the query in the form of a collection of objects. |
||||
|
||||
`RLMResults` can be queried using the same predicates as `RLMObject` and `RLMArray`, |
||||
and you can chain queries to further filter results. |
||||
|
||||
`RLMResults` always reflect the current state of the Realm on the current thread, |
||||
including during write transactions on the current thread. The one exception to |
||||
this is when using `for...in` fast enumeration, which will always enumerate |
||||
over the objects which matched the query when the enumeration is begun, even if |
||||
some of them are deleted or modified to be excluded by the filter during the |
||||
enumeration. |
||||
|
||||
`RLMResults` are lazily evaluated the first time they are accessed; they only |
||||
run queries when the result of the query is requested. This means that |
||||
chaining several temporary `RLMResults` to sort and filter your data does not |
||||
perform any extra work processing the intermediate state. |
||||
|
||||
Once the results have been evaluated or a notification block has been added, |
||||
the results are eagerly kept up-to-date, with the work done to keep them |
||||
up-to-date done on a background thread whenever possible. |
||||
|
||||
`RLMResults` cannot be directly instantiated. |
||||
*/ |
||||
@interface RLMResults<RLMObjectType> : NSObject<RLMCollection, NSFastEnumeration> |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The number of objects in the results collection. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) NSUInteger count; |
||||
|
||||
/**
|
||||
The type of the objects in the results collection. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) RLMPropertyType type; |
||||
|
||||
/**
|
||||
Indicates whether the objects in the collection can be `nil`. |
||||
*/ |
||||
@property (nonatomic, readwrite, getter = isOptional) BOOL optional; |
||||
|
||||
/**
|
||||
The class name of the objects contained in the results collection. |
||||
|
||||
Will be `nil` if `type` is not RLMPropertyTypeObject. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *objectClassName; |
||||
|
||||
/**
|
||||
The Realm which manages this results collection. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMRealm *realm; |
||||
|
||||
/**
|
||||
Indicates if the results collection is no longer valid. |
||||
|
||||
The results collection becomes invalid if `invalidate` is called on the containing `realm`. |
||||
An invalidated results collection can be accessed, but will always be empty. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
#pragma mark - Accessing Objects from an RLMResults |
||||
|
||||
/**
|
||||
Returns the object at the index specified. |
||||
|
||||
@param index The index to look up. |
||||
|
||||
@return An object of the type contained in the results collection. |
||||
*/ |
||||
- (RLMObjectType)objectAtIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Returns the first object in the results collection. |
||||
|
||||
Returns `nil` if called on an empty results collection. |
||||
|
||||
@return An object of the type contained in the results collection. |
||||
*/ |
||||
- (nullable RLMObjectType)firstObject; |
||||
|
||||
/**
|
||||
Returns the last object in the results collection. |
||||
|
||||
Returns `nil` if called on an empty results collection. |
||||
|
||||
@return An object of the type contained in the results collection. |
||||
*/ |
||||
- (nullable RLMObjectType)lastObject; |
||||
|
||||
#pragma mark - Querying Results |
||||
|
||||
/**
|
||||
Returns the index of an object in the results collection. |
||||
|
||||
Returns `NSNotFound` if the object is not found in the results collection. |
||||
|
||||
@param object An object (of the same type as returned from the `objectClassName` selector). |
||||
*/ |
||||
- (NSUInteger)indexOfObject:(RLMObjectType)object; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the results collection matching the predicate. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the results collection. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the results collection matching the predicate. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the results collection. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns all the objects matching the given predicate in the results collection. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` of objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)objectsWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMResults<RLMObjectType> *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns all the objects matching the given predicate in the results collection. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` of objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)objectsWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from an existing results collection. |
||||
|
||||
@param keyPath The key path to sort by. |
||||
@param ascending The direction to sort in. |
||||
|
||||
@return An `RLMResults` sorted by the specified key path. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)sortedResultsUsingKeyPath:(NSString *)keyPath ascending:(BOOL)ascending; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from an existing results collection. |
||||
|
||||
@param properties An array of `RLMSortDescriptor`s to sort by. |
||||
|
||||
@return An `RLMResults` sorted by the specified properties. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)sortedResultsUsingDescriptors:(NSArray<RLMSortDescriptor *> *)properties; |
||||
|
||||
/**
|
||||
Returns a distinct `RLMResults` from an existing results collection. |
||||
|
||||
@param keyPaths The key paths used produce distinct results |
||||
|
||||
@return An `RLMResults` made distinct based on the specified key paths |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)distinctResultsUsingKeyPaths:(NSArray<NSString *> *)keyPaths; |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
Registers a block to be called each time the results collection changes. |
||||
|
||||
The block will be asynchronously called with the initial results collection, |
||||
and then called again after each write transaction which changes either any |
||||
of the objects in the results, or which objects are in the results. |
||||
|
||||
The `change` parameter will be `nil` the first time the block is called. |
||||
For each call after that, it will contain information about |
||||
which rows in the results collection were added, removed or modified. If a |
||||
write transaction did not modify any objects in the results collection, |
||||
the block is not called at all. See the `RLMCollectionChange` documentation for |
||||
information on how the changes are reported and an example of updating a |
||||
`UITableView`. |
||||
|
||||
If an error occurs the block will be called with `nil` for the results |
||||
parameter and a non-`nil` error. Currently the only errors that can occur are |
||||
when opening the Realm on the background worker thread. |
||||
|
||||
At the time when the block is called, the `RLMResults` object will be fully |
||||
evaluated and up-to-date, and as long as you do not perform a write transaction |
||||
on the same thread or explicitly call `-[RLMRealm refresh]`, accessing it will |
||||
never perform blocking work. |
||||
|
||||
Notifications are delivered via the standard run loop, and so can't be |
||||
delivered while the run loop is blocked by other activity. When |
||||
notifications can't be delivered instantly, multiple notifications may be |
||||
coalesced into a single notification. This can include the notification |
||||
with the initial results. For example, the following code performs a write |
||||
transaction immediately after adding the notification block, so there is no |
||||
opportunity for the initial notification to be delivered first. As a |
||||
result, the initial notification will reflect the state of the Realm after |
||||
the write transaction. |
||||
|
||||
RLMResults<Dog *> *results = [Dog allObjects]; |
||||
NSLog(@"dogs.count: %zu", dogs.count); // => 0
|
||||
self.token = [results addNotificationBlock:^(RLMResults *dogs, |
||||
RLMCollectionChange *changes, |
||||
NSError *error) { |
||||
// Only fired once for the example
|
||||
NSLog(@"dogs.count: %zu", dogs.count); // => 1
|
||||
}]; |
||||
[realm transactionWithBlock:^{ |
||||
Dog *dog = [[Dog alloc] init]; |
||||
dog.name = @"Rex"; |
||||
[realm addObject:dog]; |
||||
}]; |
||||
// end of run loop execution context
|
||||
|
||||
You must retain the returned token for as long as you want updates to continue |
||||
to be sent to the block. To stop receiving updates, call `-invalidate` on the token. |
||||
|
||||
@warning This method cannot be called during a write transaction, or when the |
||||
containing Realm is read-only. |
||||
|
||||
@param block The block to be called whenever a change occurs. |
||||
@return A token which must be held for as long as you want updates to be delivered. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(void (^)(RLMResults<RLMObjectType> *__nullable results, |
||||
RLMCollectionChange *__nullable change, |
||||
NSError *__nullable error))block __attribute__((warn_unused_result)); |
||||
|
||||
#pragma mark - Aggregating Property Values |
||||
|
||||
/**
|
||||
Returns the minimum (lowest) value of the given property among all the objects |
||||
represented by the results collection. |
||||
|
||||
NSNumber *min = [results minOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose minimum value is desired. Only properties of types `int`, `float`, `double`, and |
||||
`NSDate` are supported. |
||||
|
||||
@return The minimum value of the property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable id)minOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the maximum (highest) value of the given property among all the objects represented by the results collection. |
||||
|
||||
NSNumber *max = [results maxOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose maximum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The maximum value of the property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable id)maxOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the sum of the values of a given property over all the objects represented by the results collection. |
||||
|
||||
NSNumber *sum = [results sumOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose values should be summed. Only properties of |
||||
types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The sum of the given property. |
||||
*/ |
||||
- (NSNumber *)sumOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the average value of a given property over the objects represented by the results collection. |
||||
|
||||
NSNumber *average = [results averageOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose average value should be calculated. Only |
||||
properties of types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The average value of the given property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable NSNumber *)averageOfProperty:(NSString *)property; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMObjectType)objectAtIndexedSubscript:(NSUInteger)index; |
||||
|
||||
#pragma mark - Unavailable Methods |
||||
|
||||
/**
|
||||
`-[RLMResults init]` is not available because `RLMResults` cannot be created directly. |
||||
`RLMResults` can be obtained by querying a Realm. |
||||
*/ |
||||
- (instancetype)init __attribute__((unavailable("RLMResults cannot be created directly"))); |
||||
|
||||
/**
|
||||
`+[RLMResults new]` is not available because `RLMResults` cannot be created directly. |
||||
`RLMResults` can be obtained by querying a Realm. |
||||
*/ |
||||
+ (instancetype)new __attribute__((unavailable("RLMResults cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
`RLMLinkingObjects` is an auto-updating container type. It represents a collection of objects that link to its |
||||
parent object. |
||||
|
||||
For more information, please see the "Inverse Relationships" section in the |
||||
[documentation](https://realm.io/docs/objc/latest/#relationships).
|
||||
*/ |
||||
@interface RLMLinkingObjects<RLMObjectType: RLMObject *> : RLMResults |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,77 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMObjectSchema; |
||||
|
||||
/**
|
||||
`RLMSchema` instances represent collections of model object schemas managed by a Realm. |
||||
|
||||
When using Realm, `RLMSchema` instances allow performing migrations and |
||||
introspecting the database's schema. |
||||
|
||||
Schemas map to collections of tables in the core database. |
||||
*/ |
||||
@interface RLMSchema : NSObject<NSCopying> |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
An `NSArray` containing `RLMObjectSchema`s for all object types in the Realm. |
||||
|
||||
This property is intended to be used during migrations for dynamic introspection. |
||||
|
||||
@see `RLMObjectSchema` |
||||
*/ |
||||
@property (nonatomic, readonly, copy) NSArray<RLMObjectSchema *> *objectSchema; |
||||
|
||||
#pragma mark - Methods |
||||
|
||||
/**
|
||||
Returns an `RLMObjectSchema` for the given class name in the schema. |
||||
|
||||
@param className The object class name. |
||||
@return An `RLMObjectSchema` for the given class in the schema. |
||||
|
||||
@see `RLMObjectSchema` |
||||
*/ |
||||
- (nullable RLMObjectSchema *)schemaForClassName:(NSString *)className; |
||||
|
||||
/**
|
||||
Looks up and returns an `RLMObjectSchema` for the given class name in the Realm. |
||||
|
||||
If there is no object of type `className` in the schema, an exception will be thrown. |
||||
|
||||
@param className The object class name. |
||||
@return An `RLMObjectSchema` for the given class in this Realm. |
||||
|
||||
@see `RLMObjectSchema` |
||||
*/ |
||||
- (RLMObjectSchema *)objectForKeyedSubscript:(NSString *)className; |
||||
|
||||
/**
|
||||
Returns whether two `RLMSchema` instances are equivalent. |
||||
*/ |
||||
- (BOOL)isEqualToSchema:(RLMSchema *)schema; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,127 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
@class RLMRealmConfiguration; |
||||
@class RLMSyncUser; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
A configuration object representing configuration state for a Realm which is intended to sync with a Realm Object |
||||
Server. |
||||
*/ |
||||
@interface RLMSyncConfiguration : NSObject |
||||
|
||||
/// The user to which the remote Realm belongs.
|
||||
@property (nonatomic, readonly) RLMSyncUser *user; |
||||
|
||||
/**
|
||||
The URL of the remote Realm upon the Realm Object Server. |
||||
|
||||
@warning The URL cannot end with `.realm`, `.realm.lock` or `.realm.management`. |
||||
*/ |
||||
@property (nonatomic, readonly) NSURL *realmURL; |
||||
|
||||
/**
|
||||
A local path to a file containing the trust anchors for SSL connections. |
||||
|
||||
Only the certificates stored in the PEM file (or any certificates signed by it, |
||||
if the file contains a CA cert) will be accepted when initiating a connection |
||||
to a server. This prevents certain certain kinds of man-in-the-middle (MITM) |
||||
attacks, and can also be used to trust a self-signed certificate which would |
||||
otherwise be untrusted. |
||||
|
||||
On macOS, the file may be in any of the formats supported by SecItemImport(), |
||||
including PEM and .cer (see SecExternalFormat for a complete list of possible |
||||
formats). On iOS and other platforms, only DER .cer files are supported. |
||||
*/ |
||||
@property (nonatomic, nullable) NSURL *pinnedCertificateURL; |
||||
|
||||
/**
|
||||
Whether SSL certificate validation is enabled for the connection associated |
||||
with this configuration value. SSL certificate validation is ON by default. |
||||
|
||||
@warning NEVER disable certificate validation for clients and servers in production. |
||||
*/ |
||||
@property (nonatomic) BOOL enableSSLValidation; |
||||
|
||||
/**
|
||||
Whether this Realm should be opened in 'partial synchronization' mode. |
||||
Partial synchronization mode means that no objects are synchronized from the remote Realm |
||||
except those matching queries that the user explicitly specifies. |
||||
|
||||
@warning Partial synchronization is a tech preview. Its APIs are subject to change. |
||||
*/ |
||||
@property (nonatomic) BOOL isPartial DEPRECATED_MSG_ATTRIBUTE("Use 'fullSynchronization' instead."); |
||||
|
||||
/**
|
||||
Whether this Realm should be a fully synchronized Realm. |
||||
|
||||
Synchronized Realms comes in two flavors: Query-based and Fully synchronized. |
||||
A fully synchronized Realm will automatically synchronize the entire Realm in |
||||
the background while a query-based Realm will only synchronize the data being |
||||
subscribed to. Synchronized realms are by default query-based unless this |
||||
boolean is set. |
||||
*/ |
||||
@property (nonatomic) BOOL fullSynchronization; |
||||
|
||||
/**
|
||||
The prefix that is prepended to the path in the HTTP request that initiates a |
||||
sync connection. The value specified must match with the server's expectation. |
||||
Changing the value of `urlPrefix` should be matched with a corresponding |
||||
change of the server's configuration. |
||||
If no value is specified here then the default `/realm-sync` path is used. |
||||
*/ |
||||
@property (nonatomic, nullable, copy) NSString *urlPrefix; |
||||
|
||||
/**
|
||||
Create a sync configuration instance. |
||||
|
||||
@param user A `RLMSyncUser` that owns the Realm at the given URL. |
||||
@param url The unresolved absolute URL to the Realm on the Realm Object Server, e.g. |
||||
`realm://example.org/~/path/to/realm`. "Unresolved" means the path should
|
||||
contain the wildcard marker `~`, which will automatically be filled in with |
||||
the user identity by the Realm Object Server. |
||||
*/ |
||||
- (instancetype)initWithUser:(RLMSyncUser *)user realmURL:(NSURL *)url __attribute__((deprecated("Use [RLMSyncUser configurationWithURL] instead"))); |
||||
|
||||
/**
|
||||
Return a Realm configuration for syncing with the default Realm of the currently logged-in sync user. |
||||
|
||||
Partial synchronization is enabled in the returned configuration. |
||||
*/ |
||||
+ (RLMRealmConfiguration *)automaticConfiguration __attribute__((deprecated("Use [RLMSyncUser configuration] instead"))); |
||||
|
||||
/**
|
||||
Return a Realm configuration for syncing with the default Realm of the given sync user. |
||||
|
||||
Partial synchronization is enabled in the returned configuration. |
||||
*/ |
||||
+ (RLMRealmConfiguration *)automaticConfigurationForUser:(RLMSyncUser *)user __attribute__((deprecated("Use [RLMSyncUser configuration] instead"))); |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)init __attribute__((unavailable("This type cannot be created directly"))); |
||||
|
||||
/// :nodoc:
|
||||
+ (instancetype)new __attribute__((unavailable("This type cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,140 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import "RLMSyncUtil.h" |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/// A token representing an identity provider's credentials.
|
||||
typedef NSString *RLMSyncCredentialsToken; |
||||
|
||||
/// A type representing the unique identifier of a Realm Object Server identity provider.
|
||||
typedef NSString *RLMIdentityProvider RLM_EXTENSIBLE_STRING_ENUM; |
||||
|
||||
/// The debug identity provider, which accepts any token string and creates a user associated with that token if one
|
||||
/// does not yet exist. Not enabled for Realm Object Server configured for production.
|
||||
extern RLMIdentityProvider const RLMIdentityProviderDebug; |
||||
|
||||
/// The username/password identity provider. User accounts are handled by the Realm Object Server directly without the
|
||||
/// involvement of a third-party identity provider.
|
||||
extern RLMIdentityProvider const RLMIdentityProviderUsernamePassword; |
||||
|
||||
/// A Facebook account as an identity provider.
|
||||
extern RLMIdentityProvider const RLMIdentityProviderFacebook; |
||||
|
||||
/// A Google account as an identity provider.
|
||||
extern RLMIdentityProvider const RLMIdentityProviderGoogle; |
||||
|
||||
/// A CloudKit account as an identity provider.
|
||||
extern RLMIdentityProvider const RLMIdentityProviderCloudKit; |
||||
|
||||
/// A JSON Web Token as an identity provider.
|
||||
extern RLMIdentityProvider const RLMIdentityProviderJWT; |
||||
|
||||
/// An Anonymous account as an identity provider.
|
||||
extern RLMIdentityProvider const RLMIdentityProviderAnonymous; |
||||
|
||||
/// A Nickname account as an identity provider.
|
||||
extern RLMIdentityProvider const RLMIdentityProviderNickname; |
||||
|
||||
/**
|
||||
Opaque credentials representing a specific Realm Object Server user. |
||||
*/ |
||||
@interface RLMSyncCredentials : NSObject |
||||
|
||||
/// An opaque credentials token containing information that uniquely identifies a Realm Object Server user.
|
||||
@property (nonatomic, readonly) RLMSyncCredentialsToken token; |
||||
|
||||
/// The name of the identity provider which generated the credentials token.
|
||||
@property (nonatomic, readonly) RLMIdentityProvider provider; |
||||
|
||||
/// A dictionary containing additional pertinent information. In most cases this is automatically configured.
|
||||
@property (nonatomic, readonly) NSDictionary<NSString *, id> *userInfo; |
||||
|
||||
/**
|
||||
Construct and return credentials from a Facebook account token. |
||||
*/ |
||||
+ (instancetype)credentialsWithFacebookToken:(RLMSyncCredentialsToken)token; |
||||
|
||||
/**
|
||||
Construct and return credentials from a Google account token. |
||||
*/ |
||||
+ (instancetype)credentialsWithGoogleToken:(RLMSyncCredentialsToken)token; |
||||
|
||||
/**
|
||||
Construct and return credentials from an CloudKit account token. |
||||
*/ |
||||
+ (instancetype)credentialsWithCloudKitToken:(RLMSyncCredentialsToken)token; |
||||
|
||||
/**
|
||||
Construct and return credentials from a Realm Object Server username and password. |
||||
*/ |
||||
+ (instancetype)credentialsWithUsername:(NSString *)username |
||||
password:(NSString *)password |
||||
register:(BOOL)shouldRegister; |
||||
|
||||
/**
|
||||
Construct and return credentials from a JSON Web Token. |
||||
*/ |
||||
+ (instancetype)credentialsWithJWT:(NSString *)token; |
||||
|
||||
/**
|
||||
Construct and return anonymous credentials |
||||
*/ |
||||
+ (instancetype)anonymousCredentials; |
||||
|
||||
/**
|
||||
Construct and return credentials from a nickname |
||||
*/ |
||||
+ (instancetype)credentialsWithNickname:(NSString *)nickname isAdmin:(BOOL)isAdmin; |
||||
|
||||
/**
|
||||
Construct and return special credentials representing a token that can |
||||
be directly used to open a Realm. The identity is used to uniquely identify |
||||
the user across application launches. |
||||
|
||||
@warning The custom user identity will be deprecated in a future release. |
||||
|
||||
@warning Do not specify a user identity that is the URL of an authentication |
||||
server. |
||||
|
||||
@warning When passing an access token credential into any of `RLMSyncUser`'s |
||||
login methods, you must always specify the same authentication server |
||||
URL, or none at all, every time you call the login method. |
||||
*/ |
||||
+ (instancetype)credentialsWithAccessToken:(RLMServerToken)accessToken identity:(NSString *)identity; |
||||
|
||||
/**
|
||||
Construct and return credentials with a custom token string, identity provider string, and optional user info. In most |
||||
cases, the convenience initializers should be used instead. |
||||
*/ |
||||
- (instancetype)initWithCustomToken:(RLMSyncCredentialsToken)token |
||||
provider:(RLMIdentityProvider)provider |
||||
userInfo:(nullable NSDictionary *)userInfo NS_DESIGNATED_INITIALIZER; |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)init __attribute__((unavailable("RLMSyncCredentials cannot be created directly"))); |
||||
|
||||
/// :nodoc:
|
||||
+ (instancetype)new __attribute__((unavailable("RLMSyncCredentials cannot be created directly"))); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
|
||||
@end |
||||
@ -0,0 +1,155 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import "RLMSyncUtil.h" |
||||
|
||||
@class RLMSyncSession; |
||||
|
||||
/// An enum representing different levels of sync-related logging that can be configured.
|
||||
typedef RLM_CLOSED_ENUM(NSUInteger, RLMSyncLogLevel) { |
||||
/// Nothing will ever be logged.
|
||||
RLMSyncLogLevelOff, |
||||
/// Only fatal errors will be logged.
|
||||
RLMSyncLogLevelFatal, |
||||
/// Only errors will be logged.
|
||||
RLMSyncLogLevelError, |
||||
/// Warnings and errors will be logged.
|
||||
RLMSyncLogLevelWarn, |
||||
/// Information about sync events will be logged. Fewer events will be logged in order to avoid overhead.
|
||||
RLMSyncLogLevelInfo, |
||||
/// Information about sync events will be logged. More events will be logged than with `RLMSyncLogLevelInfo`.
|
||||
RLMSyncLogLevelDetail, |
||||
/// Log information that can aid in debugging.
|
||||
///
|
||||
/// - warning: Will incur a measurable performance impact.
|
||||
RLMSyncLogLevelDebug, |
||||
/// Log information that can aid in debugging. More events will be logged than with `RLMSyncLogLevelDebug`.
|
||||
///
|
||||
/// - warning: Will incur a measurable performance impact.
|
||||
RLMSyncLogLevelTrace, |
||||
/// Log information that can aid in debugging. More events will be logged than with `RLMSyncLogLevelTrace`.
|
||||
///
|
||||
/// - warning: Will incur a measurable performance impact.
|
||||
RLMSyncLogLevelAll |
||||
}; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/// A block type representing a block which can be used to report a sync-related error to the application. If the error
|
||||
/// pertains to a specific session, that session will also be passed into the block.
|
||||
typedef void(^RLMSyncErrorReportingBlock)(NSError *, RLMSyncSession * _Nullable); |
||||
|
||||
/**
|
||||
A singleton manager which serves as a central point for sync-related configuration. |
||||
*/ |
||||
@interface RLMSyncManager : NSObject |
||||
|
||||
/**
|
||||
A block which can optionally be set to report sync-related errors to your application. |
||||
|
||||
Any error reported through this block will be of the `RLMSyncError` type, and marked |
||||
with the `RLMSyncErrorDomain` domain. |
||||
|
||||
Errors reported through this mechanism are fatal, with several exceptions. Please consult |
||||
`RLMSyncError` for information about the types of errors that can be reported through |
||||
the block, and for for suggestions on handling recoverable error codes. |
||||
|
||||
@see `RLMSyncError` |
||||
*/ |
||||
@property (nullable, nonatomic, copy) RLMSyncErrorReportingBlock errorHandler; |
||||
|
||||
/**
|
||||
A reverse-DNS string uniquely identifying this application. In most cases this |
||||
is automatically set by the SDK, and does not have to be explicitly configured. |
||||
*/ |
||||
@property (nonatomic, copy) NSString *appID; |
||||
|
||||
/**
|
||||
A string identifying this application which is included in the User-Agent |
||||
header of sync connections. By default, this will be the application's bundle |
||||
identifier. |
||||
|
||||
This property must be set prior to opening a synchronized Realm for the first |
||||
time. Any modifications made after opening a Realm will be ignored. |
||||
*/ |
||||
@property (nonatomic, copy) NSString *userAgent; |
||||
|
||||
/**
|
||||
The logging threshold which newly opened synced Realms will use. Defaults to |
||||
`RLMSyncLogLevelInfo`. |
||||
|
||||
Logging strings are output to Apple System Logger. |
||||
|
||||
@warning This property must be set before any synced Realms are opened. Setting it after |
||||
opening any synced Realm will do nothing. |
||||
*/ |
||||
@property (nonatomic) RLMSyncLogLevel logLevel; |
||||
|
||||
/**
|
||||
The name of the HTTP header to send authorization data in when making requests to a Realm Object Server which has |
||||
been configured to expect a custom authorization header. |
||||
*/ |
||||
@property (nullable, nonatomic, copy) NSString *authorizationHeaderName; |
||||
|
||||
/**
|
||||
Extra HTTP headers to append to every request to a Realm Object Server. |
||||
|
||||
Modifying this property while sync sessions are active will result in all |
||||
sessions disconnecting and reconnecting using the new headers. |
||||
*/ |
||||
@property (nullable, nonatomic, copy) NSDictionary<NSString *, NSString *> *customRequestHeaders; |
||||
|
||||
/**
|
||||
A map of hostname to file URL for pinned certificates to use for HTTPS requests. |
||||
|
||||
When initiating a HTTPS connection to a server, if this dictionary contains an |
||||
entry for the server's hostname, only the certificates stored in the file (or |
||||
any certificates signed by it, if the file contains a CA cert) will be accepted |
||||
when initiating a connection to a server. This prevents certain certain kinds |
||||
of man-in-the-middle (MITM) attacks, and can also be used to trust a self-signed |
||||
certificate which would otherwise be untrusted. |
||||
|
||||
On macOS, the certificate files may be in any of the formats supported by |
||||
SecItemImport(), including PEM and .cer (see SecExternalFormat for a complete |
||||
list of possible formats). On iOS and other platforms, only DER .cer files are |
||||
supported. |
||||
|
||||
For example, to pin example.com to a .cer file included in your bundle: |
||||
|
||||
<pre> |
||||
RLMSyncManager.sharedManager.pinnedCertificatePaths = @{ |
||||
@"example.com": [NSBundle.mainBundle pathForResource:@"example.com" ofType:@"cer"] |
||||
}; |
||||
</pre> |
||||
*/ |
||||
@property (nullable, nonatomic, copy) NSDictionary<NSString *, NSURL *> *pinnedCertificatePaths; |
||||
|
||||
/// The sole instance of the singleton.
|
||||
+ (instancetype)sharedManager NS_REFINED_FOR_SWIFT; |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)init __attribute__((unavailable("RLMSyncManager cannot be created directly"))); |
||||
|
||||
/// :nodoc:
|
||||
+ (instancetype)new __attribute__((unavailable("RLMSyncManager cannot be created directly"))); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
|
||||
@end |
||||
@ -0,0 +1,502 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2017 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMConstants.h> |
||||
#import <Realm/RLMObject.h> |
||||
|
||||
@protocol RLMPermission, RLMPermissionUser; |
||||
@class RLMPermission, RLMPermissionUser, RLMPermissionRole, |
||||
RLMArray<RLMObjectType>, RLMLinkingObjects<RLMObjectType: RLMObject *>; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
A permission which can be applied to a Realm, Class, or specific Object. |
||||
|
||||
Permissions are applied by adding the permission to the RLMRealmPermission singleton |
||||
object, the RLMClassPermission object for the desired class, or to a user-defined |
||||
RLMArray<RLMPermission> property on a specific Object instance. The meaning of each of |
||||
the properties of RLMPermission depend on what the permission is applied to, and so are |
||||
left undocumented here. See `RLMRealmPrivileges`, `RLMClassPrivileges`, and |
||||
`RLMObjectPrivileges` for details about what each of the properties mean when applied to |
||||
that type. |
||||
*/ |
||||
@interface RLMPermission : RLMObject |
||||
/// The Role which this Permission applies to. All users within the Role are
|
||||
/// granted the permissions specified by the fields below any
|
||||
/// objects/classes/realms which use this Permission.
|
||||
///
|
||||
/// This property cannot be modified once set.
|
||||
@property (nonatomic) RLMPermissionRole *role; |
||||
|
||||
/// Whether the user can read the object to which this Permission is attached.
|
||||
@property (nonatomic) bool canRead; |
||||
/// Whether the user can modify the object to which this Permission is attached.
|
||||
@property (nonatomic) bool canUpdate; |
||||
/// Whether the user can delete the object to which this Permission is attached.
|
||||
///
|
||||
/// This field is only applicable to Permissions attached to Objects, and not
|
||||
/// to Realms or Classes.
|
||||
@property (nonatomic) bool canDelete; |
||||
/// Whether the user can add or modify Permissions for the object which this
|
||||
/// Permission is attached to.
|
||||
@property (nonatomic) bool canSetPermissions; |
||||
/// Whether the user can subscribe to queries for this object type.
|
||||
///
|
||||
/// This field is only applicable to Permissions attached to Classes, and not
|
||||
/// to Realms or Objects.
|
||||
@property (nonatomic) bool canQuery; |
||||
/// Whether the user can create new objects of the type this Permission is attached to.
|
||||
///
|
||||
/// This field is only applicable to Permissions attached to Classes, and not
|
||||
/// to Realms or Objects.
|
||||
@property (nonatomic) bool canCreate; |
||||
/// Whether the user can modify the schema of the Realm which this
|
||||
/// Permission is attached to.
|
||||
///
|
||||
/// This field is only applicable to Permissions attached to Realms, and not
|
||||
/// to Realms or Objects.
|
||||
@property (nonatomic) bool canModifySchema; |
||||
|
||||
/**
|
||||
Returns the Permission object for the named Role in the array, creating it if needed. |
||||
|
||||
This function should be used in preference to manually querying the array for |
||||
the applicable Permission as it ensures that there is exactly one Permission |
||||
for the given Role in the array, merging duplicates or creating and adding new |
||||
ones as needed. |
||||
*/ |
||||
+ (RLMPermission *)permissionForRoleNamed:(NSString *)roleName inArray:(RLMArray<RLMPermission *><RLMPermission> *)array; |
||||
|
||||
/**
|
||||
Returns the Permission object for the named Role on the Realm, creating it if needed. |
||||
|
||||
This function should be used in preference to manually querying for the |
||||
applicable Permission as it ensures that there is exactly one Permission for |
||||
the given Role on the Realm, merging duplicates or creating and adding new ones |
||||
as needed. |
||||
*/ |
||||
+ (RLMPermission *)permissionForRoleNamed:(NSString *)roleName onRealm:(RLMRealm *)realm; |
||||
|
||||
/**
|
||||
Returns the Permission object for the named Role on the Class, creating it if needed. |
||||
|
||||
This function should be used in preference to manually querying for the |
||||
applicable Permission as it ensures that there is exactly one Permission for |
||||
the given Role on the Class, merging duplicates or creating and adding new ones |
||||
as needed. |
||||
*/ |
||||
+ (RLMPermission *)permissionForRoleNamed:(NSString *)roleName onClass:(Class)cls realm:(RLMRealm *)realm; |
||||
|
||||
/**
|
||||
Returns the Permission object for the named Role on the named class, creating it if needed. |
||||
|
||||
This function should be used in preference to manually querying for the |
||||
applicable Permission as it ensures that there is exactly one Permission for |
||||
the given Role on the Class, merging duplicates or creating and adding new ones |
||||
as needed. |
||||
*/ |
||||
+ (RLMPermission *)permissionForRoleNamed:(NSString *)roleName onClassNamed:(NSString *)className realm:(RLMRealm *)realm; |
||||
|
||||
/**
|
||||
Returns the Permission object for the named Role on the object, creating it if needed. |
||||
|
||||
This function should be used in preference to manually querying for the |
||||
applicable Permission as it ensures that there is exactly one Permission for |
||||
the given Role on the Realm, merging duplicates or creating and adding new ones |
||||
as needed. |
||||
|
||||
The given object must have a RLMArray<RLMPermission> property defined on it. If |
||||
more than one such property is present, the first will be used. |
||||
*/ |
||||
+ (RLMPermission *)permissionForRoleNamed:(NSString *)roleName onObject:(RLMObject *)object; |
||||
@end |
||||
|
||||
/**
|
||||
A Role within the permissions system. |
||||
|
||||
A Role consists of a name for the role and a list of users which are members of the role. |
||||
Roles are granted privileges on Realms, Classes and Objects, and in turn grant those |
||||
privileges to all users which are members of the role. |
||||
|
||||
A role named "everyone" is automatically created in new Realms, and all new users which |
||||
connect to the Realm are automatically added to it. Any other roles you wish to use are |
||||
managed as normal Realm objects. |
||||
*/ |
||||
@interface RLMPermissionRole : RLMObject |
||||
/// The name of the Role
|
||||
@property (nonatomic) NSString *name; |
||||
/// The users which belong to the role
|
||||
@property (nonatomic) RLMArray<RLMPermissionUser *><RLMPermissionUser> *users; |
||||
@end |
||||
|
||||
/**
|
||||
A representation of a sync user within the permissions system. |
||||
|
||||
RLMPermissionUser objects are created automatically for each sync user which connects to |
||||
a Realm, and can also be created manually if you wish to grant permissions to a user |
||||
which has not yet connected to this Realm. |
||||
*/ |
||||
@interface RLMPermissionUser : RLMObject |
||||
/// The unique Realm Object Server user ID string identifying this user. This will have
|
||||
/// the same value as `-[RLMSyncUser identity]`.
|
||||
@property (nonatomic) NSString *identity; |
||||
|
||||
/// The user's private role. This will be initialized to a role named for the user's
|
||||
/// identity that contains this user as its only member.
|
||||
@property (nonatomic) RLMPermissionRole *role; |
||||
|
||||
/// Roles which this user belongs to.
|
||||
@property (nonatomic, readonly) RLMLinkingObjects<RLMPermissionRole *> *roles; |
||||
|
||||
/// Get the user object in the given Realm, creating it if needed.
|
||||
+ (RLMPermissionUser *)userInRealm:(RLMRealm *)realm withIdentity:(NSString *)identity; |
||||
@end |
||||
|
||||
/**
|
||||
A singleton object which describes Realm-wide permissions. |
||||
|
||||
An object of this type is automatically created in the Realm for you, and more objects |
||||
cannot be created manually. Call `+[RLMRealmPermission objectInRealm:]` to obtain the |
||||
instance for a specific Realm. |
||||
|
||||
See `RLMRealmPrivileges` for the meaning of permissions applied to a Realm. |
||||
*/ |
||||
@interface RLMRealmPermission : RLMObject |
||||
/// The permissions for the Realm.
|
||||
@property (nonatomic) RLMArray<RLMPermission *><RLMPermission> *permissions; |
||||
|
||||
/// Retrieve the singleton object for the given Realm. This will return `nil`
|
||||
/// for non-partial-sync Realms.
|
||||
+ (nullable instancetype)objectInRealm:(RLMRealm *)realm; |
||||
@end |
||||
|
||||
/**
|
||||
An object which describes class-wide permissions. |
||||
|
||||
An instance of this object is automatically created in the Realm for class in your schema, |
||||
and should not be created manually. Call `+[RLMClassPermission objectInRealm:forClassNamed:]` |
||||
or `+[RLMClassPermission objectInRealm:forClass:]` to obtain the existing instance, or |
||||
query `RLMClassPermission` as normal. |
||||
*/ |
||||
@interface RLMClassPermission : RLMObject |
||||
/// The name of the class which these permissions apply to.
|
||||
@property (nonatomic) NSString *name; |
||||
/// The permissions for this class.
|
||||
@property (nonatomic) RLMArray<RLMPermission *><RLMPermission> *permissions; |
||||
|
||||
/// Retrieve the object for the named RLMObject subclass. This will return `nil`
|
||||
/// for non-partial-sync Realms.
|
||||
+ (nullable instancetype)objectInRealm:(RLMRealm *)realm forClassNamed:(NSString *)className; |
||||
/// Retrieve the object for the given RLMObject subclass. This will return `nil`
|
||||
/// for non-partial-sync Realms.
|
||||
+ (nullable instancetype)objectInRealm:(RLMRealm *)realm forClass:(Class)cls; |
||||
@end |
||||
|
||||
/**
|
||||
A description of the actual privileges which apply to a Realm. |
||||
|
||||
This is a combination of all of the privileges granted to all of the Roles which the |
||||
current User is a member of, obtained by calling `-[RLMRealm privilegesForRealm]` on |
||||
the Realm. |
||||
|
||||
By default, all operations are permitted, and each privilege field indicates an operation |
||||
which may be forbidden. |
||||
*/ |
||||
struct RLMRealmPrivileges { |
||||
/// If `false`, the current User is not permitted to see the Realm at all. This can
|
||||
/// happen only if the Realm was created locally and has not yet been synchronized.
|
||||
bool read : 1; |
||||
|
||||
/// If `false`, no modifications to the Realm are permitted. Write transactions can
|
||||
/// be performed locally, but any changes made will be reverted by the server.
|
||||
/// `setPermissions` and `modifySchema` will always be `false` when this is `false`.
|
||||
bool update : 1; |
||||
|
||||
/// If `false`, no modifications to the permissions property of the RLMRealmPermissions
|
||||
/// object for are permitted. Write transactions can be performed locally, but any
|
||||
/// changes made will be reverted by the server.
|
||||
///
|
||||
/// Note that if invalide privilege changes are made, `-[RLMRealm privilegesFor*:]`
|
||||
/// will return results reflecting those invalid changes until synchronization occurs.
|
||||
///
|
||||
/// Even if this field is `true`, note that the user will be unable to grant
|
||||
/// privileges to a Role which they do not themselves have.
|
||||
///
|
||||
/// Adding or removing Users from a Role is controlled by Update privileges on that
|
||||
/// Role, and not by this value.
|
||||
bool setPermissions : 1; |
||||
|
||||
/// If `false`, the user is not permitted to add new object types to the Realm or add
|
||||
/// new properties to existing objec types. Defining new RLMObject subclasses (and not
|
||||
/// excluding them from the schema with `-[RLMRealmConfiguration setObjectClasses:]`)
|
||||
/// will result in the application crashing if the object types are not first added on
|
||||
/// the server by a more privileged user.
|
||||
bool modifySchema : 1; |
||||
}; |
||||
|
||||
/**
|
||||
A description of the actual privileges which apply to a Class within a Realm. |
||||
|
||||
This is a combination of all of the privileges granted to all of the Roles which the |
||||
current User is a member of, obtained by calling `-[RLMRealm privilegesForClass:]` or |
||||
`-[RLMRealm privilegesForClassNamed:]` on the Realm. |
||||
|
||||
By default, all operations are permitted, and each privilege field indicates an operation |
||||
which may be forbidden. |
||||
*/ |
||||
struct RLMClassPrivileges { |
||||
/// If `false`, the current User is not permitted to see objects of this type, and
|
||||
/// attempting to query this class will always return empty results.
|
||||
///
|
||||
/// Note that Read permissions are transitive, and so it may be possible to read an
|
||||
/// object which the user does not directly have Read permissions for by following a
|
||||
/// link to it from an object they do have Read permissions for. This does not apply
|
||||
/// to any of the other permission types.
|
||||
bool read : 1; |
||||
|
||||
/// If `false`, creating new objects of this type is not permitted. Write transactions
|
||||
/// creating objects can be performed locally, but the objects will be deleted by the
|
||||
/// server when synchronization occurs.
|
||||
///
|
||||
/// For objects with Primary Keys, it may not be locally determinable if Create or
|
||||
/// Update privileges are applicable. It may appear that you are creating a new object,
|
||||
/// but an object with that Primary Key may already exist and simply not be visible to
|
||||
/// you, in which case it is actually an Update operation.
|
||||
bool create : 1; |
||||
|
||||
/// If `false`, no modifications to objects of this type are permitted. Write
|
||||
/// transactions modifying the objects can be performed locally, but any changes made
|
||||
/// will be reverted by the server.
|
||||
///
|
||||
/// Deleting an object is considered a modification, and is governed by this privilege.
|
||||
bool update : 1; |
||||
|
||||
/// If `false`, the User is not permitted to create new subscriptions for this class.
|
||||
/// Local queries against the objects within the Realm will work, but new
|
||||
/// subscriptions will never add objects to the Realm.
|
||||
bool subscribe : 1; |
||||
|
||||
/// If `false`, no modifications to the permissions property of the RLMClassPermissions
|
||||
/// object for this type are permitted. Write transactions can be performed locally,
|
||||
/// but any changes made will be reverted by the server.
|
||||
///
|
||||
/// Note that if invalid privilege changes are made, `-[RLMRealm privilegesFor*:]`
|
||||
/// will return results reflecting those invalid changes until synchronization occurs.
|
||||
///
|
||||
/// Even if this field is `true`, note that the user will be unable to grant
|
||||
/// privileges to a Role which they do not themselves have.
|
||||
bool setPermissions : 1; |
||||
}; |
||||
|
||||
/**
|
||||
A description of the actual privileges which apply to a specific RLMObject. |
||||
|
||||
This is a combination of all of the privileges granted to all of the Roles which the |
||||
current User is a member of, obtained by calling `-[RLMRealm privilegesForObject:]` on |
||||
the Realm. |
||||
|
||||
By default, all operations are permitted, and each privilege field indicates an operation |
||||
which may be forbidden. |
||||
*/ |
||||
struct RLMObjectPrivileges { |
||||
/// If `false`, the current User is not permitted to read this object directly.
|
||||
///
|
||||
/// Objects which cannot be read by a user will appear in a Realm due to that read
|
||||
/// permissions are transitive. All objects which a readable object links to are
|
||||
/// themselves implicitly readable. If the link to an object with `read=false` is
|
||||
/// removed, the object will be deleted from the local Realm.
|
||||
bool read : 1; |
||||
|
||||
/// If `false`, modifying the fields of this type is not permitted. Write
|
||||
/// transactions modifying the objects can be performed locally, but any changes made
|
||||
/// will be reverted by the server.
|
||||
///
|
||||
/// Note that even if this is `true`, the user may not be able to modify the
|
||||
/// `RLMArray<RLMPermission> *` property of the object (if it exists), as that is
|
||||
/// governed by `setPermissions`.
|
||||
bool update : 1; |
||||
|
||||
/// If `false`, deleting this object is not permitted. Write transactions which delete
|
||||
/// the object can be performed locally, but the server will restore it.
|
||||
///
|
||||
/// It is possible to have `update` but not `delete` privileges, or vice versa. For
|
||||
/// objects with primary keys, `delete` but not `update` is ill-advised, as an object
|
||||
/// can be updated by deleting and recreating it.
|
||||
bool del : 1; |
||||
|
||||
/// If `false`, modifying the privileges of this specific object is not permitted.
|
||||
///
|
||||
/// Object-specific permissions are set by declaring a `RLMArray<RLMPermission> *`
|
||||
/// property on the `RLMObject` subclass. Modifications to this property are
|
||||
/// controlled by `setPermissions` rather than `update`.
|
||||
///
|
||||
/// Even if this field is `true`, note that the user will be unable to grant
|
||||
/// privileges to a Role which they do not themselves have.
|
||||
bool setPermissions : 1; |
||||
}; |
||||
|
||||
/// :nodoc:
|
||||
FOUNDATION_EXTERN id RLMPermissionForRole(RLMArray *array, id role); |
||||
|
||||
/**
|
||||
Access levels which can be granted to Realm Mobile Platform users |
||||
for specific synchronized Realms, using the permissions APIs. |
||||
|
||||
Note that each access level guarantees all allowed actions provided |
||||
by less permissive access levels. Specifically, users with write |
||||
access to a Realm can always read from that Realm, and users with |
||||
administrative access can always read or write from the Realm. |
||||
*/ |
||||
typedef RLM_CLOSED_ENUM(NSUInteger, RLMSyncAccessLevel) { |
||||
/// No access whatsoever.
|
||||
RLMSyncAccessLevelNone = 0, |
||||
/**
|
||||
User can only read the contents of the Realm. |
||||
|
||||
@warning Users who have read-only access to a Realm should open the |
||||
Realm using `+[RLMRealm asyncOpenWithConfiguration:callbackQueue:callback:]`. |
||||
Attempting to directly open the Realm is an error; in this |
||||
case the Realm must be deleted and re-opened. |
||||
*/ |
||||
RLMSyncAccessLevelRead = 1, |
||||
/// User can read and write the contents of the Realm.
|
||||
RLMSyncAccessLevelWrite = 2, |
||||
/// User can read, write, and administer the Realm, including
|
||||
/// granting permissions to other users.
|
||||
RLMSyncAccessLevelAdmin = 3, |
||||
}; |
||||
|
||||
/**
|
||||
A property on which a `RLMResults<RLMSyncPermission *>` can be queried or filtered. |
||||
|
||||
@warning If building `NSPredicate`s using format strings including these string |
||||
constants, use %K instead of %@ as the substitution parameter. |
||||
*/ |
||||
typedef NSString * RLMSyncPermissionSortProperty NS_STRING_ENUM; |
||||
|
||||
/// Sort by the Realm Object Server path to the Realm to which the permission applies.
|
||||
extern RLMSyncPermissionSortProperty const RLMSyncPermissionSortPropertyPath; |
||||
/// Sort by the identity of the user to whom the permission applies.
|
||||
extern RLMSyncPermissionSortProperty const RLMSyncPermissionSortPropertyUserID; |
||||
/// Sort by the date the permissions were last updated.
|
||||
extern RLMSyncPermissionSortProperty const RLMSyncPermissionSortPropertyUpdated; |
||||
|
||||
/**
|
||||
A value representing a permission granted to the specified user(s) to access the specified Realm(s). |
||||
|
||||
`RLMSyncPermission` is immutable and can be accessed from any thread. |
||||
|
||||
See https://realm.io/docs/realm-object-server/#permissions for general documentation.
|
||||
*/ |
||||
@interface RLMSyncPermission : NSObject |
||||
|
||||
/**
|
||||
The Realm Object Server path to the Realm to which this permission applies (e.g. "/path/to/realm"). |
||||
|
||||
Specify "*" if this permission applies to all Realms managed by the server. |
||||
*/ |
||||
@property (nonatomic, readonly) NSString *path; |
||||
|
||||
/**
|
||||
The access level described by this permission. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSyncAccessLevel accessLevel; |
||||
|
||||
/// Whether the access level allows the user to read from the Realm.
|
||||
@property (nonatomic, readonly) BOOL mayRead; |
||||
|
||||
/// Whether the access level allows the user to write to the Realm.
|
||||
@property (nonatomic, readonly) BOOL mayWrite; |
||||
|
||||
/// Whether the access level allows the user to administer the Realm.
|
||||
@property (nonatomic, readonly) BOOL mayManage; |
||||
|
||||
/**
|
||||
Create a new sync permission value, for use with permission APIs. |
||||
|
||||
@param path The Realm Object Server path to the Realm whose permission should be modified |
||||
(e.g. "/path/to/realm"). Pass "*" to apply to all Realms managed by the user. |
||||
@param identity The Realm Object Server identity of the user who should be granted access to |
||||
the Realm at `path`. |
||||
Pass "*" to apply to all users managed by the server. |
||||
@param accessLevel The access level to grant. |
||||
*/ |
||||
- (instancetype)initWithRealmPath:(NSString *)path |
||||
identity:(NSString *)identity |
||||
accessLevel:(RLMSyncAccessLevel)accessLevel; |
||||
|
||||
/**
|
||||
Create a new sync permission value, for use with permission APIs. |
||||
|
||||
@param path The Realm Object Server path to the Realm whose permission should be modified |
||||
(e.g. "/path/to/realm"). Pass "*" to apply to all Realms managed by the user. |
||||
@param username The username (often an email address) of the user who should be granted access |
||||
to the Realm at `path`. |
||||
@param accessLevel The access level to grant. |
||||
*/ |
||||
- (instancetype)initWithRealmPath:(NSString *)path |
||||
username:(NSString *)username |
||||
accessLevel:(RLMSyncAccessLevel)accessLevel; |
||||
|
||||
/**
|
||||
The identity of the user to whom this permission is granted, or "*" |
||||
if all users are granted this permission. Nil if the permission is |
||||
defined in terms of a key-value pair. |
||||
*/ |
||||
@property (nullable, nonatomic, readonly) NSString *identity; |
||||
|
||||
/**
|
||||
If the permission is defined in terms of a key-value pair, the key |
||||
describing the type of criterion used to determine what users the |
||||
permission applies to. Otherwise, nil. |
||||
*/ |
||||
@property (nullable, nonatomic, readonly) NSString *key; |
||||
|
||||
/**
|
||||
If the permission is defined in terms of a key-value pair, a string |
||||
describing the criterion value used to determine what users the |
||||
permission applies to. Otherwise, nil. |
||||
*/ |
||||
@property (nullable, nonatomic, readonly) NSString *value; |
||||
|
||||
/**
|
||||
When this permission was last updated. |
||||
*/ |
||||
@property (nonatomic, readonly) NSDate *updatedAt; |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)init __attribute__((unavailable("Use the designated initializer"))); |
||||
|
||||
/// :nodoc:
|
||||
+ (instancetype)new __attribute__((unavailable("Use the designated initializer"))); |
||||
|
||||
// MARK: - Migration assistance
|
||||
|
||||
/// :nodoc:
|
||||
@property (nullable, nonatomic, readonly) NSString *userId __attribute__((unavailable("Renamed to `identity`"))); |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)initWithRealmPath:(NSString *)path |
||||
userID:(NSString *)identity |
||||
accessLevel:(RLMSyncAccessLevel)accessLevel |
||||
__attribute__((unavailable("Renamed to `-initWithRealmPath:identity:accessLevel:`"))); |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,236 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import "RLMRealm.h" |
||||
|
||||
/**
|
||||
The current state of the session represented by a session object. |
||||
*/ |
||||
typedef NS_ENUM(NSUInteger, RLMSyncSessionState) { |
||||
/// The sync session is actively communicating or attempting to communicate
|
||||
/// with the Realm Object Server. A session is considered Active even if
|
||||
/// it is not currently connected. Check the connection state instead if you
|
||||
/// wish to know if the connection is currently online.
|
||||
RLMSyncSessionStateActive, |
||||
/// The sync session is not attempting to communicate with the Realm Object
|
||||
/// Server, due to the user logging out or synchronization being paused.
|
||||
RLMSyncSessionStateInactive, |
||||
/// The sync session encountered a fatal error and is permanently invalid; it should be discarded.
|
||||
RLMSyncSessionStateInvalid |
||||
}; |
||||
|
||||
/**
|
||||
The current state of a sync session's connection. Sessions which are not in |
||||
the Active state will always be Disconnected. |
||||
*/ |
||||
typedef NS_ENUM(NSUInteger, RLMSyncConnectionState) { |
||||
/// The sync session is not connected to the server, and is not attempting
|
||||
/// to connect, either because the session is inactive or because it is
|
||||
/// waiting to retry after a failed connection.
|
||||
RLMSyncConnectionStateDisconnected, |
||||
/// The sync session is attempting to connect to the Realm Object Server.
|
||||
RLMSyncConnectionStateConnecting, |
||||
/// The sync session is currently connected to the Realm Object Server.
|
||||
RLMSyncConnectionStateConnected, |
||||
}; |
||||
|
||||
/**
|
||||
The transfer direction (upload or download) tracked by a given progress notification block. |
||||
|
||||
Progress notification blocks can be registered on sessions if your app wishes to be informed |
||||
how many bytes have been uploaded or downloaded, for example to show progress indicator UIs. |
||||
*/ |
||||
typedef RLM_CLOSED_ENUM(NSUInteger, RLMSyncProgressDirection) { |
||||
/// For monitoring upload progress.
|
||||
RLMSyncProgressDirectionUpload, |
||||
/// For monitoring download progress.
|
||||
RLMSyncProgressDirectionDownload, |
||||
}; |
||||
|
||||
/**
|
||||
The desired behavior of a progress notification block. |
||||
|
||||
Progress notification blocks can be registered on sessions if your app wishes to be informed |
||||
how many bytes have been uploaded or downloaded, for example to show progress indicator UIs. |
||||
*/ |
||||
typedef NS_ENUM(NSUInteger, RLMSyncProgressMode) { |
||||
/**
|
||||
The block will be called indefinitely, or until it is unregistered by calling |
||||
`-[RLMProgressNotificationToken invalidate]`. |
||||
|
||||
Notifications will always report the latest number of transferred bytes, and the |
||||
most up-to-date number of total transferrable bytes. |
||||
*/ |
||||
RLMSyncProgressModeReportIndefinitely, |
||||
/**
|
||||
The block will, upon registration, store the total number of bytes |
||||
to be transferred. When invoked, it will always report the most up-to-date number |
||||
of transferrable bytes out of that original number of transferrable bytes. |
||||
|
||||
When the number of transferred bytes reaches or exceeds the |
||||
number of transferrable bytes, the block will be unregistered. |
||||
*/ |
||||
RLMSyncProgressModeForCurrentlyOutstandingWork, |
||||
}; |
||||
|
||||
@class RLMSyncUser, RLMSyncConfiguration, RLMSyncErrorActionToken; |
||||
|
||||
/**
|
||||
The type of a progress notification block intended for reporting a session's network |
||||
activity to the user. |
||||
|
||||
`transferredBytes` refers to the number of bytes that have been uploaded or downloaded. |
||||
`transferrableBytes` refers to the total number of bytes transferred, and pending transfer. |
||||
*/ |
||||
typedef void(^RLMProgressNotificationBlock)(NSUInteger transferredBytes, NSUInteger transferrableBytes); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
A token object corresponding to a progress notification block on a session object. |
||||
|
||||
To stop notifications manually, call `-invalidate` on it. Notifications should be stopped before |
||||
the token goes out of scope or is destroyed. |
||||
*/ |
||||
@interface RLMProgressNotificationToken : RLMNotificationToken |
||||
@end |
||||
|
||||
/**
|
||||
An object encapsulating a Realm Object Server "session". Sessions represent the |
||||
communication between the client (and a local Realm file on disk), and the server |
||||
(and a remote Realm at a given URL stored on a Realm Object Server). |
||||
|
||||
Sessions are always created by the SDK and vended out through various APIs. The |
||||
lifespans of sessions associated with Realms are managed automatically. Session |
||||
objects can be accessed from any thread. |
||||
*/ |
||||
@interface RLMSyncSession : NSObject |
||||
|
||||
/// The session's current state.
|
||||
///
|
||||
/// This property is not KVO-compliant.
|
||||
@property (nonatomic, readonly) RLMSyncSessionState state; |
||||
|
||||
/// The session's current connection state.
|
||||
///
|
||||
/// This property is KVO-compliant and can be observed to be notified of changes.
|
||||
/// Be warned that KVO observers for this property may be called on a background
|
||||
/// thread.
|
||||
@property (atomic, readonly) RLMSyncConnectionState connectionState; |
||||
|
||||
/// The Realm Object Server URL of the remote Realm this session corresponds to.
|
||||
@property (nullable, nonatomic, readonly) NSURL *realmURL; |
||||
|
||||
/// The user that owns this session.
|
||||
- (nullable RLMSyncUser *)parentUser; |
||||
|
||||
/**
|
||||
If the session is valid, return a sync configuration that can be used to open the Realm |
||||
associated with this session. |
||||
*/ |
||||
- (nullable RLMSyncConfiguration *)configuration; |
||||
|
||||
/**
|
||||
Temporarily suspend syncronization and disconnect from the server. |
||||
|
||||
The session will not attempt to connect to Realm Object Server until `resume` |
||||
is called or the Realm file is closed and re-opened. |
||||
*/ |
||||
- (void)suspend; |
||||
|
||||
/**
|
||||
Resume syncronization and reconnect to Realm Object Server after suspending. |
||||
|
||||
This is a no-op if the session was already active or if the session is invalid. |
||||
Newly created sessions begin in the Active state and do not need to be resumed. |
||||
*/ |
||||
- (void)resume; |
||||
|
||||
/**
|
||||
Register a progress notification block. |
||||
|
||||
Multiple blocks can be registered with the same session at once. Each block |
||||
will be invoked on a side queue devoted to progress notifications. |
||||
|
||||
If the session has already received progress information from the |
||||
synchronization subsystem, the block will be called immediately. Otherwise, it |
||||
will be called as soon as progress information becomes available. |
||||
|
||||
The token returned by this method must be retained as long as progress |
||||
notifications are desired, and the `-invalidate` method should be called on it |
||||
when notifications are no longer needed and before the token is destroyed. |
||||
|
||||
If no token is returned, the notification block will never be called again. |
||||
There are a number of reasons this might be true. If the session has previously |
||||
experienced a fatal error it will not accept progress notification blocks. If |
||||
the block was configured in the `RLMSyncProgressForCurrentlyOutstandingWork` |
||||
mode but there is no additional progress to report (for example, the number |
||||
of transferrable bytes and transferred bytes are equal), the block will not be |
||||
called again. |
||||
|
||||
@param direction The transfer direction (upload or download) to track in this progress notification block. |
||||
@param mode The desired behavior of this progress notification block. |
||||
@param block The block to invoke when notifications are available. |
||||
|
||||
@return A token which must be held for as long as you want notifications to be delivered. |
||||
|
||||
@see `RLMSyncProgressDirection`, `RLMSyncProgress`, `RLMProgressNotificationBlock`, `RLMProgressNotificationToken` |
||||
*/ |
||||
- (nullable RLMProgressNotificationToken *)addProgressNotificationForDirection:(RLMSyncProgressDirection)direction |
||||
mode:(RLMSyncProgressMode)mode |
||||
block:(RLMProgressNotificationBlock)block |
||||
NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Given an error action token, immediately handle the corresponding action. |
||||
|
||||
@see `RLMSyncErrorClientResetError`, `RLMSyncErrorPermissionDeniedError` |
||||
*/ |
||||
+ (void)immediatelyHandleError:(RLMSyncErrorActionToken *)token; |
||||
|
||||
/**
|
||||
Get the sync session for the given Realm if it is a synchronized Realm, or `nil` |
||||
if it is not. |
||||
*/ |
||||
+ (nullable RLMSyncSession *)sessionForRealm:(RLMRealm *)realm; |
||||
|
||||
@end |
||||
|
||||
// MARK: - Error action token
|
||||
|
||||
#pragma mark - Error action token |
||||
|
||||
/**
|
||||
An opaque token returned as part of certain errors. It can be |
||||
passed into certain APIs to perform certain actions. |
||||
|
||||
@see `RLMSyncErrorClientResetError`, `RLMSyncErrorPermissionDeniedError` |
||||
*/ |
||||
@interface RLMSyncErrorActionToken : NSObject |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)init __attribute__((unavailable("This type cannot be created directly"))); |
||||
|
||||
/// :nodoc:
|
||||
+ (instancetype)new __attribute__((unavailable("This type cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,416 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2018 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMRealm.h> |
||||
#import <Realm/RLMResults.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
`RLMSyncSubscriptionState` is an enumeration representing the possible state of a sync subscription. |
||||
*/ |
||||
typedef RLM_CLOSED_ENUM(NSInteger, RLMSyncSubscriptionState) { |
||||
/**
|
||||
An error occurred while creating the subscription or while the server was processing it. |
||||
*/ |
||||
RLMSyncSubscriptionStateError = -1, |
||||
|
||||
/**
|
||||
The subscription is being created, but has not yet been written to the synced Realm. |
||||
*/ |
||||
RLMSyncSubscriptionStateCreating = 2, |
||||
|
||||
/**
|
||||
The subscription has been created, and is waiting to be processed by the server. |
||||
*/ |
||||
RLMSyncSubscriptionStatePending = 0, |
||||
|
||||
/**
|
||||
The subscription has been processed by the server, and objects matching the subscription |
||||
are now being synchronized to this client. |
||||
*/ |
||||
RLMSyncSubscriptionStateComplete = 1, |
||||
|
||||
/**
|
||||
This subscription has been removed. |
||||
*/ |
||||
RLMSyncSubscriptionStateInvalidated = 3, |
||||
}; |
||||
|
||||
/**
|
||||
`RLMSyncSubscription` represents a subscription to a set of objects in a synced Realm. |
||||
|
||||
When query-based sync is enabled for a synchronized Realm, the server only |
||||
synchronizes objects to the client when they match a sync subscription |
||||
registered by that client. A subscription consists of of a query (represented |
||||
by an `RLMResults`) and an optional name. |
||||
|
||||
The state of the subscription can be observed using |
||||
[Key-Value Observing](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html)
|
||||
on the `state` property. |
||||
|
||||
Subscriptions are created using `-[RLMResults subscribe]` or |
||||
`-[RLMResults subscribeWithName:]`. Existing subscriptions for a Realm can be |
||||
looked up with `-[RLMRealm subscriptions]` or `-[RLMRealm subscriptionWithName:]`. |
||||
*/ |
||||
@interface RLMSyncSubscription : NSObject |
||||
|
||||
/**
|
||||
The unique name for this subscription. |
||||
|
||||
This will be `nil` if this object was created with `-[RLMResults subscribe]`. |
||||
Subscription objects read from a Realm with `-[RLMRealm subscriptions]` will |
||||
always have a non-`nil` name and subscriptions which were not explicitly named |
||||
will have an automatically generated one. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) NSString *name; |
||||
|
||||
/**
|
||||
The current state of the subscription. See `RLMSyncSubscriptionState`. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSyncSubscriptionState state; |
||||
|
||||
/**
|
||||
The error which occurred when registering this subscription, if any. |
||||
|
||||
Will be non-nil only when `state` is `RLMSyncSubscriptionStateError`. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) NSError *error; |
||||
|
||||
/**
|
||||
The raw query which this subscription is running on the server. |
||||
|
||||
This string is a serialized representation of the RLMResults which the |
||||
subscription was created from. This representation does *not* use NSPredicate |
||||
syntax, and is not guaranteed to remain consistent between versions of Realm. |
||||
Any use of this other than manual inspection when debugging is likely to be |
||||
incorrect. |
||||
|
||||
This is `nil` while the subscription is in the Creating state. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) NSString *query; |
||||
|
||||
/**
|
||||
When this subscription was first created. |
||||
|
||||
This value will be `nil` for subscriptions created with older versions of Realm |
||||
which did not store the creation date. Newly created subscriptions should |
||||
always have a non-nil creation date. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) NSDate *createdAt; |
||||
|
||||
/**
|
||||
When this subscription was last updated. |
||||
|
||||
This value will be `nil` for subscriptions created with older versions of Realm |
||||
which did not store the update date. Newly created subscriptions should |
||||
always have a non-nil update date. |
||||
|
||||
The update date is the time when the subscription was last updated by a call |
||||
to `-[RLMResults subscribeWithOptions:]`, and not when the set of objects which |
||||
match the subscription last changed. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) NSDate *updatedAt; |
||||
|
||||
/**
|
||||
When this subscription will be automatically removed. |
||||
|
||||
If the `timeToLive` parameter is set when creating a sync subscription, the |
||||
subscription will be automatically removed the first time that any subscription |
||||
is created, modified, or deleted after that time has elapsed. |
||||
|
||||
This property will be `nil` if the `timeToLive` option was not enabled. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) NSDate *expiresAt; |
||||
|
||||
/**
|
||||
How long this subscription will persist after last being updated. |
||||
|
||||
If the `timeToLive` parameter is set when creating a sync subscription, the |
||||
subscription will be automatically removed the first time that any subscription |
||||
is created, modified, or deleted after that time has elapsed. |
||||
|
||||
This property will be NaN if the `timeToLive` option was not enabled. |
||||
*/ |
||||
@property (nonatomic, readonly) NSTimeInterval timeToLive; |
||||
|
||||
/**
|
||||
Remove this subscription. |
||||
|
||||
Removing a subscription will delete all objects from the local Realm that were |
||||
matched only by that subscription and not any remaining subscriptions. The |
||||
deletion is performed by the server, and so has no immediate impact on the |
||||
contents of the local Realm. If the device is currently offline, the removal |
||||
will not be processed until the device returns online. |
||||
|
||||
Unsubscribing is an asynchronous operation and will not immediately remove the |
||||
subscription from the Realm's list of subscriptions. Observe the state property |
||||
to be notified of when the subscription has actually been removed. |
||||
*/ |
||||
- (void)unsubscribe; |
||||
|
||||
#pragma mark - Unavailable Methods |
||||
|
||||
/**
|
||||
`-[RLMSyncSubscription init]` is not available because `RLMSyncSubscription` cannot be created directly. |
||||
*/ |
||||
- (instancetype)init __attribute__((unavailable("RLMSyncSubscription cannot be created directly"))); |
||||
|
||||
/**
|
||||
`+[RLMSyncSubscription new]` is not available because `RLMSyncSubscription` cannot be created directly. |
||||
*/ |
||||
+ (instancetype)new __attribute__((unavailable("RLMSyncSubscription cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
Configuration options for query-based sync subscriptions. |
||||
*/ |
||||
@interface RLMSyncSubscriptionOptions : NSObject |
||||
/**
|
||||
The name of the subscription. |
||||
|
||||
Naming a subscription makes it possible to look up a subscription by name |
||||
(using `-[RLMRealm subscriptionWithName:]`) or update an existing |
||||
subscription rather than creating a new one. |
||||
*/ |
||||
@property (nonatomic, copy, nullable) NSString *name; |
||||
|
||||
/**
|
||||
Whether this should update an existing subscription with the same name. |
||||
|
||||
By default trying to create a subscription with a name that's already in use |
||||
will fail unless the new subscription is an exact match for the existing one. |
||||
If this is set to YES, instead the existing subscription will be updated using |
||||
the query and options from the new subscription. This only works if the new |
||||
subscription is for the same type of objects as the existing subscription. |
||||
Trying to overwrite a subscription with a subscription of a different type of |
||||
objects will fail. |
||||
|
||||
The `updatedAt` and (if `timeToLive` is used) `expiresAt` properties are |
||||
updated whenever a subscription is overwritten even if nothing else has changed. |
||||
*/ |
||||
@property (nonatomic) BOOL overwriteExisting; |
||||
|
||||
/**
|
||||
How long (in seconds) a subscription should persist after being created. |
||||
|
||||
By default subscriptions are persistent, and last until they are explicitly |
||||
removed by calling `unsubscribe()`. Subscriptions can instead be made temporary |
||||
by setting the time to live to how long the subscription should remain. After |
||||
that time has elapsed the subscription will be automatically removed. |
||||
|
||||
A time to live of 0 or less disables subscription expiration. |
||||
*/ |
||||
@property (nonatomic) NSTimeInterval timeToLive; |
||||
|
||||
/**
|
||||
The maximum number of top-level matches to include in this subscription. |
||||
|
||||
If more top-level objects than the limit match the query, only the first |
||||
`limit` objects will be included. This respects the sort and distinct order of |
||||
the query being subscribed to for the determination of what the "first" objects |
||||
are. |
||||
|
||||
The limit does not count or apply to objects which are added indirectly due to |
||||
being linked to by the objects in the subscription or due to being listed in |
||||
`includeLinkingObjectProperties`. If the limit is larger than the number of |
||||
objects which match the query, all objects will be included. A limit of zero is |
||||
treated as unlimited. |
||||
*/ |
||||
@property (nonatomic) NSUInteger limit; |
||||
|
||||
/**
|
||||
Which RLMLinkingObjects properties should be included in the subscription. |
||||
|
||||
Outgoing links (i.e. `RLMArray` and `RLMObject` properties) are automatically |
||||
included in sync subscriptions. That is, if you subscribe to a query which |
||||
matches one object, every object which is reachable via links from that object |
||||
are also included in the subscription. |
||||
|
||||
By default, RLMLinkingObjects properties do not work this way. Instead, they |
||||
only report objects which happen to be included in a subscription. By naming |
||||
a RLMLinkingObjects property in this array, it can instead be treated as if |
||||
it was a RLMArray and include all objects which link to this object. |
||||
|
||||
Any keypath which ends in a RLMLinkingObject property can be included in this |
||||
array, including ones involving intermediate links. |
||||
*/ |
||||
@property (nonatomic, copy, nullable) NSArray<NSString *> *includeLinkingObjectProperties; |
||||
@end |
||||
|
||||
/**
|
||||
Support for subscribing to the results of object queries in a synced Realm. |
||||
*/ |
||||
@interface RLMResults (SyncSubscription) |
||||
|
||||
/**
|
||||
Subscribe to the query represented by this `RLMResults`. |
||||
|
||||
Subscribing to a query asks the server to synchronize all objects to the |
||||
client which match the query, along with all objects which are reachable |
||||
from those objects via links. This happens asynchronously, and the local |
||||
client Realm may not immediately have all objects which match the query. |
||||
Observe the `state` property of the returned subscription object to be |
||||
notified of when the subscription has been processed by the server and |
||||
all objects matching the query are available. |
||||
|
||||
The subscription will not be explicitly named. A name will be automatically |
||||
generated for internal use. The exact format of this name may change without |
||||
warning and should not be depended on. |
||||
|
||||
@return An object representing the newly-created subscription. |
||||
|
||||
@see RLMSyncSubscription |
||||
*/ |
||||
- (RLMSyncSubscription *)subscribe; |
||||
|
||||
/**
|
||||
Subscribe to the query represented by this `RLMResults`. |
||||
|
||||
Subscribing to a query asks the server to synchronize all objects to the |
||||
client which match the query, along with all objects which are reachable |
||||
from those objects via links. This happens asynchronously, and the local |
||||
client Realm may not immediately have all objects which match the query. |
||||
Observe the `state` property of the returned subscription object to be |
||||
notified of when the subscription has been processed by the server and |
||||
all objects matching the query are available. |
||||
|
||||
Creating a new subscription with the same name and query as an existing |
||||
subscription will not create a new subscription, but instead will return |
||||
an object referring to the existing sync subscription. This means that |
||||
performing the same subscription twice followed by removing it once will |
||||
result in no subscription existing. |
||||
|
||||
The newly created subscription will not be reported by |
||||
`-[RLMRealm subscriptions]` or `-[RLMRealm subscriptionWithName:]` until |
||||
`state` has transitioned from `RLMSyncSubscriptionStateCreating` to any of the |
||||
other states. |
||||
|
||||
@param subscriptionName The name of the subscription. |
||||
|
||||
@return An object representing the newly-created subscription. |
||||
|
||||
@see RLMSyncSubscription |
||||
*/ |
||||
- (RLMSyncSubscription *)subscribeWithName:(nullable NSString *)subscriptionName; |
||||
|
||||
/**
|
||||
Subscribe to a subset of the query represented by this `RLMResults`. |
||||
|
||||
Subscribing to a query asks the server to synchronize all objects to the |
||||
client which match the query, along with all objects which are reachable |
||||
from those objects via links. This happens asynchronously, and the local |
||||
client Realm may not immediately have all objects which match the query. |
||||
Observe the `state` property of the returned subscription object to be |
||||
notified of when the subscription has been processed by the server and |
||||
all objects matching the query are available. |
||||
|
||||
Creating a new subscription with the same name and query as an existing |
||||
subscription will not create a new subscription, but instead will return |
||||
an object referring to the existing sync subscription. This means that |
||||
performing the same subscription twice followed by removing it once will |
||||
result in no subscription existing. |
||||
|
||||
The newly created subscription will not be reported by |
||||
`-[RLMRealm subscriptions]` or `-[RLMRealm subscriptionWithName:]` until |
||||
`state` has transitioned from `RLMSyncSubscriptionStateCreating` to any of the |
||||
other states. |
||||
|
||||
The number of top-level matches may optionally be limited. This limit |
||||
respects the sort and distinct order of the query being subscribed to, |
||||
if any. Please note that the limit does not count or apply to objects |
||||
which are added indirectly due to being linked to by the objects in the |
||||
subscription. If the limit is larger than the number of objects which |
||||
match the query, all objects will be included. |
||||
|
||||
@param subscriptionName The name of the subscription |
||||
@param limit The maximum number of objects to include in the subscription. |
||||
|
||||
@return The subscription |
||||
|
||||
@see RLMSyncSubscription |
||||
*/ |
||||
- (RLMSyncSubscription *)subscribeWithName:(nullable NSString *)subscriptionName limit:(NSUInteger)limit; |
||||
|
||||
/**
|
||||
Subscribe to a subset of the query represented by this `RLMResults`. |
||||
|
||||
Subscribing to a query asks the server to synchronize all objects to the |
||||
client which match the query, along with all objects which are reachable |
||||
from those objects via links. This happens asynchronously, and the local |
||||
client Realm may not immediately have all objects which match the query. |
||||
Observe the `state` property of the returned subscription object to be |
||||
notified of when the subscription has been processed by the server and |
||||
all objects matching the query are available. |
||||
|
||||
Creating a new subscription with the same name and query as an existing |
||||
subscription will not create a new subscription, but instead will return |
||||
an object referring to the existing sync subscription. This means that |
||||
performing the same subscription twice followed by removing it once will |
||||
result in no subscription existing. |
||||
|
||||
The newly created subscription will not be reported by |
||||
`-[RLMRealm subscriptions]` or `-[RLMRealm subscriptionWithName:]` until |
||||
`state` has transitioned from `RLMSyncSubscriptionStateCreating` to any of the |
||||
other states. |
||||
|
||||
@param options The additional configuration options for the subscription. |
||||
@return The subscription. |
||||
|
||||
@see RLMSyncSubscription |
||||
*/ |
||||
- (RLMSyncSubscription *)subscribeWithOptions:(RLMSyncSubscriptionOptions *)options; |
||||
@end |
||||
|
||||
/**
|
||||
Support for managing existing subscriptions to object queries in a Realm. |
||||
*/ |
||||
@interface RLMRealm (SyncSubscription) |
||||
/**
|
||||
Get a list of the query-based sync subscriptions made for this Realm. |
||||
|
||||
This list includes all subscriptions which are currently in the states `Pending`, |
||||
`Created`, and `Error`. Newly created subscriptions which are still in the |
||||
`Creating` state are not included, and calling this immediately after calling |
||||
`-[RLMResults subscribe]` will typically not include that subscription. Similarly, |
||||
because unsubscription happens asynchronously, this may continue to include |
||||
subscriptions after `-[RLMSyncSubscription unsubscribe]` is called on them. |
||||
|
||||
This method can only be called on a Realm which is using query-based sync and |
||||
will throw an exception if called on a non-synchronized or full-sync Realm. |
||||
*/ |
||||
- (RLMResults<RLMSyncSubscription *> *)subscriptions; |
||||
|
||||
/**
|
||||
Look up a specific query-based sync subscription by name. |
||||
|
||||
Subscriptions are created asynchronously, so calling this immediately after |
||||
calling `subscribeWithName:` on a `RLMResults` will typically return `nil`. |
||||
Only subscriptions which are currently in the states `Pending`, `Created`, |
||||
and `Error` can be retrieved with this method. |
||||
|
||||
This method can only be called on a Realm which is using query-based sync and |
||||
will throw an exception if called on a non-synchronized or full-sync Realm. |
||||
|
||||
@return The named subscription, or `nil` if no subscription exists with that name. |
||||
*/ |
||||
- (nullable RLMSyncSubscription *)subscriptionWithName:(NSString *)name; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,526 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import "RLMRealmConfiguration.h" |
||||
#import "RLMResults.h" |
||||
#import "RLMSyncCredentials.h" |
||||
#import "RLMSyncPermission.h" |
||||
|
||||
@class RLMSyncUser, RLMSyncUserInfo, RLMSyncCredentials, RLMSyncPermission, RLMSyncSession, RLMRealm; |
||||
|
||||
/**
|
||||
The state of the user object. |
||||
*/ |
||||
typedef NS_ENUM(NSUInteger, RLMSyncUserState) { |
||||
/// The user is logged out. Call `logInWithCredentials:...` with valid credentials to log the user back in.
|
||||
RLMSyncUserStateLoggedOut, |
||||
/// The user is logged in, and any Realms associated with it are syncing with the Realm Object Server.
|
||||
RLMSyncUserStateActive, |
||||
/// The user has encountered a fatal error state, and cannot be used.
|
||||
RLMSyncUserStateError, |
||||
}; |
||||
|
||||
/// A block type used for APIs which asynchronously vend an `RLMSyncUser`.
|
||||
typedef void(^RLMUserCompletionBlock)(RLMSyncUser * _Nullable, NSError * _Nullable); |
||||
|
||||
/// A block type used to report the status of a password change operation.
|
||||
/// If the `NSError` argument is nil, the operation succeeded.
|
||||
typedef void(^RLMPasswordChangeStatusBlock)(NSError * _Nullable); |
||||
|
||||
/// A block type used to report the status of a permission apply or revoke operation.
|
||||
/// If the `NSError` argument is nil, the operation succeeded.
|
||||
typedef void(^RLMPermissionStatusBlock)(NSError * _Nullable); |
||||
|
||||
/// A block type used to report the status of a permission offer operation.
|
||||
typedef void(^RLMPermissionOfferStatusBlock)(NSString * _Nullable, NSError * _Nullable); |
||||
|
||||
/// A block type used to report the status of a permission offer response operation.
|
||||
typedef void(^RLMPermissionOfferResponseStatusBlock)(NSURL * _Nullable, NSError * _Nullable); |
||||
|
||||
/// A block type used to asynchronously report results of a permissions get operation.
|
||||
/// Exactly one of the two arguments will be populated.
|
||||
typedef void(^RLMPermissionResultsBlock)(RLMResults<RLMSyncPermission *> * _Nullable, NSError * _Nullable); |
||||
|
||||
/// A block type used to asynchronously report results of a user info retrieval.
|
||||
/// Exactly one of the two arguments will be populated.
|
||||
typedef void(^RLMRetrieveUserBlock)(RLMSyncUserInfo * _Nullable, NSError * _Nullable); |
||||
|
||||
/// A block type used to report an error related to a specific user.
|
||||
typedef void(^RLMUserErrorReportingBlock)(RLMSyncUser * _Nonnull, NSError * _Nonnull); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
A `RLMSyncUser` instance represents a single Realm Object Server user account. |
||||
|
||||
A user may have one or more credentials associated with it. These credentials |
||||
uniquely identify the user to the authentication provider, and are used to sign |
||||
into a Realm Object Server user account. |
||||
|
||||
Note that user objects are only vended out via SDK APIs, and cannot be directly |
||||
initialized. User objects can be accessed from any thread. |
||||
*/ |
||||
@interface RLMSyncUser : NSObject |
||||
|
||||
/**
|
||||
A dictionary of all valid, logged-in user identities corresponding to their user objects. |
||||
*/ |
||||
+ (NSDictionary<NSString *, RLMSyncUser *> *)allUsers NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
The logged-in user. `nil` if none exists. |
||||
|
||||
@warning Throws an exception if more than one logged-in user exists. |
||||
*/ |
||||
+ (nullable RLMSyncUser *)currentUser NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
The unique Realm Object Server user ID string identifying this user. |
||||
*/ |
||||
@property (nullable, nonatomic, readonly) NSString *identity; |
||||
|
||||
/**
|
||||
The user's refresh token used to access the Realm Object Server. |
||||
|
||||
This is required to make HTTP requests to Realm Object Server's REST API |
||||
for functionality not exposed natively. It should be treated as sensitive data. |
||||
*/ |
||||
@property (nullable, nonatomic, readonly) NSString *refreshToken; |
||||
|
||||
/**
|
||||
The URL of the authentication server this user will communicate with. |
||||
*/ |
||||
@property (nullable, nonatomic, readonly) NSURL *authenticationServer; |
||||
|
||||
/**
|
||||
Whether the user is a Realm Object Server administrator. Value reflects the |
||||
state at the time of the last successful login of this user. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL isAdmin; |
||||
|
||||
/**
|
||||
The current state of the user. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSyncUserState state; |
||||
|
||||
#pragma mark - Lifecycle |
||||
|
||||
/**
|
||||
Create, log in, and asynchronously return a new user object, specifying a custom |
||||
timeout for the network request and a custom queue to run the callback upon. |
||||
Credentials identifying the user must be passed in. The user becomes available in |
||||
the completion block, at which point it is ready for use. |
||||
*/ |
||||
+ (void)logInWithCredentials:(RLMSyncCredentials *)credentials |
||||
authServerURL:(NSURL *)authServerURL |
||||
timeout:(NSTimeInterval)timeout |
||||
callbackQueue:(dispatch_queue_t)callbackQueue |
||||
onCompletion:(RLMUserCompletionBlock)completion NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Create, log in, and asynchronously return a new user object. |
||||
|
||||
If the login completes successfully, the completion block will invoked with |
||||
a `RLMSyncUser` object representing the logged-in user. This object can be |
||||
used to open synchronized Realms. If the login fails, the completion block |
||||
will be invoked with an error. |
||||
|
||||
The completion block always runs on the main queue. |
||||
|
||||
@param credentials A credentials value identifying the user to be logged in. |
||||
@param authServerURL The URL of the authentication server (e.g. "http://realm.example.org:9080"). |
||||
@param completion A callback block that returns a user object or an error, |
||||
indicating the completion of the login operation. |
||||
*/ |
||||
+ (void)logInWithCredentials:(RLMSyncCredentials *)credentials |
||||
authServerURL:(NSURL *)authServerURL |
||||
onCompletion:(RLMUserCompletionBlock)completion |
||||
NS_SWIFT_UNAVAILABLE("Use the full version of this API."); |
||||
|
||||
|
||||
/**
|
||||
Returns the default configuration for the user. The default configuration |
||||
points to the default query-based Realm on the server the user authenticated against. |
||||
*/ |
||||
- (RLMRealmConfiguration *)configuration NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Create a query-based configuration instance for the given url. |
||||
|
||||
@param url The unresolved absolute URL to the Realm on the Realm Object Server, |
||||
e.g. "realm://example.org/~/path/to/realm". "Unresolved" means the |
||||
path should contain the wildcard marker `~`, which will automatically |
||||
be filled in with the user identity by the Realm Object Server. |
||||
@return A default configuration object with the sync configuration set to use the given URL. |
||||
*/ |
||||
- (RLMRealmConfiguration *)configurationWithURL:(nullable NSURL *)url NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Create a configuration instance for the given url. |
||||
|
||||
@param url The unresolved absolute URL to the Realm on the Realm Object Server, |
||||
e.g. "realm://example.org/~/path/to/realm". "Unresolved" means the |
||||
path should contain the wildcard marker `~`, which will automatically |
||||
be filled in with the user identity by the Realm Object Server. |
||||
@param fullSynchronization If YES, all objects in the server Realm are |
||||
automatically synchronized, and the query subscription |
||||
methods cannot be used. |
||||
@return A default configuration object with the sync configuration set to use |
||||
the given URL and options. |
||||
*/ |
||||
- (RLMRealmConfiguration *)configurationWithURL:(nullable NSURL *)url |
||||
fullSynchronization:(bool)fullSynchronization NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Create a configuration instance for the given url. |
||||
|
||||
@param url The unresolved absolute URL to the Realm on the Realm Object Server, |
||||
e.g. "realm://example.org/~/path/to/realm". "Unresolved" means the |
||||
path should contain the wildcard marker `~`, which will automatically |
||||
be filled in with the user identity by the Realm Object Server. |
||||
@param fullSynchronization If YES, all objects in the server Realm are |
||||
automatically synchronized, and the query subscription |
||||
methods cannot be used. |
||||
@param enableSSLValidation If NO, invalid SSL certificates for the server will |
||||
not be rejected. THIS SHOULD NEVER BE USED IN |
||||
PRODUCTION AND EXISTS ONLY FOR TESTING PURPOSES. |
||||
@param urlPrefix A prefix which is prepending to URLs constructed for |
||||
the server. This should normally be `nil`, and customized only |
||||
to match corresponding settings on the server. |
||||
@return A default configuration object with the sync configuration set to use |
||||
the given URL and options. |
||||
*/ |
||||
- (RLMRealmConfiguration *)configurationWithURL:(nullable NSURL *)url |
||||
fullSynchronization:(bool)fullSynchronization |
||||
enableSSLValidation:(bool)enableSSLValidation |
||||
urlPrefix:(nullable NSString *)urlPrefix NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Log a user out, destroying their server state, unregistering them from the SDK, |
||||
and removing any synced Realms associated with them from on-disk storage on |
||||
next app launch. If the user is already logged out or in an error state, this |
||||
method does nothing. |
||||
|
||||
This method should be called whenever the application is committed to not using |
||||
a user again unless they are recreated. |
||||
Failing to call this method may result in unused files and metadata needlessly |
||||
taking up space. |
||||
*/ |
||||
- (void)logOut; |
||||
|
||||
/**
|
||||
An optional error handler which can be set to notify the host application when |
||||
the user encounters an error. Errors reported by this error handler are always |
||||
`RLMSyncAuthError`s. |
||||
|
||||
@note Check for `RLMSyncAuthErrorInvalidAccessToken` to see if the user has |
||||
been remotely logged out because its refresh token expired, or because the |
||||
third party authentication service providing the user's identity has |
||||
logged the user out. |
||||
|
||||
@warning Regardless of whether an error handler is installed, certain user errors |
||||
will automatically cause the user to enter the logged out state. |
||||
*/ |
||||
@property (nullable, nonatomic) RLMUserErrorReportingBlock errorHandler NS_REFINED_FOR_SWIFT; |
||||
|
||||
#pragma mark - Sessions |
||||
|
||||
/**
|
||||
Retrieve a valid session object belonging to this user for a given URL, or `nil` |
||||
if no such object exists. |
||||
*/ |
||||
- (nullable RLMSyncSession *)sessionForURL:(NSURL *)url; |
||||
|
||||
/**
|
||||
Retrieve all the valid sessions belonging to this user. |
||||
*/ |
||||
- (NSArray<RLMSyncSession *> *)allSessions; |
||||
|
||||
#pragma mark - Passwords |
||||
|
||||
/**
|
||||
Change this user's password asynchronously. |
||||
|
||||
@warning Changing a user's password using an authentication server that doesn't |
||||
use HTTPS is a major security flaw, and should only be done while |
||||
testing. |
||||
|
||||
@param newPassword The user's new password. |
||||
@param completion Completion block invoked when login has completed or failed. |
||||
The callback will be invoked on a background queue provided |
||||
by `NSURLSession`. |
||||
*/ |
||||
- (void)changePassword:(NSString *)newPassword completion:(RLMPasswordChangeStatusBlock)completion; |
||||
|
||||
/**
|
||||
Change an arbitrary user's password asynchronously. |
||||
|
||||
@note The current user must be an admin user for this operation to succeed. |
||||
|
||||
@warning Changing a user's password using an authentication server that doesn't |
||||
use HTTPS is a major security flaw, and should only be done while |
||||
testing. |
||||
|
||||
@param newPassword The user's new password. |
||||
@param userID The identity of the user whose password should be changed. |
||||
@param completion Completion block invoked when login has completed or failed. |
||||
The callback will be invoked on a background queue provided |
||||
by `NSURLSession`. |
||||
*/ |
||||
- (void)changePassword:(NSString *)newPassword forUserID:(NSString *)userID completion:(RLMPasswordChangeStatusBlock)completion; |
||||
|
||||
/**
|
||||
Ask the server to send a password reset email to the given email address. |
||||
|
||||
If `email` is an email address which is associated with a user account that was |
||||
registered using the "password" authentication service, the server will send an |
||||
email to that address with a password reset token. No error is reported if the |
||||
email address is invalid or not associated with an account. |
||||
|
||||
@param serverURL The authentication server URL for the user. |
||||
@param email The email address to send the email to. |
||||
@param completion A block which will be called when the request completes or |
||||
fails. The callback will be invoked on a background queue |
||||
provided by `NSURLSession`, and not on the calling queue. |
||||
*/ |
||||
+ (void)requestPasswordResetForAuthServer:(NSURL *)serverURL |
||||
userEmail:(NSString *)email |
||||
completion:(RLMPasswordChangeStatusBlock)completion; |
||||
|
||||
/**
|
||||
Change a user's password using a one-time password reset token. |
||||
|
||||
By default, the password reset email sent by ROS will link to a web site where |
||||
the user can select a new password, and the app will not need to call this |
||||
method. If you wish to instead handle this within your native app, you must |
||||
change the `baseURL` in the server configuration for `PasswordAuthProvider` to |
||||
a scheme registered for your app, extract the token from the URL, and call this |
||||
method after prompting the user for a new password. |
||||
|
||||
@warning Changing a user's password using an authentication server that doesn't |
||||
use HTTPS is a major security flaw, and should only be done while |
||||
testing. |
||||
|
||||
@param serverURL The authentication server URL for the user. |
||||
@param token The one-time use token from the URL. |
||||
@param newPassword The user's new password. |
||||
@param completion A block which will be called when the request completes or |
||||
fails. The callback will be invoked on a background queue |
||||
provided by `NSURLSession`, and not on the calling queue. |
||||
*/ |
||||
+ (void)completePasswordResetForAuthServer:(NSURL *)serverURL |
||||
token:(NSString *)token |
||||
password:(NSString *)newPassword |
||||
completion:(RLMPasswordChangeStatusBlock)completion; |
||||
|
||||
/**
|
||||
Ask the server to send a confirmation email to the given email address. |
||||
|
||||
If `email` is an email address which is associated with a user account that was |
||||
registered using the "password" authentication service, the server will send an |
||||
email to that address with a confirmation token. No error is reported if the |
||||
email address is invalid or not associated with an account. |
||||
|
||||
@param serverURL The authentication server URL for the user. |
||||
@param email The email address to send the email to. |
||||
@param completion A block which will be called when the request completes or |
||||
fails. The callback will be invoked on a background queue |
||||
provided by `NSURLSession`, and not on the calling queue. |
||||
*/ |
||||
+ (void)requestEmailConfirmationForAuthServer:(NSURL *)serverURL |
||||
userEmail:(NSString *)email |
||||
completion:(RLMPasswordChangeStatusBlock)completion; |
||||
|
||||
/**
|
||||
Confirm a user's email using a one-time confirmation token. |
||||
|
||||
By default, the confirmation email sent by ROS will link to a web site with |
||||
a generic "thank you for confirming your email" message, and the app will not |
||||
need to call this method. If you wish to instead handle this within your native |
||||
app, you must change the `baseURL` in the server configuration for |
||||
`PasswordAuthProvider` to a scheme registered for your app, extract the token |
||||
from the URL, and call this method. |
||||
|
||||
@param serverURL The authentication server URL for the user. |
||||
@param token The one-time use token from the URL. |
||||
@param completion A block which will be called when the request completes or |
||||
fails. The callback will be invoked on a background queue |
||||
provided by `NSURLSession`, and not on the calling queue. |
||||
*/ |
||||
+ (void)confirmEmailForAuthServer:(NSURL *)serverURL |
||||
token:(NSString *)token |
||||
completion:(RLMPasswordChangeStatusBlock)completion; |
||||
|
||||
#pragma mark - Administrator |
||||
|
||||
/**
|
||||
Given a Realm Object Server authentication provider and a provider identifier for a user |
||||
(for example, a username), look up and return user information for that user. |
||||
|
||||
@param providerUserIdentity The username or identity of the user as issued by the authentication provider. |
||||
In most cases this is different from the Realm Object Server-issued identity. |
||||
@param provider The authentication provider that manages the user whose information is desired. |
||||
@param completion Completion block invoked when request has completed or failed. |
||||
The callback will be invoked on a background queue provided |
||||
by `NSURLSession`. |
||||
*/ |
||||
- (void)retrieveInfoForUser:(NSString *)providerUserIdentity |
||||
identityProvider:(RLMIdentityProvider)provider |
||||
completion:(RLMRetrieveUserBlock)completion; |
||||
|
||||
#pragma mark - Permissions |
||||
|
||||
/**
|
||||
Asynchronously retrieve all permissions associated with the user calling this method. |
||||
|
||||
The results will be returned through the callback block, or an error if the operation failed. |
||||
The callback block will be run on the same thread the method was called on. |
||||
|
||||
@warning This method must be called from a thread with a currently active run loop. Unless |
||||
you have manually configured a run loop on a side thread, this will usually be the |
||||
main thread. |
||||
*/ |
||||
- (void)retrievePermissionsWithCallback:(RLMPermissionResultsBlock)callback NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Apply a given permission. |
||||
|
||||
The operation will take place asynchronously, and the callback will be used to report whether |
||||
the permission change succeeded or failed. The user calling this method must have the right |
||||
to grant the given permission, or else the operation will fail. |
||||
|
||||
@see `RLMSyncPermission` |
||||
*/ |
||||
- (void)applyPermission:(RLMSyncPermission *)permission callback:(RLMPermissionStatusBlock)callback; |
||||
|
||||
/**
|
||||
Revoke a given permission. |
||||
|
||||
The operation will take place asynchronously, and the callback will be used to report whether |
||||
the permission change succeeded or failed. The user calling this method must have the right |
||||
to grant the given permission, or else the operation will fail. |
||||
|
||||
@see `RLMSyncPermission` |
||||
*/ |
||||
- (void)revokePermission:(RLMSyncPermission *)permission callback:(RLMPermissionStatusBlock)callback; |
||||
|
||||
/**
|
||||
Create a permission offer for a Realm. |
||||
|
||||
A permission offer is used to grant access to a Realm this user manages to another |
||||
user. Creating a permission offer produces a string token which can be passed to the |
||||
recepient in any suitable way (for example, via e-mail). |
||||
|
||||
The operation will take place asynchronously. The token can be accepted by the recepient |
||||
using the `-[RLMSyncUser acceptOfferForToken:callback:]` method. |
||||
|
||||
@param url The URL of the Realm for which the permission offer should pertain. This |
||||
may be the URL of any Realm which this user is allowed to manage. If the URL |
||||
has a `~` wildcard it will be replaced with this user's user identity. |
||||
@param accessLevel What access level to grant to whoever accepts the token. |
||||
@param expirationDate Optionally, a date which indicates when the offer expires. If the |
||||
recepient attempts to accept the offer after the date it will be rejected. |
||||
@param callback A callback indicating whether the operation succeeded or failed. If it |
||||
succeeded the token will be passed in as a string. |
||||
|
||||
@see `acceptOfferForToken:callback:` |
||||
*/ |
||||
- (void)createOfferForRealmAtURL:(NSURL *)url |
||||
accessLevel:(RLMSyncAccessLevel)accessLevel |
||||
expiration:(nullable NSDate *)expirationDate |
||||
callback:(RLMPermissionOfferStatusBlock)callback NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Accept a permission offer. |
||||
|
||||
Pass in a token representing a permission offer. The operation will take place asynchronously. |
||||
If the operation succeeds, the callback will be passed the URL of the Realm for which the |
||||
offer applied, so the Realm can be opened. |
||||
|
||||
The token this method accepts can be created by the offering user through the |
||||
`-[RLMSyncUser createOfferForRealmAtURL:accessLevel:expiration:callback:]` method. |
||||
|
||||
@see `createOfferForRealmAtURL:accessLevel:expiration:callback:` |
||||
*/ |
||||
- (void)acceptOfferForToken:(NSString *)token |
||||
callback:(RLMPermissionOfferResponseStatusBlock)callback; |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)init __attribute__((unavailable("RLMSyncUser cannot be created directly"))); |
||||
/// :nodoc:
|
||||
+ (instancetype)new __attribute__((unavailable("RLMSyncUser cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
#pragma mark - User info classes |
||||
|
||||
/**
|
||||
A data object representing a user account associated with a user. |
||||
|
||||
@see `RLMSyncUserInfo` |
||||
*/ |
||||
@interface RLMSyncUserAccountInfo : NSObject |
||||
|
||||
/// The authentication provider which manages this user account.
|
||||
@property (nonatomic, readonly) RLMIdentityProvider provider; |
||||
|
||||
/// The username or identity of this user account.
|
||||
@property (nonatomic, readonly) NSString *providerUserIdentity; |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)init __attribute__((unavailable("RLMSyncUserAccountInfo cannot be created directly"))); |
||||
/// :nodoc:
|
||||
+ (instancetype)new __attribute__((unavailable("RLMSyncUserAccountInfo cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
A data object representing information about a user that was retrieved from a user lookup call. |
||||
*/ |
||||
@interface RLMSyncUserInfo : NSObject |
||||
|
||||
/**
|
||||
An array of all the user accounts associated with this user. |
||||
*/ |
||||
@property (nonatomic, readonly) NSArray<RLMSyncUserAccountInfo *> *accounts; |
||||
|
||||
/**
|
||||
The identity issued to this user by the Realm Object Server. |
||||
*/ |
||||
@property (nonatomic, readonly) NSString *identity; |
||||
|
||||
/**
|
||||
Metadata about this user stored on the Realm Object Server. |
||||
*/ |
||||
@property (nonatomic, readonly) NSDictionary<NSString *, NSString *> *metadata; |
||||
|
||||
/**
|
||||
Whether the user is flagged on the Realm Object Server as an administrator. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL isAdmin; |
||||
|
||||
/// :nodoc:
|
||||
- (instancetype)init __attribute__((unavailable("RLMSyncUserInfo cannot be created directly"))); |
||||
/// :nodoc:
|
||||
+ (instancetype)new __attribute__((unavailable("RLMSyncUserInfo cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,222 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMConstants.h> |
||||
|
||||
/// A token originating from the Realm Object Server.
|
||||
typedef NSString* RLMServerToken; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/// A user info key for use with `RLMSyncErrorClientResetError`.
|
||||
extern NSString *const kRLMSyncPathOfRealmBackupCopyKey; |
||||
|
||||
/// A user info key for use with certain error types.
|
||||
extern NSString *const kRLMSyncErrorActionTokenKey; |
||||
|
||||
/**
|
||||
The error domain string for all SDK errors related to errors reported |
||||
by the synchronization manager error handler, as well as general sync |
||||
errors that don't fall into any of the other categories. |
||||
*/ |
||||
extern NSString *const RLMSyncErrorDomain; |
||||
|
||||
/**
|
||||
The error domain string for all SDK errors related to the authentication |
||||
endpoint. |
||||
*/ |
||||
extern NSString *const RLMSyncAuthErrorDomain; |
||||
|
||||
/**
|
||||
The error domain string for all SDK errors related to the permissions |
||||
system and APIs. |
||||
*/ |
||||
extern NSString *const RLMSyncPermissionErrorDomain; |
||||
|
||||
/**
|
||||
An error related to a problem that might be reported by the synchronization manager |
||||
error handler, or a callback on a sync-related API that performs asynchronous work. |
||||
*/ |
||||
typedef RLM_ERROR_ENUM(NSInteger, RLMSyncError, RLMSyncErrorDomain) { |
||||
|
||||
/// An error that indicates a problem with the session (a specific Realm opened for sync).
|
||||
RLMSyncErrorClientSessionError = 4, |
||||
|
||||
/// An error that indicates a problem with a specific user.
|
||||
RLMSyncErrorClientUserError = 5, |
||||
|
||||
/**
|
||||
An error that indicates an internal, unrecoverable problem |
||||
with the underlying synchronization engine. |
||||
*/ |
||||
RLMSyncErrorClientInternalError = 6, |
||||
|
||||
/**
|
||||
An error that indicates the Realm needs to be reset. |
||||
|
||||
A synced Realm may need to be reset because the Realm Object Server encountered an |
||||
error and had to be restored from a backup. If the backup copy of the remote Realm |
||||
is of an earlier version than the local copy of the Realm, the server will ask the |
||||
client to reset the Realm. |
||||
|
||||
The reset process is as follows: the local copy of the Realm is copied into a recovery |
||||
directory for safekeeping, and then deleted from the original location. The next time |
||||
the Realm for that URL is opened, the Realm will automatically be re-downloaded from the |
||||
Realm Object Server, and can be used as normal. |
||||
|
||||
Data written to the Realm after the local copy of the Realm diverged from the backup |
||||
remote copy will be present in the local recovery copy of the Realm file. The |
||||
re-downloaded Realm will initially contain only the data present at the time the Realm |
||||
was backed up on the server. |
||||
|
||||
The client reset process can be initiated in one of two ways. |
||||
|
||||
The `userInfo` dictionary contains an opaque token object under the key |
||||
`kRLMSyncErrorActionTokenKey`. This token can be passed into |
||||
`+[RLMSyncSession immediatelyHandleError:]` in order to immediately perform the client |
||||
reset process. This should only be done after your app closes and invalidates every |
||||
instance of the offending Realm on all threads (note that autorelease pools may make this |
||||
difficult to guarantee). |
||||
|
||||
If `+[RLMSyncSession immediatelyHandleError:]` is not called, the client reset process |
||||
will be automatically carried out the next time the app is launched and the |
||||
`RLMSyncManager` singleton is accessed. |
||||
|
||||
The value for the `kRLMSyncPathOfRealmBackupCopyKey` key in the `userInfo` dictionary |
||||
describes the path of the recovered copy of the Realm. This copy will not actually be |
||||
created until the client reset process is initiated. |
||||
|
||||
@see `-[NSError rlmSync_errorActionToken]`, `-[NSError rlmSync_clientResetBackedUpRealmPath]` |
||||
*/ |
||||
RLMSyncErrorClientResetError = 7, |
||||
|
||||
/**
|
||||
An error that indicates an authentication error occurred. |
||||
|
||||
The `kRLMSyncUnderlyingErrorKey` key in the user info dictionary will contain the |
||||
underlying error, which is guaranteed to be under the `RLMSyncAuthErrorDomain` |
||||
error domain. |
||||
*/ |
||||
RLMSyncErrorUnderlyingAuthError = 8, |
||||
|
||||
/**
|
||||
An error that indicates the user does not have permission to perform an operation |
||||
upon a synced Realm. For example, a user may receive this error if they attempt to |
||||
open a Realm they do not have at least read access to, or write to a Realm they only |
||||
have read access to. |
||||
|
||||
This error may also occur if a user incorrectly opens a Realm they have read-only |
||||
permissions to without using the `asyncOpen()` APIs. |
||||
|
||||
A Realm that suffers a permission denied error is, by default, flagged so that its |
||||
local copy will be deleted the next time the application starts. |
||||
|
||||
The `userInfo` dictionary contains an opaque token object under the key |
||||
`kRLMSyncErrorActionTokenKey`. This token can be passed into |
||||
`+[RLMSyncSession immediatelyHandleError:]` in order to immediately delete the local |
||||
copy. This should only be done after your app closes and invalidates every instance |
||||
of the offending Realm on all threads (note that autorelease pools may make this |
||||
difficult to guarantee). |
||||
|
||||
@warning It is strongly recommended that, if a Realm has encountered a permission denied |
||||
error, its files be deleted before attempting to re-open it. |
||||
|
||||
@see `-[NSError rlmSync_errorActionToken]` |
||||
*/ |
||||
RLMSyncErrorPermissionDeniedError = 9, |
||||
}; |
||||
|
||||
/// An error which is related to authentication to a Realm Object Server.
|
||||
typedef RLM_ERROR_ENUM(NSInteger, RLMSyncAuthError, RLMSyncAuthErrorDomain) { |
||||
/// An error that indicates that the response received from the authentication server was malformed.
|
||||
RLMSyncAuthErrorBadResponse = 1, |
||||
|
||||
/// An error that indicates that the supplied Realm path was invalid, or could not be resolved by the authentication
|
||||
/// server.
|
||||
RLMSyncAuthErrorBadRemoteRealmPath = 2, |
||||
|
||||
/// An error that indicates that the response received from the authentication server was an HTTP error code. The
|
||||
/// `userInfo` dictionary contains the actual error code value.
|
||||
RLMSyncAuthErrorHTTPStatusCodeError = 3, |
||||
|
||||
/// An error that indicates a problem with the session (a specific Realm opened for sync).
|
||||
RLMSyncAuthErrorClientSessionError = 4, |
||||
|
||||
/// An error that indicates that the provided credentials are ill-formed.
|
||||
RLMSyncAuthErrorInvalidParameters = 601, |
||||
|
||||
/// An error that indicates that no Realm path was included in the URL.
|
||||
RLMSyncAuthErrorMissingPath = 602, |
||||
|
||||
/// An error that indicates that the provided credentials are invalid.
|
||||
RLMSyncAuthErrorInvalidCredential = 611, |
||||
|
||||
/// An error that indicates that the user with provided credentials does not exist.
|
||||
RLMSyncAuthErrorUserDoesNotExist = 612, |
||||
|
||||
/// An error that indicates that the user cannot be registered as it exists already.
|
||||
RLMSyncAuthErrorUserAlreadyExists = 613, |
||||
|
||||
/// An error that indicates the path is invalid or the user doesn't have access to that Realm.
|
||||
RLMSyncAuthErrorAccessDeniedOrInvalidPath = 614, |
||||
|
||||
/// An error that indicates the refresh token was invalid.
|
||||
RLMSyncAuthErrorInvalidAccessToken = 615, |
||||
|
||||
/// An error that indicates the permission offer is expired.
|
||||
RLMSyncAuthErrorExpiredPermissionOffer = 701, |
||||
|
||||
/// An error that indicates the permission offer is ambiguous.
|
||||
RLMSyncAuthErrorAmbiguousPermissionOffer = 702, |
||||
|
||||
/// An error that indicates the file at the given path can't be shared.
|
||||
RLMSyncAuthErrorFileCannotBeShared = 703, |
||||
}; |
||||
|
||||
/**
|
||||
An error related to the permissions subsystem. |
||||
*/ |
||||
typedef RLM_ERROR_ENUM(NSInteger, RLMSyncPermissionError, RLMSyncPermissionErrorDomain) { |
||||
/**
|
||||
An error that indicates a permission change operation failed. The `userInfo` |
||||
dictionary contains the underlying error code and a message (if any). |
||||
*/ |
||||
RLMSyncPermissionErrorChangeFailed = 1, |
||||
|
||||
/**
|
||||
An error that indicates that attempting to retrieve permissions failed. |
||||
*/ |
||||
RLMSyncPermissionErrorGetFailed = 2, |
||||
|
||||
/**
|
||||
An error that indicates that trying to create a permission offer failed. |
||||
*/ |
||||
RLMSyncPermissionErrorOfferFailed = 3, |
||||
|
||||
/**
|
||||
An error that indicates that trying to accept a permission offer failed. |
||||
*/ |
||||
RLMSyncPermissionErrorAcceptOfferFailed = 4, |
||||
|
||||
/**
|
||||
An error that indicates that an internal error occurred. |
||||
*/ |
||||
RLMSyncPermissionErrorInternal = 5, |
||||
}; |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
106
Carthage/Build/Mac/Realm.framework/Versions/A/Headers/RLMThreadSafeReference.h
generated
vendored
106
Carthage/Build/Mac/Realm.framework/Versions/A/Headers/RLMThreadSafeReference.h
generated
vendored
@ -0,0 +1,106 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
@class RLMRealm; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
Objects of types which conform to `RLMThreadConfined` can be managed by a Realm, which will make |
||||
them bound to a thread-specific `RLMRealm` instance. Managed objects must be explicitly exported |
||||
and imported to be passed between threads. |
||||
|
||||
Managed instances of objects conforming to this protocol can be converted to a thread-safe |
||||
reference for transport between threads by passing to the |
||||
`+[RLMThreadSafeReference referenceWithThreadConfined:]` constructor. |
||||
|
||||
Note that only types defined by Realm can meaningfully conform to this protocol, and defining new |
||||
classes which attempt to conform to it will not make them work with `RLMThreadSafeReference`. |
||||
*/ |
||||
@protocol RLMThreadConfined <NSObject> |
||||
// Conformance to the `RLMThreadConfined_Private` protocol will be enforced at runtime.
|
||||
|
||||
/**
|
||||
The Realm which manages the object, or `nil` if the object is unmanaged. |
||||
|
||||
Unmanaged objects are not confined to a thread and cannot be passed to methods expecting a |
||||
`RLMThreadConfined` object. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) RLMRealm *realm; |
||||
|
||||
/// Indicates if the object can no longer be accessed because it is now invalid.
|
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
An object intended to be passed between threads containing a thread-safe reference to its |
||||
thread-confined object. |
||||
|
||||
To resolve a thread-safe reference on a target Realm on a different thread, pass to |
||||
`-[RLMRealm resolveThreadSafeReference:]`. |
||||
|
||||
@warning A `RLMThreadSafeReference` object must be resolved at most once. |
||||
Failing to resolve a `RLMThreadSafeReference` will result in the source version of the |
||||
Realm being pinned until the reference is deallocated. |
||||
|
||||
@note Prefer short-lived `RLMThreadSafeReference`s as the data for the version of the source Realm |
||||
will be retained until all references have been resolved or deallocated. |
||||
|
||||
@see `RLMThreadConfined` |
||||
@see `-[RLMRealm resolveThreadSafeReference:]` |
||||
*/ |
||||
@interface RLMThreadSafeReference<__covariant Confined : id<RLMThreadConfined>> : NSObject |
||||
|
||||
/**
|
||||
Create a thread-safe reference to the thread-confined object. |
||||
|
||||
@param threadConfined The thread-confined object to create a thread-safe reference to. |
||||
|
||||
@note You may continue to use and access the thread-confined object after passing it to this |
||||
constructor. |
||||
*/ |
||||
+ (instancetype)referenceWithThreadConfined:(Confined)threadConfined; |
||||
|
||||
/**
|
||||
Indicates if the reference can no longer be resolved because an attempt to resolve it has already |
||||
occurred. References can only be resolved once. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
#pragma mark - Unavailable Methods |
||||
|
||||
/**
|
||||
`-[RLMThreadSafeReference init]` is not available because `RLMThreadSafeReference` cannot be |
||||
created directly. `RLMThreadSafeReference` instances must be obtained by calling |
||||
`-[RLMRealm resolveThreadSafeReference:]`. |
||||
*/ |
||||
- (instancetype)init __attribute__((unavailable("RLMThreadSafeReference cannot be created directly"))); |
||||
|
||||
/**
|
||||
`-[RLMThreadSafeReference new]` is not available because `RLMThreadSafeReference` cannot be |
||||
created directly. `RLMThreadSafeReference` instances must be obtained by calling |
||||
`-[RLMRealm resolveThreadSafeReference:]`. |
||||
*/ |
||||
+ (instancetype)new __attribute__((unavailable("RLMThreadSafeReference cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,41 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import <Realm/RLMArray.h> |
||||
#import <Realm/RLMMigration.h> |
||||
#import <Realm/RLMObject.h> |
||||
#import <Realm/RLMObjectSchema.h> |
||||
#import <Realm/RLMPlatform.h> |
||||
#import <Realm/RLMProperty.h> |
||||
#import <Realm/RLMRealm.h> |
||||
#import <Realm/RLMRealm+Sync.h> |
||||
#import <Realm/RLMRealmConfiguration.h> |
||||
#import <Realm/RLMRealmConfiguration+Sync.h> |
||||
#import <Realm/RLMResults.h> |
||||
#import <Realm/RLMSchema.h> |
||||
#import <Realm/RLMSyncConfiguration.h> |
||||
#import <Realm/RLMSyncCredentials.h> |
||||
#import <Realm/RLMSyncManager.h> |
||||
#import <Realm/RLMSyncPermission.h> |
||||
#import <Realm/RLMSyncSession.h> |
||||
#import <Realm/RLMSyncSubscription.h> |
||||
#import <Realm/RLMSyncUser.h> |
||||
#import <Realm/RLMSyncUtil.h> |
||||
#import <Realm/NSError+RLMSync.h> |
||||
@ -0,0 +1,31 @@ |
||||
framework module Realm { |
||||
umbrella header "Realm.h" |
||||
|
||||
export * |
||||
module * { export * } |
||||
|
||||
explicit module Private { |
||||
header "RLMAccessor.h" |
||||
header "RLMArray_Private.h" |
||||
header "RLMCollection_Private.h" |
||||
header "RLMListBase.h" |
||||
header "RLMObject_Private.h" |
||||
header "RLMObjectBase_Dynamic.h" |
||||
header "RLMObjectBase_Private.h" |
||||
header "RLMObjectSchema_Private.h" |
||||
header "RLMObjectStore.h" |
||||
header "RLMOptionalBase.h" |
||||
header "RLMProperty_Private.h" |
||||
header "RLMRealm_Private.h" |
||||
header "RLMRealmConfiguration_Private.h" |
||||
header "RLMResults_Private.h" |
||||
header "RLMSchema_Private.h" |
||||
header "RLMSyncConfiguration_Private.h" |
||||
header "RLMSyncUtil_Private.h" |
||||
} |
||||
|
||||
explicit module Dynamic { |
||||
header "RLMRealm_Dynamic.h" |
||||
header "RLMObjectBase_Dynamic.h" |
||||
} |
||||
} |
||||
@ -0,0 +1,53 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
@class RLMObjectSchema, RLMProperty, RLMObjectBase; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
//
|
||||
// Accessors Class Creation/Caching
|
||||
//
|
||||
|
||||
// get accessor classes for an object class - generates classes if not cached
|
||||
Class RLMManagedAccessorClassForObjectClass(Class objectClass, RLMObjectSchema *schema, const char *name); |
||||
Class RLMUnmanagedAccessorClassForObjectClass(Class objectClass, RLMObjectSchema *schema); |
||||
|
||||
//
|
||||
// Dynamic getters/setters
|
||||
//
|
||||
FOUNDATION_EXTERN void RLMDynamicValidatedSet(RLMObjectBase *obj, NSString *propName, id __nullable val); |
||||
FOUNDATION_EXTERN id __nullable RLMDynamicGet(RLMObjectBase *obj, RLMProperty *prop); |
||||
FOUNDATION_EXTERN id __nullable RLMDynamicGetByName(RLMObjectBase *obj, NSString *propName, bool asList); |
||||
|
||||
// by property/column
|
||||
void RLMDynamicSet(RLMObjectBase *obj, RLMProperty *prop, id val); |
||||
|
||||
//
|
||||
// Class modification
|
||||
//
|
||||
|
||||
// Replace className method for the given class
|
||||
void RLMReplaceClassNameMethod(Class accessorClass, NSString *className); |
||||
|
||||
// Replace sharedSchema method for the given class
|
||||
void RLMReplaceSharedSchemaMethod(Class accessorClass, RLMObjectSchema * __nullable schema); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
32
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMArray_Private.h
generated
vendored
32
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMArray_Private.h
generated
vendored
@ -0,0 +1,32 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMArray.h> |
||||
#import <Realm/RLMConstants.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@interface RLMArray () |
||||
- (instancetype)initWithObjectClassName:(NSString *)objectClassName; |
||||
- (instancetype)initWithObjectType:(RLMPropertyType)type optional:(BOOL)optional; |
||||
- (NSString *)descriptionWithMaxDepth:(NSUInteger)depth; |
||||
@end |
||||
|
||||
void RLMArrayValidateMatchingObjectType(RLMArray *array, id value); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
26
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMCollection_Private.h
generated
vendored
26
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMCollection_Private.h
generated
vendored
@ -0,0 +1,26 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMCollection.h> |
||||
|
||||
#import <Realm/RLMRealm.h> |
||||
|
||||
@protocol RLMFastEnumerable; |
||||
|
||||
void RLMCollectionSetValueForKey(id<RLMFastEnumerable> collection, NSString *key, id value); |
||||
FOUNDATION_EXTERN NSString *RLMDescriptionWithMaxDepth(NSString *name, id<RLMCollection> collection, NSUInteger depth); |
||||
@ -0,0 +1,33 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
@class RLMArray; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
// A base class for Swift generic Lists to make it possible to interact with
|
||||
// them from obj-c
|
||||
@interface RLMListBase : NSObject <NSFastEnumeration> |
||||
@property (nonatomic, strong) RLMArray *_rlmArray; |
||||
|
||||
- (instancetype)initWithArray:(RLMArray *)array; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
40
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMMigration_Private.h
generated
vendored
40
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMMigration_Private.h
generated
vendored
@ -0,0 +1,40 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMMigration.h> |
||||
#import <Realm/RLMObjectBase.h> |
||||
#import <Realm/RLMRealm.h> |
||||
|
||||
namespace realm { |
||||
class Schema; |
||||
} |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@interface RLMMigration () |
||||
|
||||
@property (nonatomic, strong) RLMRealm *oldRealm; |
||||
@property (nonatomic, strong) RLMRealm *realm; |
||||
|
||||
- (instancetype)initWithRealm:(RLMRealm *)realm oldRealm:(RLMRealm *)oldRealm schema:(realm::Schema &)schema; |
||||
|
||||
- (void)execute:(RLMMigrationBlock)block; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
28
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMObjectBase_Private.h
generated
vendored
28
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMObjectBase_Private.h
generated
vendored
@ -0,0 +1,28 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2017 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMObjectBase.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
// RLMObjectBase private
|
||||
@interface RLMObjectBase () |
||||
+ (void)initializeLinkedObjectSchemas; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
71
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMObjectSchema_Private.h
generated
vendored
71
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMObjectSchema_Private.h
generated
vendored
@ -0,0 +1,71 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMObjectSchema.h> |
||||
|
||||
#import <objc/runtime.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
// RLMObjectSchema private
|
||||
@interface RLMObjectSchema () { |
||||
@public |
||||
bool _isSwiftClass; |
||||
} |
||||
|
||||
/// The object type name reported to the object store and core.
|
||||
@property (nonatomic, readonly) NSString *objectName; |
||||
|
||||
// writable redeclaration
|
||||
@property (nonatomic, readwrite, copy) NSArray<RLMProperty *> *properties; |
||||
@property (nonatomic, readwrite, assign) bool isSwiftClass; |
||||
|
||||
// class used for this object schema
|
||||
@property (nonatomic, readwrite, assign) Class objectClass; |
||||
@property (nonatomic, readwrite, assign) Class accessorClass; |
||||
@property (nonatomic, readwrite, assign) Class unmanagedClass; |
||||
|
||||
@property (nonatomic, readwrite, nullable) RLMProperty *primaryKeyProperty; |
||||
|
||||
@property (nonatomic, copy) NSArray<RLMProperty *> *computedProperties; |
||||
@property (nonatomic, readonly) NSArray<RLMProperty *> *swiftGenericProperties; |
||||
|
||||
// returns a cached or new schema for a given object class
|
||||
+ (instancetype)schemaForObjectClass:(Class)objectClass; |
||||
@end |
||||
|
||||
@interface RLMObjectSchema (Dynamic) |
||||
/**
|
||||
This method is useful only in specialized circumstances, for example, when accessing objects |
||||
in a Realm produced externally. If you are simply building an app on Realm, it is not recommended |
||||
to use this method as an [RLMObjectSchema](RLMObjectSchema) is generated automatically for every [RLMObject](RLMObject) subclass. |
||||
|
||||
Initialize an RLMObjectSchema with classname, objectClass, and an array of properties |
||||
|
||||
@warning This method is useful only in specialized circumstances. |
||||
|
||||
@param objectClassName The name of the class used to refer to objects of this type. |
||||
@param objectClass The Objective-C class used when creating instances of this type. |
||||
@param properties An array of RLMProperty instances describing the managed properties for this type. |
||||
|
||||
@return An initialized instance of RLMObjectSchema. |
||||
*/ |
||||
- (instancetype)initWithClassName:(NSString *)objectClassName objectClass:(Class)objectClass properties:(NSArray *)properties; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,95 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
@class RLMRealm, RLMSchema, RLMObjectBase, RLMResults, RLMProperty; |
||||
|
||||
typedef NS_ENUM(NSUInteger, RLMUpdatePolicy) { |
||||
RLMUpdatePolicyError = 0, |
||||
RLMUpdatePolicyUpdateChanged = 1, |
||||
RLMUpdatePolicyUpdateAll = 2, |
||||
}; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
void RLMVerifyHasPrimaryKey(Class cls); |
||||
|
||||
//
|
||||
// Accessor Creation
|
||||
//
|
||||
|
||||
// create or get cached accessors for the given schema
|
||||
void RLMRealmCreateAccessors(RLMSchema *schema); |
||||
|
||||
|
||||
//
|
||||
// Adding, Removing, Getting Objects
|
||||
//
|
||||
|
||||
// add an object to the given realm
|
||||
void RLMAddObjectToRealm(RLMObjectBase *object, RLMRealm *realm, RLMUpdatePolicy); |
||||
|
||||
// delete an object from its realm
|
||||
void RLMDeleteObjectFromRealm(RLMObjectBase *object, RLMRealm *realm); |
||||
|
||||
// deletes all objects from a realm
|
||||
void RLMDeleteAllObjectsFromRealm(RLMRealm *realm); |
||||
|
||||
// get objects of a given class
|
||||
RLMResults *RLMGetObjects(RLMRealm *realm, NSString *objectClassName, NSPredicate * _Nullable predicate) |
||||
NS_RETURNS_RETAINED; |
||||
|
||||
// get an object with the given primary key
|
||||
id _Nullable RLMGetObject(RLMRealm *realm, NSString *objectClassName, id _Nullable key) NS_RETURNS_RETAINED; |
||||
|
||||
// create object from array or dictionary
|
||||
RLMObjectBase *RLMCreateObjectInRealmWithValue(RLMRealm *realm, NSString *className, |
||||
id _Nullable value, RLMUpdatePolicy updatePolicy) |
||||
NS_RETURNS_RETAINED; |
||||
|
||||
//
|
||||
// Accessor Creation
|
||||
//
|
||||
|
||||
|
||||
// switch List<> properties from being backed by unmanaged RLMArrays to RLMManagedArray
|
||||
void RLMInitializeSwiftAccessorGenerics(RLMObjectBase *object); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
|
||||
namespace realm { |
||||
class Table; |
||||
template<typename T> class BasicRowExpr; |
||||
using RowExpr = BasicRowExpr<Table>; |
||||
} |
||||
class RLMClassInfo; |
||||
|
||||
// Create accessors
|
||||
RLMObjectBase *RLMCreateObjectAccessor(RLMRealm *realm, RLMClassInfo& info, |
||||
NSUInteger index) NS_RETURNS_RETAINED; |
||||
RLMObjectBase *RLMCreateObjectAccessor(RLMRealm *realm, RLMClassInfo& info, |
||||
realm::RowExpr row) NS_RETURNS_RETAINED; |
||||
#endif |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
147
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMObject_Private.h
generated
vendored
147
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMObject_Private.h
generated
vendored
@ -0,0 +1,147 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMObjectBase_Dynamic.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMProperty, RLMArray, RLMSwiftPropertyMetadata; |
||||
typedef NS_ENUM(int32_t, RLMPropertyType); |
||||
|
||||
// RLMObject accessor and read/write realm
|
||||
@interface RLMObjectBase () { |
||||
@public |
||||
RLMRealm *_realm; |
||||
__unsafe_unretained RLMObjectSchema *_objectSchema; |
||||
} |
||||
|
||||
// unmanaged initializer
|
||||
- (instancetype)initWithValue:(id)value schema:(RLMSchema *)schema NS_DESIGNATED_INITIALIZER; |
||||
|
||||
// live accessor initializer
|
||||
- (instancetype)initWithRealm:(__unsafe_unretained RLMRealm *const)realm |
||||
schema:(RLMObjectSchema *)schema NS_DESIGNATED_INITIALIZER; |
||||
|
||||
// shared schema for this class
|
||||
+ (nullable RLMObjectSchema *)sharedSchema; |
||||
|
||||
// provide injection point for alternative Swift object util class
|
||||
+ (Class)objectUtilClass:(BOOL)isSwift; |
||||
|
||||
@end |
||||
|
||||
@interface RLMObject () |
||||
|
||||
// unmanaged initializer
|
||||
- (instancetype)initWithValue:(id)value schema:(RLMSchema *)schema NS_DESIGNATED_INITIALIZER; |
||||
|
||||
// live accessor initializer
|
||||
- (instancetype)initWithRealm:(__unsafe_unretained RLMRealm *const)realm |
||||
schema:(RLMObjectSchema *)schema NS_DESIGNATED_INITIALIZER; |
||||
|
||||
@end |
||||
|
||||
@interface RLMDynamicObject : RLMObject |
||||
|
||||
@end |
||||
|
||||
// A reference to an object's row that doesn't keep the object accessor alive.
|
||||
// Used by some Swift property types, such as LinkingObjects, to avoid retain cycles
|
||||
// with their containing object.
|
||||
@interface RLMWeakObjectHandle : NSObject<NSCopying> |
||||
|
||||
- (instancetype)initWithObject:(RLMObjectBase *)object; |
||||
|
||||
// Consumes the row, so can only usefully be called once.
|
||||
@property (nonatomic, readonly) RLMObjectBase *object; |
||||
|
||||
@end |
||||
|
||||
// Calls valueForKey: and re-raises NSUndefinedKeyExceptions
|
||||
FOUNDATION_EXTERN id _Nullable RLMValidatedValueForProperty(id object, NSString *key, NSString *className); |
||||
|
||||
// Compare two RLObjectBases
|
||||
FOUNDATION_EXTERN BOOL RLMObjectBaseAreEqual(RLMObjectBase * _Nullable o1, RLMObjectBase * _Nullable o2); |
||||
|
||||
typedef void (^RLMObjectNotificationCallback)(NSArray<NSString *> *_Nullable propertyNames, |
||||
NSArray *_Nullable oldValues, |
||||
NSArray *_Nullable newValues, |
||||
NSError *_Nullable error); |
||||
FOUNDATION_EXTERN RLMNotificationToken *RLMObjectAddNotificationBlock(RLMObjectBase *obj, RLMObjectNotificationCallback block); |
||||
|
||||
// Returns whether the class is a descendent of RLMObjectBase
|
||||
FOUNDATION_EXTERN BOOL RLMIsObjectOrSubclass(Class klass); |
||||
|
||||
// Returns whether the class is an indirect descendant of RLMObjectBase
|
||||
FOUNDATION_EXTERN BOOL RLMIsObjectSubclass(Class klass); |
||||
|
||||
// For unit testing purposes, allow an Objective-C class named FakeObject to also be used
|
||||
// as the base class of managed objects. This allows for testing invalid schemas.
|
||||
FOUNDATION_EXTERN void RLMSetTreatFakeObjectAsRLMObject(BOOL flag); |
||||
|
||||
// Get ObjectUil class for objc or swift
|
||||
FOUNDATION_EXTERN Class RLMObjectUtilClass(BOOL isSwift); |
||||
|
||||
FOUNDATION_EXTERN const NSUInteger RLMDescriptionMaxDepth; |
||||
|
||||
@interface RLMObjectUtil : NSObject |
||||
|
||||
+ (nullable NSArray<NSString *> *)ignoredPropertiesForClass:(Class)cls; |
||||
+ (nullable NSArray<NSString *> *)indexedPropertiesForClass:(Class)cls; |
||||
+ (nullable NSDictionary<NSString *, NSDictionary<NSString *, NSString *> *> *)linkingObjectsPropertiesForClass:(Class)cls; |
||||
|
||||
// Precondition: these must be returned in ascending order.
|
||||
+ (nullable NSArray<RLMSwiftPropertyMetadata *> *)getSwiftProperties:(id)obj; |
||||
|
||||
+ (nullable NSDictionary<NSString *, NSNumber *> *)getOptionalProperties:(id)obj; |
||||
+ (nullable NSArray<NSString *> *)requiredPropertiesForClass:(Class)cls; |
||||
|
||||
@end |
||||
|
||||
typedef NS_ENUM(NSUInteger, RLMSwiftPropertyKind) { |
||||
RLMSwiftPropertyKindList, |
||||
RLMSwiftPropertyKindLinkingObjects, |
||||
RLMSwiftPropertyKindOptional, |
||||
RLMSwiftPropertyKindNilLiteralOptional, // For Swift optional properties that reflect as nil
|
||||
RLMSwiftPropertyKindOther, |
||||
}; |
||||
|
||||
// Metadata that describes a Swift generic property.
|
||||
@interface RLMSwiftPropertyMetadata : NSObject |
||||
|
||||
@property (nonatomic, strong) NSString *propertyName; |
||||
@property (nullable, nonatomic, strong) NSString *className; |
||||
@property (nullable, nonatomic, strong) NSString *linkedPropertyName; |
||||
@property (nonatomic) RLMPropertyType propertyType; |
||||
@property (nonatomic) RLMSwiftPropertyKind kind; |
||||
|
||||
+ (instancetype)metadataForOtherProperty:(NSString *)propertyName; |
||||
|
||||
+ (instancetype)metadataForListProperty:(NSString *)propertyName; |
||||
|
||||
+ (instancetype)metadataForLinkingObjectsProperty:(NSString *)propertyName |
||||
className:(NSString *)className |
||||
linkedPropertyName:(NSString *)linkedPropertyName; |
||||
|
||||
+ (instancetype)metadataForOptionalProperty:(NSString *)propertyName type:(RLMPropertyType)type; |
||||
|
||||
+ (instancetype)metadataForNilLiteralOptionalProperty:(NSString *)propertyName; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
36
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMOptionalBase.h
generated
vendored
36
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMOptionalBase.h
generated
vendored
@ -0,0 +1,36 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import <Realm/RLMConstants.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMObjectBase, RLMProperty; |
||||
|
||||
@interface RLMOptionalBase : NSProxy |
||||
- (instancetype)init; |
||||
@end |
||||
|
||||
FOUNDATION_EXTERN id _Nullable RLMGetOptional(RLMOptionalBase *); |
||||
FOUNDATION_EXTERN void RLMSetOptional(RLMOptionalBase *, id _Nullable); |
||||
|
||||
void RLMInitializeManagedOptional(RLMOptionalBase *, RLMObjectBase *parent, RLMProperty *prop); |
||||
void RLMInitializeUnmanagedOptional(RLMOptionalBase *, RLMObjectBase *parent, RLMProperty *prop); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
136
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMProperty_Private.h
generated
vendored
136
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMProperty_Private.h
generated
vendored
@ -0,0 +1,136 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMProperty.h> |
||||
|
||||
#import <objc/runtime.h> |
||||
|
||||
@class RLMObjectBase; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
BOOL RLMPropertyTypeIsComputed(RLMPropertyType propertyType); |
||||
FOUNDATION_EXTERN void RLMValidateSwiftPropertyName(NSString *name); |
||||
|
||||
// Translate an rlmtype to a string representation
|
||||
static inline NSString *RLMTypeToString(RLMPropertyType type) { |
||||
switch (type) { |
||||
case RLMPropertyTypeString: |
||||
return @"string"; |
||||
case RLMPropertyTypeInt: |
||||
return @"int"; |
||||
case RLMPropertyTypeBool: |
||||
return @"bool"; |
||||
case RLMPropertyTypeDate: |
||||
return @"date"; |
||||
case RLMPropertyTypeData: |
||||
return @"data"; |
||||
case RLMPropertyTypeDouble: |
||||
return @"double"; |
||||
case RLMPropertyTypeFloat: |
||||
return @"float"; |
||||
case RLMPropertyTypeAny: |
||||
return @"any"; |
||||
case RLMPropertyTypeObject: |
||||
return @"object"; |
||||
case RLMPropertyTypeLinkingObjects: |
||||
return @"linking objects"; |
||||
} |
||||
return @"Unknown"; |
||||
} |
||||
|
||||
// private property interface
|
||||
@interface RLMProperty () { |
||||
@public |
||||
RLMPropertyType _type; |
||||
Ivar _swiftIvar; |
||||
} |
||||
|
||||
- (instancetype)initWithName:(NSString *)name |
||||
indexed:(BOOL)indexed |
||||
linkPropertyDescriptor:(nullable RLMPropertyDescriptor *)linkPropertyDescriptor |
||||
property:(objc_property_t)property; |
||||
|
||||
- (instancetype)initSwiftPropertyWithName:(NSString *)name |
||||
indexed:(BOOL)indexed |
||||
linkPropertyDescriptor:(nullable RLMPropertyDescriptor *)linkPropertyDescriptor |
||||
property:(objc_property_t)property |
||||
instance:(RLMObjectBase *)objectInstance; |
||||
|
||||
- (instancetype)initSwiftListPropertyWithName:(NSString *)name |
||||
instance:(id)object; |
||||
|
||||
- (instancetype)initSwiftOptionalPropertyWithName:(NSString *)name |
||||
indexed:(BOOL)indexed |
||||
ivar:(Ivar)ivar |
||||
propertyType:(RLMPropertyType)propertyType; |
||||
|
||||
- (instancetype)initSwiftLinkingObjectsPropertyWithName:(NSString *)name |
||||
ivar:(Ivar)ivar |
||||
objectClassName:(nullable NSString *)objectClassName |
||||
linkOriginPropertyName:(nullable NSString *)linkOriginPropertyName; |
||||
|
||||
// private setters
|
||||
@property (nonatomic, readwrite) NSString *name; |
||||
@property (nonatomic, readwrite, assign) RLMPropertyType type; |
||||
@property (nonatomic, readwrite) BOOL indexed; |
||||
@property (nonatomic, readwrite) BOOL optional; |
||||
@property (nonatomic, copy, nullable) NSString *objectClassName; |
||||
|
||||
// private properties
|
||||
@property (nonatomic, readwrite) NSString *columnName; |
||||
@property (nonatomic, assign) NSUInteger index; |
||||
@property (nonatomic, assign) BOOL isPrimary; |
||||
@property (nonatomic, assign) Ivar swiftIvar; |
||||
|
||||
// getter and setter names
|
||||
@property (nonatomic, copy) NSString *getterName; |
||||
@property (nonatomic, copy) NSString *setterName; |
||||
@property (nonatomic) SEL getterSel; |
||||
@property (nonatomic) SEL setterSel; |
||||
|
||||
- (RLMProperty *)copyWithNewName:(NSString *)name; |
||||
|
||||
@end |
||||
|
||||
@interface RLMProperty (Dynamic) |
||||
/**
|
||||
This method is useful only in specialized circumstances, for example, in conjunction with |
||||
+[RLMObjectSchema initWithClassName:objectClass:properties:]. If you are simply building an |
||||
app on Realm, it is not recommened to use this method. |
||||
|
||||
Initialize an RLMProperty |
||||
|
||||
@warning This method is useful only in specialized circumstances. |
||||
|
||||
@param name The property name. |
||||
@param type The property type. |
||||
@param objectClassName The object type used for Object and Array types. |
||||
@param linkOriginPropertyName The property name of the origin of a link. Used for linking objects properties. |
||||
|
||||
@return An initialized instance of RLMProperty. |
||||
*/ |
||||
- (instancetype)initWithName:(NSString *)name |
||||
type:(RLMPropertyType)type |
||||
objectClassName:(nullable NSString *)objectClassName |
||||
linkOriginPropertyName:(nullable NSString *)linkOriginPropertyName |
||||
indexed:(BOOL)indexed |
||||
optional:(BOOL)optional; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,45 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMRealmConfiguration.h> |
||||
|
||||
@class RLMSchema; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@interface RLMRealmConfiguration () |
||||
|
||||
@property (nonatomic, readwrite) bool cache; |
||||
@property (nonatomic, readwrite) bool dynamic; |
||||
@property (nonatomic, readwrite) bool disableFormatUpgrade; |
||||
@property (nonatomic, copy, nullable) RLMSchema *customSchema; |
||||
@property (nonatomic, copy) NSString *pathOnDisk; |
||||
|
||||
// Get the default confiugration without copying it
|
||||
+ (RLMRealmConfiguration *)rawDefaultConfiguration; |
||||
|
||||
+ (void)resetRealmConfigurationState; |
||||
|
||||
- (void)setCustomSchemaWithoutCopying:(nullable RLMSchema *)schema; |
||||
@end |
||||
|
||||
// Get a path in the platform-appropriate documents directory with the given filename
|
||||
FOUNDATION_EXTERN NSString *RLMRealmPathForFile(NSString *fileName); |
||||
FOUNDATION_EXTERN NSString *RLMRealmPathForFileAndBundleIdentifier(NSString *fileName, NSString *mainBundleIdentifier); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
54
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMRealm_Private.h
generated
vendored
54
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMRealm_Private.h
generated
vendored
@ -0,0 +1,54 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMRealm.h> |
||||
|
||||
@class RLMFastEnumerator, RLMSyncSubscription; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
// Disable syncing files to disk. Cannot be re-enabled. Use only for tests.
|
||||
FOUNDATION_EXTERN void RLMDisableSyncToDisk(void); |
||||
|
||||
FOUNDATION_EXTERN NSData * _Nullable RLMRealmValidatedEncryptionKey(NSData *key); |
||||
|
||||
FOUNDATION_EXTERN RLMSyncSubscription *RLMCastToSyncSubscription(id obj); |
||||
|
||||
// Translate an in-flight exception resulting from an operation on a SharedGroup to
|
||||
// an NSError or NSException (if error is nil)
|
||||
void RLMRealmTranslateException(NSError **error); |
||||
|
||||
// RLMRealm private members
|
||||
@interface RLMRealm () |
||||
|
||||
@property (nonatomic, readonly) BOOL dynamic; |
||||
@property (nonatomic, readwrite) RLMSchema *schema; |
||||
|
||||
+ (void)resetRealmState; |
||||
|
||||
- (void)registerEnumerator:(RLMFastEnumerator *)enumerator; |
||||
- (void)unregisterEnumerator:(RLMFastEnumerator *)enumerator; |
||||
- (void)detachAllEnumerators; |
||||
|
||||
- (void)sendNotifications:(RLMNotification)notification; |
||||
- (void)verifyThread; |
||||
- (void)verifyNotificationsAreSupported:(bool)isCollection; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
32
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMResults_Private.h
generated
vendored
32
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMResults_Private.h
generated
vendored
@ -0,0 +1,32 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMResults.h> |
||||
|
||||
@class RLMObjectSchema; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@interface RLMResults () |
||||
@property (nonatomic, readonly, getter=isAttached) BOOL attached; |
||||
|
||||
+ (instancetype)emptyDetachedResults; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
58
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMSchema_Private.h
generated
vendored
58
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMSchema_Private.h
generated
vendored
@ -0,0 +1,58 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMSchema.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMRealm; |
||||
|
||||
//
|
||||
// RLMSchema private interface
|
||||
//
|
||||
@interface RLMSchema () |
||||
|
||||
/**
|
||||
Returns an `RLMSchema` containing only the given `RLMObject` subclasses. |
||||
|
||||
@param classes The classes to be included in the schema. |
||||
|
||||
@return An `RLMSchema` containing only the given classes. |
||||
*/ |
||||
+ (instancetype)schemaWithObjectClasses:(NSArray<Class> *)classes; |
||||
|
||||
@property (nonatomic, readwrite, copy) NSArray<RLMObjectSchema *> *objectSchema; |
||||
|
||||
// schema based on runtime objects
|
||||
+ (instancetype)sharedSchema; |
||||
|
||||
// schema based upon all currently registered object classes
|
||||
+ (instancetype)partialSharedSchema; |
||||
|
||||
// private schema based upon all currently registered object classes.
|
||||
// includes classes that are excluded from the default schema.
|
||||
+ (instancetype)partialPrivateSharedSchema; |
||||
|
||||
// class for string
|
||||
+ (nullable Class)classForString:(NSString *)className; |
||||
|
||||
+ (nullable RLMObjectSchema *)sharedSchemaForClass:(Class)cls; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,48 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMSyncConfiguration.h> |
||||
|
||||
#import <Realm/RLMConstants.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
typedef RLM_CLOSED_ENUM(NSUInteger, RLMSyncStopPolicy) { |
||||
RLMSyncStopPolicyImmediately, |
||||
RLMSyncStopPolicyLiveIndefinitely, |
||||
RLMSyncStopPolicyAfterChangesUploaded, |
||||
}; |
||||
|
||||
@interface RLMSyncConfiguration () |
||||
|
||||
- (instancetype)initWithUser:(RLMSyncUser *)user |
||||
realmURL:(NSURL *)url |
||||
isPartial:(BOOL)isPartial |
||||
urlPrefix:(nullable NSString *)urlPrefix |
||||
stopPolicy:(RLMSyncStopPolicy)stopPolicy |
||||
enableSSLValidation:(BOOL)enableSSLValidation |
||||
certificatePath:(nullable NSURL *)certificatePath; |
||||
|
||||
@property (nonatomic, readwrite) RLMSyncStopPolicy stopPolicy; |
||||
|
||||
// Internal-only APIs
|
||||
@property (nullable, nonatomic) NSURL *customFileURL; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
27
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMSyncPermissionResults.h
generated
vendored
27
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMSyncPermissionResults.h
generated
vendored
@ -0,0 +1,27 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2017 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import "RLMResults.h" |
||||
|
||||
@class RLMSyncPermission; |
||||
|
||||
// A private subclass of `RLMResults`.
|
||||
@interface RLMSyncPermissionResults : RLMResults<RLMSyncPermission *> |
||||
@end |
||||
135
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMSyncUtil_Private.h
generated
vendored
135
Carthage/Build/Mac/Realm.framework/Versions/A/PrivateHeaders/RLMSyncUtil_Private.h
generated
vendored
@ -0,0 +1,135 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMSyncUtil.h> |
||||
|
||||
#import <Realm/RLMProperty.h> |
||||
#import <Realm/RLMRealmConfiguration.h> |
||||
#import <Realm/RLMSyncCredentials.h> |
||||
|
||||
typedef NS_ENUM(NSUInteger, RLMSyncSystemErrorKind) { |
||||
// Specific
|
||||
RLMSyncSystemErrorKindClientReset, |
||||
RLMSyncSystemErrorKindPermissionDenied, |
||||
// General
|
||||
RLMSyncSystemErrorKindClient, |
||||
RLMSyncSystemErrorKindConnection, |
||||
RLMSyncSystemErrorKindSession, |
||||
RLMSyncSystemErrorKindUser, |
||||
RLMSyncSystemErrorKindUnknown, |
||||
}; |
||||
|
||||
@class RLMSyncUser; |
||||
|
||||
typedef void(^RLMSyncCompletionBlock)(NSError * _Nullable, NSDictionary * _Nullable); |
||||
typedef void(^RLMSyncBasicErrorReportingBlock)(NSError * _Nullable); |
||||
|
||||
typedef NSString* RLMServerPath; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
extern RLMIdentityProvider const RLMIdentityProviderAccessToken; |
||||
extern RLMIdentityProvider const RLMIdentityProviderRealm; |
||||
|
||||
extern NSString *const kRLMSyncAppIDKey; |
||||
extern NSString *const kRLMSyncDataKey; |
||||
extern NSString *const kRLMSyncErrorJSONKey; |
||||
extern NSString *const kRLMSyncErrorStatusCodeKey; |
||||
extern NSString *const kRLMSyncIdentityKey; |
||||
extern NSString *const kRLMSyncIsAdminKey; |
||||
extern NSString *const kRLMSyncNewPasswordKey; |
||||
extern NSString *const kRLMSyncPasswordKey; |
||||
extern NSString *const kRLMSyncPathKey; |
||||
extern NSString *const kRLMSyncTokenKey; |
||||
extern NSString *const kRLMSyncProviderKey; |
||||
extern NSString *const kRLMSyncProviderIDKey; |
||||
extern NSString *const kRLMSyncRegisterKey; |
||||
extern NSString *const kRLMSyncUnderlyingErrorKey; |
||||
extern NSString *const kRLMSyncUserIDKey; |
||||
|
||||
FOUNDATION_EXTERN uint8_t RLMGetComputedPermissions(RLMRealm *realm, id _Nullable object); |
||||
|
||||
#define RLM_SYNC_UNINITIALIZABLE \ |
||||
- (instancetype)init __attribute__((unavailable("This type cannot be created directly"))); \
|
||||
+ (instancetype)new __attribute__((unavailable("This type cannot be created directly"))); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
|
||||
/// A macro to parse a string out of a JSON dictionary, or return nil.
|
||||
#define RLM_SYNC_PARSE_STRING_OR_ABORT(json_macro_val, key_macro_val, prop_macro_val) \ |
||||
{ \
|
||||
id data = json_macro_val[key_macro_val]; \
|
||||
if (![data isKindOfClass:[NSString class]]) { return nil; } \
|
||||
self.prop_macro_val = data; \
|
||||
} \
|
||||
|
||||
#define RLM_SYNC_PARSE_OPTIONAL_STRING(json_macro_val, key_macro_val, prop_macro_val) \ |
||||
{ \
|
||||
id data = json_macro_val[key_macro_val]; \
|
||||
if (![data isKindOfClass:[NSString class]]) { data = nil; } \
|
||||
self.prop_macro_val = data; \
|
||||
} \
|
||||
|
||||
#define RLM_SYNC_PARSE_OPTIONAL_BOOL(json_macro_val, key_macro_val, prop_macro_val) \ |
||||
{ \
|
||||
id data = json_macro_val[key_macro_val]; \
|
||||
if (![data isKindOfClass:[NSNumber class]]) { data = @NO; } \
|
||||
self.prop_macro_val = [data boolValue]; \
|
||||
} \
|
||||
|
||||
/// A macro to parse a double out of a JSON dictionary, or return nil.
|
||||
#define RLM_SYNC_PARSE_DOUBLE_OR_ABORT(json_macro_val, key_macro_val, prop_macro_val) \ |
||||
{ \
|
||||
id data = json_macro_val[key_macro_val]; \
|
||||
if (![data isKindOfClass:[NSNumber class]]) { return nil; } \
|
||||
self.prop_macro_val = [data doubleValue]; \
|
||||
} \
|
||||
|
||||
/// A macro to build a sub-model out of a JSON dictionary, or return nil.
|
||||
#define RLM_SYNC_PARSE_MODEL_OR_ABORT(json_macro_val, key_macro_val, class_macro_val, prop_macro_val) \ |
||||
{ \
|
||||
id raw = json_macro_val[key_macro_val]; \
|
||||
if (![raw isKindOfClass:[NSDictionary class]]) { return nil; } \
|
||||
id model = [[class_macro_val alloc] initWithDictionary:raw]; \
|
||||
if (!model) { return nil; } \
|
||||
self.prop_macro_val = model; \
|
||||
} \
|
||||
|
||||
/// A macro to build an array of sub-models out of a JSON dictionary, or return nil.
|
||||
#define RLM_SYNC_PARSE_MODEL_ARRAY_OR_ABORT(json_macro_val, key_macro_val, class_macro_val, prop_macro_val) \ |
||||
{ \
|
||||
NSArray *jsonArray = json_macro_val[key_macro_val]; \
|
||||
if (![jsonArray isKindOfClass:[NSArray class]]) { return nil; } \
|
||||
NSMutableArray *buffer = [NSMutableArray array]; \
|
||||
for (id value in jsonArray) { \
|
||||
id next = nil; \
|
||||
if ([value isKindOfClass:[NSDictionary class]]) { next = [[class_macro_val alloc] initWithDictionary:value]; } \
|
||||
if (!next) { return nil; } \
|
||||
[buffer addObject:next]; \
|
||||
} \
|
||||
self.prop_macro_val = [buffer copy]; \
|
||||
} \
|
||||
|
||||
#define RLM_SYNC_PARSE_OPTIONAL_MODEL(json_macro_val, key_macro_val, class_macro_val, prop_macro_val) \ |
||||
{ \
|
||||
id model; \
|
||||
id raw = json_macro_val[key_macro_val]; \
|
||||
if (![raw isKindOfClass:[NSDictionary class]]) { model = nil; } \
|
||||
else { model = [[class_macro_val alloc] initWithDictionary:raw]; } \
|
||||
self.prop_macro_val = model; \
|
||||
} \
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,53 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>BuildMachineOSBuild</key> |
||||
<string>18D109</string> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>English</string> |
||||
<key>CFBundleExecutable</key> |
||||
<string>Realm</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>io.Realm.Realm</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleName</key> |
||||
<string>Realm</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>FMWK</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>3.16.1</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>CFBundleSupportedPlatforms</key> |
||||
<array> |
||||
<string>MacOSX</string> |
||||
</array> |
||||
<key>CFBundleVersion</key> |
||||
<string>3.16.1</string> |
||||
<key>DTCompiler</key> |
||||
<string>com.apple.compilers.llvm.clang.1_0</string> |
||||
<key>DTPlatformBuild</key> |
||||
<string>10E1001</string> |
||||
<key>DTPlatformVersion</key> |
||||
<string>GM</string> |
||||
<key>DTSDKBuild</key> |
||||
<string>18E219</string> |
||||
<key>DTSDKName</key> |
||||
<string>macosx10.14</string> |
||||
<key>DTXcode</key> |
||||
<string>1020</string> |
||||
<key>DTXcodeBuild</key> |
||||
<string>10E1001</string> |
||||
<key>NSHumanReadableCopyright</key> |
||||
<string>Copyright © 2014 Realm. All rights reserved.</string> |
||||
<key>UIDeviceFamily</key> |
||||
<array> |
||||
<integer>1</integer> |
||||
<integer>2</integer> |
||||
<integer>3</integer> |
||||
<integer>4</integer> |
||||
</array> |
||||
</dict> |
||||
</plist> |
||||
@ -0,0 +1,248 @@ |
||||
TABLE OF CONTENTS |
||||
|
||||
1. Apache License version 2.0 |
||||
2. Realm Components |
||||
3. Export Compliance |
||||
|
||||
1. ------------------------------------------------------------------------------- |
||||
|
||||
Apache License |
||||
Version 2.0, January 2004 |
||||
http://www.apache.org/licenses/ |
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||
|
||||
1. Definitions. |
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, |
||||
and distribution as defined by Sections 1 through 9 of this document. |
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by |
||||
the copyright owner that is granting the License. |
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all |
||||
other entities that control, are controlled by, or are under common |
||||
control with that entity. For the purposes of this definition, |
||||
"control" means (i) the power, direct or indirect, to cause the |
||||
direction or management of such entity, whether by contract or |
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||
outstanding shares, or (iii) beneficial ownership of such entity. |
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity |
||||
exercising permissions granted by this License. |
||||
|
||||
"Source" form shall mean the preferred form for making modifications, |
||||
including but not limited to software source code, documentation |
||||
source, and configuration files. |
||||
|
||||
"Object" form shall mean any form resulting from mechanical |
||||
transformation or translation of a Source form, including but |
||||
not limited to compiled object code, generated documentation, |
||||
and conversions to other media types. |
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or |
||||
Object form, made available under the License, as indicated by a |
||||
copyright notice that is included in or attached to the work |
||||
(an example is provided in the Appendix below). |
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object |
||||
form, that is based on (or derived from) the Work and for which the |
||||
editorial revisions, annotations, elaborations, or other modifications |
||||
represent, as a whole, an original work of authorship. For the purposes |
||||
of this License, Derivative Works shall not include works that remain |
||||
separable from, or merely link (or bind by name) to the interfaces of, |
||||
the Work and Derivative Works thereof. |
||||
|
||||
"Contribution" shall mean any work of authorship, including |
||||
the original version of the Work and any modifications or additions |
||||
to that Work or Derivative Works thereof, that is intentionally |
||||
submitted to Licensor for inclusion in the Work by the copyright owner |
||||
or by an individual or Legal Entity authorized to submit on behalf of |
||||
the copyright owner. For the purposes of this definition, "submitted" |
||||
means any form of electronic, verbal, or written communication sent |
||||
to the Licensor or its representatives, including but not limited to |
||||
communication on electronic mailing lists, source code control systems, |
||||
and issue tracking systems that are managed by, or on behalf of, the |
||||
Licensor for the purpose of discussing and improving the Work, but |
||||
excluding communication that is conspicuously marked or otherwise |
||||
designated in writing by the copyright owner as "Not a Contribution." |
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity |
||||
on behalf of whom a Contribution has been received by Licensor and |
||||
subsequently incorporated within the Work. |
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
copyright license to reproduce, prepare Derivative Works of, |
||||
publicly display, publicly perform, sublicense, and distribute the |
||||
Work and such Derivative Works in Source or Object form. |
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
(except as stated in this section) patent license to make, have made, |
||||
use, offer to sell, sell, import, and otherwise transfer the Work, |
||||
where such license applies only to those patent claims licensable |
||||
by such Contributor that are necessarily infringed by their |
||||
Contribution(s) alone or by combination of their Contribution(s) |
||||
with the Work to which such Contribution(s) was submitted. If You |
||||
institute patent litigation against any entity (including a |
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work |
||||
or a Contribution incorporated within the Work constitutes direct |
||||
or contributory patent infringement, then any patent licenses |
||||
granted to You under this License for that Work shall terminate |
||||
as of the date such litigation is filed. |
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the |
||||
Work or Derivative Works thereof in any medium, with or without |
||||
modifications, and in Source or Object form, provided that You |
||||
meet the following conditions: |
||||
|
||||
(a) You must give any other recipients of the Work or |
||||
Derivative Works a copy of this License; and |
||||
|
||||
(b) You must cause any modified files to carry prominent notices |
||||
stating that You changed the files; and |
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works |
||||
that You distribute, all copyright, patent, trademark, and |
||||
attribution notices from the Source form of the Work, |
||||
excluding those notices that do not pertain to any part of |
||||
the Derivative Works; and |
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its |
||||
distribution, then any Derivative Works that You distribute must |
||||
include a readable copy of the attribution notices contained |
||||
within such NOTICE file, excluding those notices that do not |
||||
pertain to any part of the Derivative Works, in at least one |
||||
of the following places: within a NOTICE text file distributed |
||||
as part of the Derivative Works; within the Source form or |
||||
documentation, if provided along with the Derivative Works; or, |
||||
within a display generated by the Derivative Works, if and |
||||
wherever such third-party notices normally appear. The contents |
||||
of the NOTICE file are for informational purposes only and |
||||
do not modify the License. You may add Your own attribution |
||||
notices within Derivative Works that You distribute, alongside |
||||
or as an addendum to the NOTICE text from the Work, provided |
||||
that such additional attribution notices cannot be construed |
||||
as modifying the License. |
||||
|
||||
You may add Your own copyright statement to Your modifications and |
||||
may provide additional or different license terms and conditions |
||||
for use, reproduction, or distribution of Your modifications, or |
||||
for any such Derivative Works as a whole, provided Your use, |
||||
reproduction, and distribution of the Work otherwise complies with |
||||
the conditions stated in this License. |
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, |
||||
any Contribution intentionally submitted for inclusion in the Work |
||||
by You to the Licensor shall be under the terms and conditions of |
||||
this License, without any additional terms or conditions. |
||||
Notwithstanding the above, nothing herein shall supersede or modify |
||||
the terms of any separate license agreement you may have executed |
||||
with Licensor regarding such Contributions. |
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade |
||||
names, trademarks, service marks, or product names of the Licensor, |
||||
except as required for reasonable and customary use in describing the |
||||
origin of the Work and reproducing the content of the NOTICE file. |
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or |
||||
agreed to in writing, Licensor provides the Work (and each |
||||
Contributor provides its Contributions) on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
||||
implied, including, without limitation, any warranties or conditions |
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
||||
PARTICULAR PURPOSE. You are solely responsible for determining the |
||||
appropriateness of using or redistributing the Work and assume any |
||||
risks associated with Your exercise of permissions under this License. |
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, |
||||
whether in tort (including negligence), contract, or otherwise, |
||||
unless required by applicable law (such as deliberate and grossly |
||||
negligent acts) or agreed to in writing, shall any Contributor be |
||||
liable to You for damages, including any direct, indirect, special, |
||||
incidental, or consequential damages of any character arising as a |
||||
result of this License or out of the use or inability to use the |
||||
Work (including but not limited to damages for loss of goodwill, |
||||
work stoppage, computer failure or malfunction, or any and all |
||||
other commercial damages or losses), even if such Contributor |
||||
has been advised of the possibility of such damages. |
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing |
||||
the Work or Derivative Works thereof, You may choose to offer, |
||||
and charge a fee for, acceptance of support, warranty, indemnity, |
||||
or other liability obligations and/or rights consistent with this |
||||
License. However, in accepting such obligations, You may act only |
||||
on Your own behalf and on Your sole responsibility, not on behalf |
||||
of any other Contributor, and only if You agree to indemnify, |
||||
defend, and hold each Contributor harmless for any liability |
||||
incurred by, or claims asserted against, such Contributor by reason |
||||
of your accepting any such warranty or additional liability. |
||||
|
||||
2. ------------------------------------------------------------------------------- |
||||
|
||||
REALM COMPONENTS |
||||
|
||||
This software contains components with separate copyright and license terms. |
||||
Your use of these components is subject to the terms and conditions of the |
||||
following licenses. |
||||
|
||||
For the Realm Platform Extensions component |
||||
|
||||
Realm Platform Extensions License |
||||
|
||||
Copyright (c) 2011-2017 Realm Inc All rights reserved |
||||
|
||||
Redistribution and use in binary form, with or without modification, is |
||||
permitted provided that the following conditions are met: |
||||
|
||||
1. You agree not to attempt to decompile, disassemble, reverse engineer or |
||||
otherwise discover the source code from which the binary code was derived. |
||||
You may, however, access and obtain a separate license for most of the |
||||
source code from which this Software was created, at |
||||
http://realm.io/pricing/. |
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation |
||||
and/or other materials provided with the distribution. |
||||
|
||||
3. Neither the name of the copyright holder nor the names of its |
||||
contributors may be used to endorse or promote products derived from this |
||||
software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||||
POSSIBILITY OF SUCH DAMAGE. |
||||
|
||||
3. ------------------------------------------------------------------------------- |
||||
|
||||
EXPORT COMPLIANCE |
||||
|
||||
You understand that the Software may contain cryptographic functions that may be |
||||
subject to export restrictions, and you represent and warrant that you are not |
||||
(i) located in a jurisdiction that is subject to United States economic |
||||
sanctions (“Prohibited Jurisdiction”), including Cuba, Iran, North Korea, |
||||
Sudan, Syria or the Crimea region, (ii) a person listed on any U.S. government |
||||
blacklist (to include the List of Specially Designated Nationals and Blocked |
||||
Persons or the Consolidated Sanctions List administered by the U.S. Department |
||||
of the Treasury’s Office of Foreign Assets Control, or the Denied Persons List |
||||
or Entity List administered by the U.S. Department of Commerce) |
||||
(“Sanctioned Person”), or (iii) controlled or 50% or more owned by a Sanctioned |
||||
Person. |
||||
|
||||
You agree to comply with all export, re-export and import restrictions and |
||||
regulations of the U.S. Department of Commerce or other agency or authority of |
||||
the United States or other applicable countries. You also agree not to transfer, |
||||
or authorize the transfer of, directly or indirectly, of the Software to any |
||||
Prohibited Jurisdiction, or otherwise in violation of any such restrictions or |
||||
regulations. |
||||
@ -0,0 +1,72 @@ |
||||
################################################################################ |
||||
# |
||||
# Copyright 2015 Realm Inc. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
# |
||||
################################################################################ |
||||
|
||||
# This script strips all non-valid architectures from dynamic libraries in |
||||
# the application's `Frameworks` directory. |
||||
# |
||||
# The following environment variables are required: |
||||
# |
||||
# BUILT_PRODUCTS_DIR |
||||
# FRAMEWORKS_FOLDER_PATH |
||||
# VALID_ARCHS |
||||
# EXPANDED_CODE_SIGN_IDENTITY |
||||
|
||||
|
||||
# Signs a framework with the provided identity |
||||
code_sign() { |
||||
# Use the current code_sign_identitiy |
||||
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" |
||||
echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements $1" |
||||
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" |
||||
} |
||||
|
||||
# Set working directory to product’s embedded frameworks |
||||
cd "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}" |
||||
|
||||
if [ "$ACTION" = "install" ]; then |
||||
echo "Copy .bcsymbolmap files to .xcarchive" |
||||
find . -name '*.bcsymbolmap' -type f -exec mv {} "${CONFIGURATION_BUILD_DIR}" \; |
||||
else |
||||
# Delete *.bcsymbolmap files from framework bundle unless archiving |
||||
find . -name '*.bcsymbolmap' -type f -exec rm -rf "{}" +\; |
||||
fi |
||||
|
||||
echo "Stripping frameworks" |
||||
|
||||
for file in $(find . -type f -perm +111); do |
||||
# Skip non-dynamic libraries |
||||
if ! [[ "$(file "$file")" == *"dynamically linked shared library"* ]]; then |
||||
continue |
||||
fi |
||||
# Get architectures for current file |
||||
archs="$(lipo -info "${file}" | rev | cut -d ':' -f1 | rev)" |
||||
stripped="" |
||||
for arch in $archs; do |
||||
if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then |
||||
# Strip non-valid architectures in-place |
||||
lipo -remove "$arch" -output "$file" "$file" || exit 1 |
||||
stripped="$stripped $arch" |
||||
fi |
||||
done |
||||
if [[ "$stripped" != "" ]]; then |
||||
echo "Stripped $file of architectures:$stripped" |
||||
if [ "${CODE_SIGNING_REQUIRED}" == "YES" ]; then |
||||
code_sign "${file}" |
||||
fi |
||||
fi |
||||
done |
||||
@ -0,0 +1 @@ |
||||
A |
||||
@ -0,0 +1,20 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>English</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>com.apple.xcode.dsym.io.realm.RealmSwit</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>dSYM</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>3.16.1</string> |
||||
<key>CFBundleVersion</key> |
||||
<string>3.16.1</string> |
||||
</dict> |
||||
</plist> |
||||
BIN
Carthage/Build/Mac/RealmSwift.framework.dSYM/Contents/Resources/DWARF/RealmSwift
generated
vendored
BIN
Carthage/Build/Mac/RealmSwift.framework.dSYM/Contents/Resources/DWARF/RealmSwift
generated
vendored
Binary file not shown.
@ -0,0 +1 @@ |
||||
Versions/Current/Headers |
||||
@ -0,0 +1 @@ |
||||
Versions/Current/Modules |
||||
@ -0,0 +1 @@ |
||||
Versions/Current/RealmSwift |
||||
@ -0,0 +1 @@ |
||||
Versions/Current/Resources |
||||
513
Carthage/Build/Mac/RealmSwift.framework/Versions/A/Headers/RealmSwift-Swift.h
generated
vendored
513
Carthage/Build/Mac/RealmSwift.framework/Versions/A/Headers/RealmSwift-Swift.h
generated
vendored
@ -0,0 +1,513 @@ |
||||
// Generated by Apple Swift version 5.0.1 effective-4.1.50 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
|
||||
#pragma clang diagnostic push |
||||
#pragma clang diagnostic ignored "-Wgcc-compat" |
||||
|
||||
#if !defined(__has_include) |
||||
# define __has_include(x) 0 |
||||
#endif |
||||
#if !defined(__has_attribute) |
||||
# define __has_attribute(x) 0 |
||||
#endif |
||||
#if !defined(__has_feature) |
||||
# define __has_feature(x) 0 |
||||
#endif |
||||
#if !defined(__has_warning) |
||||
# define __has_warning(x) 0 |
||||
#endif |
||||
|
||||
#if __has_include(<swift/objc-prologue.h>) |
||||
# include <swift/objc-prologue.h> |
||||
#endif |
||||
|
||||
#pragma clang diagnostic ignored "-Wauto-import" |
||||
#include <Foundation/Foundation.h> |
||||
#include <stdint.h> |
||||
#include <stddef.h> |
||||
#include <stdbool.h> |
||||
|
||||
#if !defined(SWIFT_TYPEDEFS) |
||||
# define SWIFT_TYPEDEFS 1 |
||||
# if __has_include(<uchar.h>) |
||||
# include <uchar.h> |
||||
# elif !defined(__cplusplus) |
||||
typedef uint_least16_t char16_t; |
||||
typedef uint_least32_t char32_t; |
||||
# endif |
||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2))); |
||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3))); |
||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4))); |
||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2))); |
||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3))); |
||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4))); |
||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2))); |
||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3))); |
||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4))); |
||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2))); |
||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3))); |
||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4))); |
||||
#endif |
||||
|
||||
#if !defined(SWIFT_PASTE) |
||||
# define SWIFT_PASTE_HELPER(x, y) x##y |
||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y) |
||||
#endif |
||||
#if !defined(SWIFT_METATYPE) |
||||
# define SWIFT_METATYPE(X) Class |
||||
#endif |
||||
#if !defined(SWIFT_CLASS_PROPERTY) |
||||
# if __has_feature(objc_class_property) |
||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__ |
||||
# else |
||||
# define SWIFT_CLASS_PROPERTY(...) |
||||
# endif |
||||
#endif |
||||
|
||||
#if __has_attribute(objc_runtime_name) |
||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X))) |
||||
#else |
||||
# define SWIFT_RUNTIME_NAME(X) |
||||
#endif |
||||
#if __has_attribute(swift_name) |
||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X))) |
||||
#else |
||||
# define SWIFT_COMPILE_NAME(X) |
||||
#endif |
||||
#if __has_attribute(objc_method_family) |
||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X))) |
||||
#else |
||||
# define SWIFT_METHOD_FAMILY(X) |
||||
#endif |
||||
#if __has_attribute(noescape) |
||||
# define SWIFT_NOESCAPE __attribute__((noescape)) |
||||
#else |
||||
# define SWIFT_NOESCAPE |
||||
#endif |
||||
#if __has_attribute(warn_unused_result) |
||||
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
||||
#else |
||||
# define SWIFT_WARN_UNUSED_RESULT |
||||
#endif |
||||
#if __has_attribute(noreturn) |
||||
# define SWIFT_NORETURN __attribute__((noreturn)) |
||||
#else |
||||
# define SWIFT_NORETURN |
||||
#endif |
||||
#if !defined(SWIFT_CLASS_EXTRA) |
||||
# define SWIFT_CLASS_EXTRA |
||||
#endif |
||||
#if !defined(SWIFT_PROTOCOL_EXTRA) |
||||
# define SWIFT_PROTOCOL_EXTRA |
||||
#endif |
||||
#if !defined(SWIFT_ENUM_EXTRA) |
||||
# define SWIFT_ENUM_EXTRA |
||||
#endif |
||||
#if !defined(SWIFT_CLASS) |
||||
# if __has_attribute(objc_subclassing_restricted) |
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA |
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA |
||||
# else |
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA |
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA |
||||
# endif |
||||
#endif |
||||
|
||||
#if !defined(SWIFT_PROTOCOL) |
||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA |
||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA |
||||
#endif |
||||
|
||||
#if !defined(SWIFT_EXTENSION) |
||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__) |
||||
#endif |
||||
|
||||
#if !defined(OBJC_DESIGNATED_INITIALIZER) |
||||
# if __has_attribute(objc_designated_initializer) |
||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) |
||||
# else |
||||
# define OBJC_DESIGNATED_INITIALIZER |
||||
# endif |
||||
#endif |
||||
#if !defined(SWIFT_ENUM_ATTR) |
||||
# if defined(__has_attribute) && __has_attribute(enum_extensibility) |
||||
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility))) |
||||
# else |
||||
# define SWIFT_ENUM_ATTR(_extensibility) |
||||
# endif |
||||
#endif |
||||
#if !defined(SWIFT_ENUM) |
||||
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type |
||||
# if __has_feature(generalized_swift_name) |
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type |
||||
# else |
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility) |
||||
# endif |
||||
#endif |
||||
#if !defined(SWIFT_UNAVAILABLE) |
||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable)) |
||||
#endif |
||||
#if !defined(SWIFT_UNAVAILABLE_MSG) |
||||
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg))) |
||||
#endif |
||||
#if !defined(SWIFT_AVAILABILITY) |
||||
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__))) |
||||
#endif |
||||
#if !defined(SWIFT_DEPRECATED) |
||||
# define SWIFT_DEPRECATED __attribute__((deprecated)) |
||||
#endif |
||||
#if !defined(SWIFT_DEPRECATED_MSG) |
||||
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__))) |
||||
#endif |
||||
#if __has_feature(attribute_diagnose_if_objc) |
||||
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning"))) |
||||
#else |
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg) |
||||
#endif |
||||
#if __has_feature(modules) |
||||
#if __has_warning("-Watimport-in-framework-header") |
||||
#pragma clang diagnostic ignored "-Watimport-in-framework-header" |
||||
#endif |
||||
@import Foundation; |
||||
@import ObjectiveC; |
||||
@import Realm; |
||||
@import Realm.Private; |
||||
#endif |
||||
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch" |
||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg" |
||||
#if __has_warning("-Wpragma-clang-attribute") |
||||
# pragma clang diagnostic ignored "-Wpragma-clang-attribute" |
||||
#endif |
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas" |
||||
#pragma clang diagnostic ignored "-Wnullability" |
||||
|
||||
#if __has_attribute(external_source_symbol) |
||||
# pragma push_macro("any") |
||||
# undef any |
||||
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="RealmSwift",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol)) |
||||
# pragma pop_macro("any") |
||||
#endif |
||||
|
||||
@class RLMRealm; |
||||
@class RLMObjectSchema; |
||||
@class RLMSchema; |
||||
|
||||
/// <code>Object</code> is a class used to define Realm model objects.
|
||||
/// In Realm you define your model classes by subclassing <code>Object</code> and adding properties to be managed.
|
||||
/// You then instantiate and use your custom subclasses instead of using the <code>Object</code> class directly.
|
||||
/// \code
|
||||
/// class Dog: Object {
|
||||
/// @objc dynamic var name: String = ""
|
||||
/// @objc dynamic var adopted: Bool = false
|
||||
/// let siblings = List<Dog>()
|
||||
/// }
|
||||
///
|
||||
/// \endcode<h3>Supported property types</h3>
|
||||
/// <ul>
|
||||
/// <li>
|
||||
/// <code>String</code>, <code>NSString</code>
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>Int</code>
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>Int8</code>, <code>Int16</code>, <code>Int32</code>, <code>Int64</code>
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>Float</code>
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>Double</code>
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>Bool</code>
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>Date</code>, <code>NSDate</code>
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>Data</code>, <code>NSData</code>
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>RealmOptional<Value></code> for optional numeric properties
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>Object</code> subclasses, to model many-to-one relationships
|
||||
/// </li>
|
||||
/// <li>
|
||||
/// <code>List<Element></code>, to model many-to-many relationships
|
||||
/// </li>
|
||||
/// </ul>
|
||||
/// <code>String</code>, <code>NSString</code>, <code>Date</code>, <code>NSDate</code>, <code>Data</code>, <code>NSData</code> and <code>Object</code> subclass properties can be declared as optional.
|
||||
/// <code>Int</code>, <code>Int8</code>, <code>Int16</code>, <code>Int32</code>, <code>Int64</code>, <code>Float</code>, <code>Double</code>, <code>Bool</code>, and <code>List</code> properties cannot. To store an optional
|
||||
/// number, use <code>RealmOptional<Int></code>, <code>RealmOptional<Float></code>, <code>RealmOptional<Double></code>, or <code>RealmOptional<Bool></code> instead,
|
||||
/// which wraps an optional numeric value.
|
||||
/// All property types except for <code>List</code> and <code>RealmOptional</code> <em>must</em> be declared as <code>@objc dynamic var</code>. <code>List</code> and
|
||||
/// <code>RealmOptional</code> properties must be declared as non-dynamic <code>let</code> properties. Swift <code>lazy</code> properties are not allowed.
|
||||
/// Note that none of the restrictions listed above apply to properties that are configured to be ignored by Realm.
|
||||
/// <h3>Querying</h3>
|
||||
/// You can retrieve all objects of a given type from a Realm by calling the <code>objects(_:)</code> instance method.
|
||||
/// <h3>Relationships</h3>
|
||||
/// See our <a href="http://realm.io/docs/cocoa">Cocoa guide</a> for more details.
|
||||
SWIFT_CLASS_NAMED("Object") |
||||
@interface RealmSwiftObject : RLMObjectBase |
||||
/// Creates an unmanaged instance of a Realm object.
|
||||
/// Call <code>add(_:)</code> on a <code>Realm</code> instance to add an unmanaged object into that Realm.
|
||||
/// <ul>
|
||||
/// <li>
|
||||
/// see: <code>Realm().add(_:)</code>
|
||||
/// </li>
|
||||
/// </ul>
|
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
/// Indicates if the object can no longer be accessed because it is now invalid.
|
||||
/// An object can no longer be accessed if the object has been deleted from the Realm that manages it, or if
|
||||
/// <code>invalidate()</code> is called on that Realm.
|
||||
@property (nonatomic, readonly, getter=isInvalidated) BOOL invalidated; |
||||
/// A human-readable description of the object.
|
||||
@property (nonatomic, readonly, copy) NSString * _Nonnull description; |
||||
/// WARNING: This is an internal helper method not intended for public use.
|
||||
/// It is not considered part of the public API.
|
||||
/// :nodoc:
|
||||
+ (Class _Nonnull)objectUtilClass:(BOOL)isSwift SWIFT_WARN_UNUSED_RESULT; |
||||
/// Override this method to specify the name of a property to be used as the primary key.
|
||||
/// Only properties of types <code>String</code> and <code>Int</code> can be designated as the primary key. Primary key properties enforce
|
||||
/// uniqueness for each value whenever the property is set, which incurs minor overhead. Indexes are created
|
||||
/// automatically for primary key properties.
|
||||
///
|
||||
/// returns:
|
||||
/// The name of the property designated as the primary key, or <code>nil</code> if the model has no primary key.
|
||||
+ (NSString * _Nullable)primaryKey SWIFT_WARN_UNUSED_RESULT; |
||||
/// Override this method to specify the names of properties to ignore. These properties will not be managed by
|
||||
/// the Realm that manages the object.
|
||||
///
|
||||
/// returns:
|
||||
/// An array of property names to ignore.
|
||||
+ (NSArray<NSString *> * _Nonnull)ignoredProperties SWIFT_WARN_UNUSED_RESULT; |
||||
/// Returns an array of property names for properties which should be indexed.
|
||||
/// Only string, integer, boolean, <code>Date</code>, and <code>NSDate</code> properties are supported.
|
||||
///
|
||||
/// returns:
|
||||
/// An array of property names.
|
||||
+ (NSArray<NSString *> * _Nonnull)indexedProperties SWIFT_WARN_UNUSED_RESULT; |
||||
- (id _Nullable)objectForKeyedSubscript:(NSString * _Nonnull)key SWIFT_WARN_UNUSED_RESULT; |
||||
- (void)setObject:(id _Nullable)value forKeyedSubscript:(NSString * _Nonnull)key; |
||||
/// WARNING: This is an internal initializer not intended for public use.
|
||||
/// :nodoc:
|
||||
- (nonnull instancetype)initWithRealm:(RLMRealm * _Nonnull)realm schema:(RLMObjectSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
/// WARNING: This is an internal initializer not intended for public use.
|
||||
/// :nodoc:
|
||||
- (nonnull instancetype)initWithValue:(id _Nonnull)value schema:(RLMSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
|
||||
/// An object which describes class-wide permissions.
|
||||
/// An instance of this object is automatically created in the Realm for class in your schema,
|
||||
/// and should not be created manually.
|
||||
SWIFT_CLASS_NAMED("ClassPermission") |
||||
@interface RealmSwiftClassPermission : RealmSwiftObject |
||||
/// The name of the class which these permissions apply to.
|
||||
@property (nonatomic, copy) NSString * _Nonnull name; |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)_realmObjectName SWIFT_WARN_UNUSED_RESULT; |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)primaryKey SWIFT_WARN_UNUSED_RESULT; |
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithRealm:(RLMRealm * _Nonnull)realm schema:(RLMObjectSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithValue:(id _Nonnull)value schema:(RLMSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
|
||||
/// Object interface which allows untyped getters and setters for Objects.
|
||||
/// :nodoc:
|
||||
SWIFT_CLASS("_TtC10RealmSwift13DynamicObject") |
||||
@interface DynamicObject : RealmSwiftObject |
||||
- (id _Nullable)objectForKeyedSubscript:(NSString * _Nonnull)key SWIFT_WARN_UNUSED_RESULT; |
||||
- (void)setObject:(id _Nullable)value forKeyedSubscript:(NSString * _Nonnull)key; |
||||
/// :nodoc:
|
||||
- (id _Nullable)valueForUndefinedKey:(NSString * _Nonnull)key SWIFT_WARN_UNUSED_RESULT; |
||||
/// :nodoc:
|
||||
- (void)setValue:(id _Nullable)value forUndefinedKey:(NSString * _Nonnull)key; |
||||
/// :nodoc:
|
||||
+ (BOOL)shouldIncludeInDefaultSchema SWIFT_WARN_UNUSED_RESULT; |
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithRealm:(RLMRealm * _Nonnull)realm schema:(RLMObjectSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithValue:(id _Nonnull)value schema:(RLMSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
|
||||
SWIFT_CLASS("_TtC10RealmSwift36KeyValueObservationNotificationToken") |
||||
@interface KeyValueObservationNotificationToken : RLMNotificationToken |
||||
- (void)invalidate; |
||||
- (nonnull instancetype)init SWIFT_UNAVAILABLE; |
||||
+ (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable"); |
||||
@end |
||||
|
||||
|
||||
/// :nodoc:
|
||||
/// Internal class. Do not use directly. Used for reflection and initialization
|
||||
SWIFT_CLASS("_TtC10RealmSwift18LinkingObjectsBase") |
||||
@interface LinkingObjectsBase : NSObject <NSFastEnumeration> |
||||
- (NSInteger)countByEnumeratingWithState:(NSFastEnumerationState * _Nonnull)state objects:(id _Nullable * _Nonnull)buffer count:(NSInteger)len SWIFT_WARN_UNUSED_RESULT; |
||||
- (nonnull instancetype)init SWIFT_UNAVAILABLE; |
||||
+ (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable"); |
||||
@end |
||||
|
||||
|
||||
/// :nodoc:
|
||||
/// Internal class. Do not use directly.
|
||||
SWIFT_CLASS("_TtC10RealmSwift8ListBase") |
||||
@interface ListBase : RLMListBase |
||||
/// Returns a human-readable description of the objects contained in the List.
|
||||
@property (nonatomic, readonly, copy) NSString * _Nonnull description; |
||||
- (nonnull instancetype)initWithArray:(RLMArray<id> * _Nonnull)array OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// :nodoc:
|
||||
/// Internal class. Do not use directly.
|
||||
SWIFT_CLASS_NAMED("ObjectUtil") |
||||
@interface RealmSwiftObjectUtil : NSObject |
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
@class RealmSwiftPermissionRole; |
||||
|
||||
/// A permission which can be applied to a Realm, Class, or specific Object.
|
||||
/// Permissions are applied by adding the permission to the RealmPermission singleton
|
||||
/// object, the ClassPermission object for the desired class, or to a user-defined
|
||||
/// List<Permission> property on a specific Object instance. The meaning of each of
|
||||
/// the properties of Permission depend on what the permission is applied to, and so are
|
||||
/// left undocumented here. See <code>RealmPrivileges</code>, <code>ClassPrivileges</code>, and
|
||||
/// <code>ObjectPrivileges</code> for details about what each of the properties mean when applied to
|
||||
/// that type.
|
||||
SWIFT_CLASS_NAMED("Permission") |
||||
@interface RealmSwiftPermission : RealmSwiftObject |
||||
/// The Role which this Permission applies to. All users within the Role are
|
||||
/// granted the permissions specified by the fields below any
|
||||
/// objects/classes/realms which use this Permission.
|
||||
/// This property cannot be modified once set.
|
||||
@property (nonatomic, strong) RealmSwiftPermissionRole * _Nullable role; |
||||
/// Whether the user can read the object to which this Permission is attached.
|
||||
@property (nonatomic) BOOL canRead; |
||||
/// Whether the user can modify the object to which this Permission is attached.
|
||||
@property (nonatomic) BOOL canUpdate; |
||||
/// Whether the user can delete the object to which this Permission is attached.
|
||||
/// This field is only applicable to Permissions attached to Objects, and not
|
||||
/// to Realms or Classes.
|
||||
@property (nonatomic) BOOL canDelete; |
||||
/// Whether the user can add or modify Permissions for the object which this
|
||||
/// Permission is attached to.
|
||||
@property (nonatomic) BOOL canSetPermissions; |
||||
/// Whether the user can subscribe to queries for this object type.
|
||||
/// This field is only applicable to Permissions attached to Classes, and not
|
||||
/// to Realms or Objects.
|
||||
@property (nonatomic) BOOL canQuery; |
||||
/// Whether the user can create new objects of the type this Permission is attached to.
|
||||
/// This field is only applicable to Permissions attached to Classes, and not
|
||||
/// to Realms or Objects.
|
||||
@property (nonatomic) BOOL canCreate; |
||||
/// Whether the user can modify the schema of the Realm which this
|
||||
/// Permission is attached to.
|
||||
/// This field is only applicable to Permissions attached to Realms, and not
|
||||
/// to Realms or Objects.
|
||||
@property (nonatomic) BOOL canModifySchema; |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)_realmObjectName SWIFT_WARN_UNUSED_RESULT; |
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithRealm:(RLMRealm * _Nonnull)realm schema:(RLMObjectSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithValue:(id _Nonnull)value schema:(RLMSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
|
||||
/// A Role within the permissions system.
|
||||
/// A Role consists of a name for the role and a list of users which are members of the role.
|
||||
/// Roles are granted privileges on Realms, Classes and Objects, and in turn grant those
|
||||
/// privileges to all users which are members of the role.
|
||||
/// A role named “everyone” is automatically created in new Realms, and all new users which
|
||||
/// connect to the Realm are automatically added to it. Any other roles you wish to use are
|
||||
/// managed as normal Realm objects.
|
||||
SWIFT_CLASS_NAMED("PermissionRole") |
||||
@interface RealmSwiftPermissionRole : RealmSwiftObject |
||||
/// The name of the Role
|
||||
@property (nonatomic, copy) NSString * _Nonnull name; |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)_realmObjectName SWIFT_WARN_UNUSED_RESULT; |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)primaryKey SWIFT_WARN_UNUSED_RESULT; |
||||
/// :nodoc:
|
||||
+ (NSDictionary<NSString *, NSString *> * _Nonnull)_realmColumnNames SWIFT_WARN_UNUSED_RESULT; |
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithRealm:(RLMRealm * _Nonnull)realm schema:(RLMObjectSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithValue:(id _Nonnull)value schema:(RLMSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
|
||||
/// A representation of a sync user within the permissions system.
|
||||
/// PermissionUser objects are created automatically for each sync user which connects to
|
||||
/// a Realm, and can also be created manually if you wish to grant permissions to a user
|
||||
/// which has not yet connected to this Realm. When creating a PermissionUser manually, you
|
||||
/// must also manually add it to the “everyone” Role.
|
||||
SWIFT_CLASS_NAMED("PermissionUser") |
||||
@interface RealmSwiftPermissionUser : RealmSwiftObject |
||||
/// The unique Realm Object Server user ID string identifying this user. This will
|
||||
/// have the same value as <code>SyncUser.identity</code>
|
||||
@property (nonatomic, copy) NSString * _Nonnull identity; |
||||
/// The user’s private role. This will be initialized to a role named for the user’s
|
||||
/// identity that contains this user as its only member.
|
||||
@property (nonatomic, strong) RealmSwiftPermissionRole * _Nullable role; |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)_realmObjectName SWIFT_WARN_UNUSED_RESULT; |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)primaryKey SWIFT_WARN_UNUSED_RESULT; |
||||
/// :nodoc:
|
||||
+ (NSDictionary<NSString *, NSString *> * _Nonnull)_realmColumnNames SWIFT_WARN_UNUSED_RESULT; |
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithRealm:(RLMRealm * _Nonnull)realm schema:(RLMObjectSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithValue:(id _Nonnull)value schema:(RLMSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// A singleton object which describes Realm-wide permissions.
|
||||
/// An object of this type is automatically created in the Realm for you, and more objects
|
||||
/// cannot be created manually.
|
||||
/// See <code>RealmPrivileges</code> for the meaning of permissions applied to a Realm.
|
||||
SWIFT_CLASS_NAMED("RealmPermission") |
||||
@interface RealmSwiftRealmPermission : RealmSwiftObject |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)_realmObjectName SWIFT_WARN_UNUSED_RESULT; |
||||
/// :nodoc:
|
||||
+ (NSString * _Nonnull)primaryKey SWIFT_WARN_UNUSED_RESULT; |
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithRealm:(RLMRealm * _Nonnull)realm schema:(RLMObjectSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
- (nonnull instancetype)initWithValue:(id _Nonnull)value schema:(RLMSchema * _Nonnull)schema OBJC_DESIGNATED_INITIALIZER; |
||||
@end |
||||
|
||||
#if __has_attribute(external_source_symbol) |
||||
# pragma clang attribute pop |
||||
#endif |
||||
#pragma clang diagnostic pop |
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,4 @@ |
||||
framework module RealmSwift { |
||||
header "RealmSwift-Swift.h" |
||||
requires objc |
||||
} |
||||
Binary file not shown.
@ -0,0 +1,46 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>BuildMachineOSBuild</key> |
||||
<string>18D109</string> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>English</string> |
||||
<key>CFBundleExecutable</key> |
||||
<string>RealmSwift</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>io.realm.RealmSwit</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundleName</key> |
||||
<string>RealmSwift</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>FMWK</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>3.16.1</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>CFBundleSupportedPlatforms</key> |
||||
<array> |
||||
<string>MacOSX</string> |
||||
</array> |
||||
<key>CFBundleVersion</key> |
||||
<string>3.16.1</string> |
||||
<key>DTCompiler</key> |
||||
<string>com.apple.compilers.llvm.clang.1_0</string> |
||||
<key>DTPlatformBuild</key> |
||||
<string>10E1001</string> |
||||
<key>DTPlatformVersion</key> |
||||
<string>GM</string> |
||||
<key>DTSDKBuild</key> |
||||
<string>18E219</string> |
||||
<key>DTSDKName</key> |
||||
<string>macosx10.14</string> |
||||
<key>DTXcode</key> |
||||
<string>1020</string> |
||||
<key>DTXcodeBuild</key> |
||||
<string>10E1001</string> |
||||
<key>NSHumanReadableCopyright</key> |
||||
<string>Copyright © 2014 Realm. All rights reserved.</string> |
||||
</dict> |
||||
</plist> |
||||
@ -0,0 +1 @@ |
||||
A |
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
||||
<plist version="1.0"> |
||||
<dict> |
||||
<key>CFBundleDevelopmentRegion</key> |
||||
<string>English</string> |
||||
<key>CFBundleIdentifier</key> |
||||
<string>com.apple.xcode.dsym.io.Realm.Realm</string> |
||||
<key>CFBundleInfoDictionaryVersion</key> |
||||
<string>6.0</string> |
||||
<key>CFBundlePackageType</key> |
||||
<string>dSYM</string> |
||||
<key>CFBundleSignature</key> |
||||
<string>????</string> |
||||
<key>CFBundleShortVersionString</key> |
||||
<string>3.16.1</string> |
||||
<key>CFBundleVersion</key> |
||||
<string>3.16.1</string> |
||||
</dict> |
||||
</plist> |
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2017 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMSyncErrorActionToken; |
||||
|
||||
/// NSError category extension providing methods to get data out of Realm's
|
||||
/// "client reset" error.
|
||||
@interface NSError (RLMSync) |
||||
|
||||
/**
|
||||
Given an appropriate Realm Object Server error, return the token that |
||||
can be passed into `+[RLMSyncSession immediatelyHandleError:]` to |
||||
immediately perform error clean-up work, or nil if the error isn't of |
||||
a type that provides a token. |
||||
*/ |
||||
- (nullable RLMSyncErrorActionToken *)rlmSync_errorActionToken NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Given a Realm Object Server client reset error, return the path where the |
||||
backup copy of the Realm will be placed once the client reset process is |
||||
complete. |
||||
*/ |
||||
- (nullable NSString *)rlmSync_clientResetBackedUpRealmPath NS_SWIFT_UNAVAILABLE(""); |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,440 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMCollection.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMObject, RLMResults<RLMObjectType>; |
||||
|
||||
/**
|
||||
`RLMArray` is the container type in Realm used to define to-many relationships. |
||||
|
||||
Unlike an `NSArray`, `RLMArray`s hold a single type, specified by the `objectClassName` property. |
||||
This is referred to in these docs as the “type” of the array. |
||||
|
||||
When declaring an `RLMArray` property, the type must be marked as conforming to a |
||||
protocol by the same name as the objects it should contain (see the |
||||
`RLM_ARRAY_TYPE` macro). In addition, the property can be declared using Objective-C |
||||
generics for better compile-time type safety. |
||||
|
||||
RLM_ARRAY_TYPE(ObjectType) |
||||
... |
||||
@property RLMArray<ObjectType *><ObjectType> *arrayOfObjectTypes; |
||||
|
||||
`RLMArray`s can be queried with the same predicates as `RLMObject` and `RLMResult`s. |
||||
|
||||
`RLMArray`s cannot be created directly. `RLMArray` properties on `RLMObject`s are |
||||
lazily created when accessed, or can be obtained by querying a Realm. |
||||
|
||||
### Key-Value Observing |
||||
|
||||
`RLMArray` supports array key-value observing on `RLMArray` properties on `RLMObject` |
||||
subclasses, and the `invalidated` property on `RLMArray` instances themselves is |
||||
key-value observing compliant when the `RLMArray` is attached to a managed |
||||
`RLMObject` (`RLMArray`s on unmanaged `RLMObject`s will never become invalidated). |
||||
|
||||
Because `RLMArray`s are attached to the object which they are a property of, they |
||||
do not require using the mutable collection proxy objects from |
||||
`-mutableArrayValueForKey:` or KVC-compatible mutation methods on the containing |
||||
object. Instead, you can call the mutation methods on the `RLMArray` directly. |
||||
*/ |
||||
|
||||
@interface RLMArray<RLMObjectType> : NSObject<RLMCollection, NSFastEnumeration> |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The number of objects in the array. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) NSUInteger count; |
||||
|
||||
/**
|
||||
The type of the objects in the array. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) RLMPropertyType type; |
||||
|
||||
/**
|
||||
Indicates whether the objects in the collection can be `nil`. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isOptional) BOOL optional; |
||||
|
||||
/**
|
||||
The class name of the objects contained in the array. |
||||
|
||||
Will be `nil` if `type` is not RLMPropertyTypeObject. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *objectClassName; |
||||
|
||||
/**
|
||||
The Realm which manages the array. Returns `nil` for unmanaged arrays. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) RLMRealm *realm; |
||||
|
||||
/**
|
||||
Indicates if the array can no longer be accessed. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
#pragma mark - Accessing Objects from an Array |
||||
|
||||
/**
|
||||
Returns the object at the index specified. |
||||
|
||||
@param index The index to look up. |
||||
|
||||
@return An object of the type contained in the array. |
||||
*/ |
||||
- (RLMObjectType)objectAtIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Returns the first object in the array. |
||||
|
||||
Returns `nil` if called on an empty array. |
||||
|
||||
@return An object of the type contained in the array. |
||||
*/ |
||||
- (nullable RLMObjectType)firstObject; |
||||
|
||||
/**
|
||||
Returns the last object in the array. |
||||
|
||||
Returns `nil` if called on an empty array. |
||||
|
||||
@return An object of the type contained in the array. |
||||
*/ |
||||
- (nullable RLMObjectType)lastObject; |
||||
|
||||
|
||||
|
||||
#pragma mark - Adding, Removing, and Replacing Objects in an Array |
||||
|
||||
/**
|
||||
Adds an object to the end of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param object An object of the type contained in the array. |
||||
*/ |
||||
- (void)addObject:(RLMObjectType)object; |
||||
|
||||
/**
|
||||
Adds an array of objects to the end of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param objects An enumerable object such as `NSArray` or `RLMResults` which contains objects of the |
||||
same class as the array. |
||||
*/ |
||||
- (void)addObjects:(id<NSFastEnumeration>)objects; |
||||
|
||||
/**
|
||||
Inserts an object at the given index. |
||||
|
||||
Throws an exception if the index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param anObject An object of the type contained in the array. |
||||
@param index The index at which to insert the object. |
||||
*/ |
||||
- (void)insertObject:(RLMObjectType)anObject atIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Removes an object at the given index. |
||||
|
||||
Throws an exception if the index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param index The array index identifying the object to be removed. |
||||
*/ |
||||
- (void)removeObjectAtIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Removes the last object in the array. |
||||
|
||||
This is a no-op if the array is already empty. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
*/ |
||||
- (void)removeLastObject; |
||||
|
||||
/**
|
||||
Removes all objects from the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
*/ |
||||
- (void)removeAllObjects; |
||||
|
||||
/**
|
||||
Replaces an object at the given index with a new object. |
||||
|
||||
Throws an exception if the index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param index The index of the object to be replaced. |
||||
@param anObject An object (of the same type as returned from the `objectClassName` selector). |
||||
*/ |
||||
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(RLMObjectType)anObject; |
||||
|
||||
/**
|
||||
Moves the object at the given source index to the given destination index. |
||||
|
||||
Throws an exception if the index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param sourceIndex The index of the object to be moved. |
||||
@param destinationIndex The index to which the object at `sourceIndex` should be moved. |
||||
*/ |
||||
- (void)moveObjectAtIndex:(NSUInteger)sourceIndex toIndex:(NSUInteger)destinationIndex; |
||||
|
||||
/**
|
||||
Exchanges the objects in the array at given indices. |
||||
|
||||
Throws an exception if either index exceeds the bounds of the array. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param index1 The index of the object which should replace the object at index `index2`. |
||||
@param index2 The index of the object which should replace the object at index `index1`. |
||||
*/ |
||||
- (void)exchangeObjectAtIndex:(NSUInteger)index1 withObjectAtIndex:(NSUInteger)index2; |
||||
|
||||
#pragma mark - Querying an Array |
||||
|
||||
/**
|
||||
Returns the index of an object in the array. |
||||
|
||||
Returns `NSNotFound` if the object is not found in the array. |
||||
|
||||
@param object An object (of the same type as returned from the `objectClassName` selector). |
||||
*/ |
||||
- (NSUInteger)indexOfObject:(RLMObjectType)object; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the array matching the predicate. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the array. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the array matching the predicate. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the array. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns all the objects matching the given predicate in the array. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` of objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)objectsWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMResults<RLMObjectType> *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns all the objects matching the given predicate in the array. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` of objects that match the given predicate |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)objectsWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from the array. |
||||
|
||||
@param keyPath The key path to sort by. |
||||
@param ascending The direction to sort in. |
||||
|
||||
@return An `RLMResults` sorted by the specified key path. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)sortedResultsUsingKeyPath:(NSString *)keyPath ascending:(BOOL)ascending; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from the array. |
||||
|
||||
@param properties An array of `RLMSortDescriptor`s to sort by. |
||||
|
||||
@return An `RLMResults` sorted by the specified properties. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)sortedResultsUsingDescriptors:(NSArray<RLMSortDescriptor *> *)properties; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMObjectType)objectAtIndexedSubscript:(NSUInteger)index; |
||||
|
||||
/// :nodoc:
|
||||
- (void)setObject:(RLMObjectType)newValue atIndexedSubscript:(NSUInteger)index; |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
Registers a block to be called each time the array changes. |
||||
|
||||
The block will be asynchronously called with the initial array, and then |
||||
called again after each write transaction which changes any of the objects in |
||||
the array, which objects are in the results, or the order of the objects in the |
||||
array. |
||||
|
||||
The `changes` parameter will be `nil` the first time the block is called. |
||||
For each call after that, it will contain information about |
||||
which rows in the array were added, removed or modified. If a write transaction |
||||
did not modify any objects in the array, the block is not called at all. |
||||
See the `RLMCollectionChange` documentation for information on how the changes |
||||
are reported and an example of updating a `UITableView`. |
||||
|
||||
If an error occurs the block will be called with `nil` for the results |
||||
parameter and a non-`nil` error. Currently the only errors that can occur are |
||||
when opening the Realm on the background worker thread. |
||||
|
||||
Notifications are delivered via the standard run loop, and so can't be |
||||
delivered while the run loop is blocked by other activity. When |
||||
notifications can't be delivered instantly, multiple notifications may be |
||||
coalesced into a single notification. This can include the notification |
||||
with the initial results. For example, the following code performs a write |
||||
transaction immediately after adding the notification block, so there is no |
||||
opportunity for the initial notification to be delivered first. As a |
||||
result, the initial notification will reflect the state of the Realm after |
||||
the write transaction. |
||||
|
||||
Person *person = [[Person allObjectsInRealm:realm] firstObject]; |
||||
NSLog(@"person.dogs.count: %zu", person.dogs.count); // => 0
|
||||
self.token = [person.dogs addNotificationBlock(RLMArray<Dog *> *dogs, |
||||
RLMCollectionChange *changes, |
||||
NSError *error) { |
||||
// Only fired once for the example
|
||||
NSLog(@"dogs.count: %zu", dogs.count) // => 1
|
||||
}]; |
||||
[realm transactionWithBlock:^{ |
||||
Dog *dog = [[Dog alloc] init]; |
||||
dog.name = @"Rex"; |
||||
[person.dogs addObject:dog]; |
||||
}]; |
||||
// end of run loop execution context
|
||||
|
||||
You must retain the returned token for as long as you want updates to continue |
||||
to be sent to the block. To stop receiving updates, call `-invalidate` on the token. |
||||
|
||||
@warning This method cannot be called during a write transaction, or when the |
||||
containing Realm is read-only. |
||||
@warning This method may only be called on a managed array. |
||||
|
||||
@param block The block to be called each time the array changes. |
||||
@return A token which must be held for as long as you want updates to be delivered. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(void (^)(RLMArray<RLMObjectType> *__nullable array, |
||||
RLMCollectionChange *__nullable changes, |
||||
NSError *__nullable error))block __attribute__((warn_unused_result)); |
||||
|
||||
#pragma mark - Aggregating Property Values |
||||
|
||||
/**
|
||||
Returns the minimum (lowest) value of the given property among all the objects in the array. |
||||
|
||||
NSNumber *min = [object.arrayProperty minOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose minimum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The minimum value of the property, or `nil` if the array is empty. |
||||
*/ |
||||
- (nullable id)minOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the maximum (highest) value of the given property among all the objects in the array. |
||||
|
||||
NSNumber *max = [object.arrayProperty maxOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose maximum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The maximum value of the property, or `nil` if the array is empty. |
||||
*/ |
||||
- (nullable id)maxOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the sum of the values of a given property over all the objects in the array. |
||||
|
||||
NSNumber *sum = [object.arrayProperty sumOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose values should be summed. Only properties of |
||||
types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The sum of the given property. |
||||
*/ |
||||
- (NSNumber *)sumOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the average value of a given property over the objects in the array. |
||||
|
||||
NSNumber *average = [object.arrayProperty averageOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose average value should be calculated. Only |
||||
properties of types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The average value of the given property, or `nil` if the array is empty. |
||||
*/ |
||||
- (nullable NSNumber *)averageOfProperty:(NSString *)property; |
||||
|
||||
|
||||
#pragma mark - Unavailable Methods |
||||
|
||||
/**
|
||||
`-[RLMArray init]` is not available because `RLMArray`s cannot be created directly. |
||||
`RLMArray` properties on `RLMObject`s are lazily created when accessed. |
||||
*/ |
||||
- (instancetype)init __attribute__((unavailable("RLMArrays cannot be created directly"))); |
||||
|
||||
/**
|
||||
`+[RLMArray new]` is not available because `RLMArray`s cannot be created directly. |
||||
`RLMArray` properties on `RLMObject`s are lazily created when accessed. |
||||
*/ |
||||
+ (instancetype)new __attribute__((unavailable("RLMArrays cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
/// :nodoc:
|
||||
@interface RLMArray (Swift) |
||||
// for use only in Swift class definitions
|
||||
- (instancetype)initWithObjectClassName:(NSString *)objectClassName; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,401 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import <Realm/RLMConstants.h> |
||||
#import <Realm/RLMThreadSafeReference.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMRealm, RLMResults, RLMSortDescriptor, RLMNotificationToken, RLMCollectionChange; |
||||
typedef RLM_CLOSED_ENUM(int32_t, RLMPropertyType); |
||||
|
||||
/**
|
||||
A homogenous collection of Realm-managed objects. Examples of conforming types |
||||
include `RLMArray`, `RLMResults`, and `RLMLinkingObjects`. |
||||
*/ |
||||
@protocol RLMCollection <NSFastEnumeration, RLMThreadConfined> |
||||
|
||||
@required |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The number of objects in the collection. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) NSUInteger count; |
||||
|
||||
/**
|
||||
The type of the objects in the collection. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) RLMPropertyType type; |
||||
|
||||
/**
|
||||
Indicates whether the objects in the collection can be `nil`. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isOptional) BOOL optional; |
||||
|
||||
/**
|
||||
The class name of the objects contained in the collection. |
||||
|
||||
Will be `nil` if `type` is not RLMPropertyTypeObject. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *objectClassName; |
||||
|
||||
/**
|
||||
The Realm which manages the collection, or `nil` for unmanaged collections. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMRealm *realm; |
||||
|
||||
#pragma mark - Accessing Objects from a Collection |
||||
|
||||
/**
|
||||
Returns the object at the index specified. |
||||
|
||||
@param index The index to look up. |
||||
|
||||
@return An object of the type contained in the collection. |
||||
*/ |
||||
- (id)objectAtIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Returns the first object in the collection. |
||||
|
||||
Returns `nil` if called on an empty collection. |
||||
|
||||
@return An object of the type contained in the collection. |
||||
*/ |
||||
- (nullable id)firstObject; |
||||
|
||||
/**
|
||||
Returns the last object in the collection. |
||||
|
||||
Returns `nil` if called on an empty collection. |
||||
|
||||
@return An object of the type contained in the collection. |
||||
*/ |
||||
- (nullable id)lastObject; |
||||
|
||||
#pragma mark - Querying a Collection |
||||
|
||||
/**
|
||||
Returns the index of an object in the collection. |
||||
|
||||
Returns `NSNotFound` if the object is not found in the collection. |
||||
|
||||
@param object An object (of the same type as returned from the `objectClassName` selector). |
||||
*/ |
||||
- (NSUInteger)indexOfObject:(id)object; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the collection matching the predicate. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the collection. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the collection matching the predicate. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the collection. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns all objects matching the given predicate in the collection. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` containing objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults *)objectsWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMResults *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns all objects matching the given predicate in the collection. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` containing objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults *)objectsWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from the collection. |
||||
|
||||
@param keyPath The keyPath to sort by. |
||||
@param ascending The direction to sort in. |
||||
|
||||
@return An `RLMResults` sorted by the specified key path. |
||||
*/ |
||||
- (RLMResults *)sortedResultsUsingKeyPath:(NSString *)keyPath ascending:(BOOL)ascending; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from the collection. |
||||
|
||||
@param properties An array of `RLMSortDescriptor`s to sort by. |
||||
|
||||
@return An `RLMResults` sorted by the specified properties. |
||||
*/ |
||||
- (RLMResults *)sortedResultsUsingDescriptors:(NSArray<RLMSortDescriptor *> *)properties; |
||||
|
||||
/// :nodoc:
|
||||
- (id)objectAtIndexedSubscript:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Returns an `NSArray` containing the results of invoking `valueForKey:` using `key` on each of the collection's objects. |
||||
|
||||
@param key The name of the property. |
||||
|
||||
@return An `NSArray` containing results. |
||||
*/ |
||||
- (nullable id)valueForKey:(NSString *)key; |
||||
|
||||
/**
|
||||
Invokes `setValue:forKey:` on each of the collection's objects using the specified `value` and `key`. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param value The object value. |
||||
@param key The name of the property. |
||||
*/ |
||||
- (void)setValue:(nullable id)value forKey:(NSString *)key; |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
Registers a block to be called each time the collection changes. |
||||
|
||||
The block will be asynchronously called with the initial collection, and then |
||||
called again after each write transaction which changes either any of the |
||||
objects in the collection, or which objects are in the collection. |
||||
|
||||
The `change` parameter will be `nil` the first time the block is called. |
||||
For each call after that, it will contain information about |
||||
which rows in the collection were added, removed or modified. If a write transaction |
||||
did not modify any objects in this collection, the block is not called at all. |
||||
See the `RLMCollectionChange` documentation for information on how the changes |
||||
are reported and an example of updating a `UITableView`. |
||||
|
||||
If an error occurs the block will be called with `nil` for the collection |
||||
parameter and a non-`nil` error. Currently the only errors that can occur are |
||||
when opening the Realm on the background worker thread. |
||||
|
||||
At the time when the block is called, the collection object will be fully |
||||
evaluated and up-to-date, and as long as you do not perform a write transaction |
||||
on the same thread or explicitly call `-[RLMRealm refresh]`, accessing it will |
||||
never perform blocking work. |
||||
|
||||
Notifications are delivered via the standard run loop, and so can't be |
||||
delivered while the run loop is blocked by other activity. When |
||||
notifications can't be delivered instantly, multiple notifications may be |
||||
coalesced into a single notification. This can include the notification |
||||
with the initial collection. For example, the following code performs a write |
||||
transaction immediately after adding the notification block, so there is no |
||||
opportunity for the initial notification to be delivered first. As a |
||||
result, the initial notification will reflect the state of the Realm after |
||||
the write transaction. |
||||
|
||||
id<RLMCollection> collection = [Dog allObjects]; |
||||
NSLog(@"dogs.count: %zu", dogs.count); // => 0
|
||||
self.token = [collection addNotificationBlock:^(id<RLMCollection> dogs, |
||||
RLMCollectionChange *changes, |
||||
NSError *error) { |
||||
// Only fired once for the example
|
||||
NSLog(@"dogs.count: %zu", dogs.count); // => 1
|
||||
}]; |
||||
[realm transactionWithBlock:^{ |
||||
Dog *dog = [[Dog alloc] init]; |
||||
dog.name = @"Rex"; |
||||
[realm addObject:dog]; |
||||
}]; |
||||
// end of run loop execution context
|
||||
|
||||
You must retain the returned token for as long as you want updates to continue |
||||
to be sent to the block. To stop receiving updates, call `-invalidate` on the token. |
||||
|
||||
@warning This method cannot be called during a write transaction, or when the |
||||
containing Realm is read-only. |
||||
|
||||
@param block The block to be called each time the collection changes. |
||||
@return A token which must be held for as long as you want collection notifications to be delivered. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(void (^)(id<RLMCollection> __nullable collection, |
||||
RLMCollectionChange *__nullable change, |
||||
NSError *__nullable error))block __attribute__((warn_unused_result)); |
||||
|
||||
#pragma mark - Aggregating Property Values |
||||
|
||||
/**
|
||||
Returns the minimum (lowest) value of the given property among all the objects |
||||
in the collection. |
||||
|
||||
NSNumber *min = [results minOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose minimum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The minimum value of the property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable id)minOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the maximum (highest) value of the given property among all the objects |
||||
in the collection. |
||||
|
||||
NSNumber *max = [results maxOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose maximum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The maximum value of the property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable id)maxOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the sum of the values of a given property over all the objects in the collection. |
||||
|
||||
NSNumber *sum = [results sumOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose values should be summed. Only properties of |
||||
types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The sum of the given property. |
||||
*/ |
||||
- (NSNumber *)sumOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the average value of a given property over the objects in the collection. |
||||
|
||||
NSNumber *average = [results averageOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose average value should be calculated. Only |
||||
properties of types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The average value of the given property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable NSNumber *)averageOfProperty:(NSString *)property; |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
An `RLMSortDescriptor` stores a property name and a sort order for use with |
||||
`sortedResultsUsingDescriptors:`. It is similar to `NSSortDescriptor`, but supports |
||||
only the subset of functionality which can be efficiently run by Realm's query |
||||
engine. |
||||
|
||||
`RLMSortDescriptor` instances are immutable. |
||||
*/ |
||||
@interface RLMSortDescriptor : NSObject |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The key path which the sort descriptor orders results by. |
||||
*/ |
||||
@property (nonatomic, readonly) NSString *keyPath; |
||||
|
||||
/**
|
||||
Whether the descriptor sorts in ascending or descending order. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL ascending; |
||||
|
||||
#pragma mark - Methods |
||||
|
||||
/**
|
||||
Returns a new sort descriptor for the given key path and sort direction. |
||||
*/ |
||||
+ (instancetype)sortDescriptorWithKeyPath:(NSString *)keyPath ascending:(BOOL)ascending; |
||||
|
||||
/**
|
||||
Returns a copy of the receiver with the sort direction reversed. |
||||
*/ |
||||
- (instancetype)reversedSortDescriptor; |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
A `RLMCollectionChange` object encapsulates information about changes to collections |
||||
that are reported by Realm notifications. |
||||
|
||||
`RLMCollectionChange` is passed to the notification blocks registered with |
||||
`-addNotificationBlock` on `RLMArray` and `RLMResults`, and reports what rows in the |
||||
collection changed since the last time the notification block was called. |
||||
|
||||
The change information is available in two formats: a simple array of row |
||||
indices in the collection for each type of change, and an array of index paths |
||||
in a requested section suitable for passing directly to `UITableView`'s batch |
||||
update methods. A complete example of updating a `UITableView` named `tv`: |
||||
|
||||
[tv beginUpdates]; |
||||
[tv deleteRowsAtIndexPaths:[changes deletionsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic]; |
||||
[tv insertRowsAtIndexPaths:[changes insertionsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic]; |
||||
[tv reloadRowsAtIndexPaths:[changes modificationsInSection:0] withRowAnimation:UITableViewRowAnimationAutomatic]; |
||||
[tv endUpdates]; |
||||
|
||||
All of the arrays in an `RLMCollectionChange` are always sorted in ascending order. |
||||
*/ |
||||
@interface RLMCollectionChange : NSObject |
||||
/// The indices of objects in the previous version of the collection which have
|
||||
/// been removed from this one.
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *deletions; |
||||
|
||||
/// The indices in the new version of the collection which were newly inserted.
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *insertions; |
||||
|
||||
/**
|
||||
The indices in the new version of the collection which were modified. |
||||
|
||||
For `RLMResults`, this means that one or more of the properties of the object at |
||||
that index were modified (or an object linked to by that object was |
||||
modified). |
||||
|
||||
For `RLMArray`, the array itself being modified to contain a |
||||
different object at that index will also be reported as a modification. |
||||
*/ |
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *modifications; |
||||
|
||||
/// Returns the index paths of the deletion indices in the given section.
|
||||
- (NSArray<NSIndexPath *> *)deletionsInSection:(NSUInteger)section; |
||||
|
||||
/// Returns the index paths of the insertion indices in the given section.
|
||||
- (NSArray<NSIndexPath *> *)insertionsInSection:(NSUInteger)section; |
||||
|
||||
/// Returns the index paths of the modification indices in the given section.
|
||||
- (NSArray<NSIndexPath *> *)modificationsInSection:(NSUInteger)section; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,224 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
// For compatibility with Xcode 7, before extensible string enums were introduced,
|
||||
#ifdef NS_EXTENSIBLE_STRING_ENUM |
||||
#define RLM_EXTENSIBLE_STRING_ENUM NS_EXTENSIBLE_STRING_ENUM |
||||
#define RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(_, extensible_string_enum) NS_SWIFT_NAME(extensible_string_enum) |
||||
#else |
||||
#define RLM_EXTENSIBLE_STRING_ENUM |
||||
#define RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(fully_qualified, _) NS_SWIFT_NAME(fully_qualified) |
||||
#endif |
||||
|
||||
// Swift 5 considers NS_ENUM to be "open", meaning there could be values present
|
||||
// other than the defined cases (which allows adding more cases later without
|
||||
// it being a breaking change), while older versions consider it "closed".
|
||||
#ifdef NS_CLOSED_ENUM |
||||
#define RLM_CLOSED_ENUM NS_CLOSED_ENUM |
||||
#else |
||||
#define RLM_CLOSED_ENUM NS_ENUM |
||||
#endif |
||||
|
||||
#if __has_attribute(ns_error_domain) && (!defined(__cplusplus) || !__cplusplus || __cplusplus >= 201103L) |
||||
#define RLM_ERROR_ENUM(type, name, domain) \ |
||||
_Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wignored-attributes\"") \
|
||||
NS_ENUM(type, __attribute__((ns_error_domain(domain))) name) \
|
||||
_Pragma("clang diagnostic pop") |
||||
#else |
||||
#define RLM_ERROR_ENUM(type, name, domain) NS_ENUM(type, name) |
||||
#endif |
||||
|
||||
|
||||
#pragma mark - Enums |
||||
|
||||
/**
|
||||
`RLMPropertyType` is an enumeration describing all property types supported in Realm models. |
||||
|
||||
For more information, see [Realm Models](https://realm.io/docs/objc/latest/#models).
|
||||
*/ |
||||
typedef RLM_CLOSED_ENUM(int32_t, RLMPropertyType) { |
||||
|
||||
#pragma mark - Primitive types |
||||
|
||||
/** Integers: `NSInteger`, `int`, `long`, `Int` (Swift) */ |
||||
RLMPropertyTypeInt = 0, |
||||
/** Booleans: `BOOL`, `bool`, `Bool` (Swift) */ |
||||
RLMPropertyTypeBool = 1, |
||||
/** Floating-point numbers: `float`, `Float` (Swift) */ |
||||
RLMPropertyTypeFloat = 5, |
||||
/** Double-precision floating-point numbers: `double`, `Double` (Swift) */ |
||||
RLMPropertyTypeDouble = 6, |
||||
|
||||
#pragma mark - Object types |
||||
|
||||
/** Strings: `NSString`, `String` (Swift) */ |
||||
RLMPropertyTypeString = 2, |
||||
/** Binary data: `NSData` */ |
||||
RLMPropertyTypeData = 3, |
||||
/**
|
||||
Any object: `id`. |
||||
|
||||
This property type is no longer supported for new models. However, old files |
||||
with any-typed properties are still supported for migration purposes. |
||||
*/ |
||||
RLMPropertyTypeAny = 9, |
||||
/** Dates: `NSDate` */ |
||||
RLMPropertyTypeDate = 4, |
||||
|
||||
#pragma mark - Linked object types |
||||
|
||||
/** Realm model objects. See [Realm Models](https://realm.io/docs/objc/latest/#models) for more information. */ |
||||
RLMPropertyTypeObject = 7, |
||||
/** Realm linking objects. See [Realm Models](https://realm.io/docs/objc/latest/#models) for more information. */ |
||||
RLMPropertyTypeLinkingObjects = 8, |
||||
}; |
||||
|
||||
/** An error domain identifying Realm-specific errors. */ |
||||
extern NSString * const RLMErrorDomain; |
||||
|
||||
/** An error domain identifying non-specific system errors. */ |
||||
extern NSString * const RLMUnknownSystemErrorDomain; |
||||
|
||||
/**
|
||||
`RLMError` is an enumeration representing all recoverable errors. It is associated with the |
||||
Realm error domain specified in `RLMErrorDomain`. |
||||
*/ |
||||
typedef RLM_ERROR_ENUM(NSInteger, RLMError, RLMErrorDomain) { |
||||
/** Denotes a general error that occurred when trying to open a Realm. */ |
||||
RLMErrorFail = 1, |
||||
|
||||
/** Denotes a file I/O error that occurred when trying to open a Realm. */ |
||||
RLMErrorFileAccess = 2, |
||||
|
||||
/**
|
||||
Denotes a file permission error that ocurred when trying to open a Realm. |
||||
|
||||
This error can occur if the user does not have permission to open or create |
||||
the specified file in the specified access mode when opening a Realm. |
||||
*/ |
||||
RLMErrorFilePermissionDenied = 3, |
||||
|
||||
/** Denotes an error where a file was to be written to disk, but another file with the same name already exists. */ |
||||
RLMErrorFileExists = 4, |
||||
|
||||
/**
|
||||
Denotes an error that occurs if a file could not be found. |
||||
|
||||
This error may occur if a Realm file could not be found on disk when trying to open a |
||||
Realm as read-only, or if the directory part of the specified path was not found when |
||||
trying to write a copy. |
||||
*/ |
||||
RLMErrorFileNotFound = 5, |
||||
|
||||
/**
|
||||
Denotes an error that occurs if a file format upgrade is required to open the file, |
||||
but upgrades were explicitly disabled. |
||||
*/ |
||||
RLMErrorFileFormatUpgradeRequired = 6, |
||||
|
||||
/**
|
||||
Denotes an error that occurs if the database file is currently open in another |
||||
process which cannot share with the current process due to an |
||||
architecture mismatch. |
||||
|
||||
This error may occur if trying to share a Realm file between an i386 (32-bit) iOS |
||||
Simulator and the Realm Browser application. In this case, please use the 64-bit |
||||
version of the iOS Simulator. |
||||
*/ |
||||
RLMErrorIncompatibleLockFile = 8, |
||||
|
||||
/** Denotes an error that occurs when there is insufficient available address space. */ |
||||
RLMErrorAddressSpaceExhausted = 9, |
||||
|
||||
/** Denotes an error that occurs if there is a schema version mismatch, so that a migration is required. */ |
||||
RLMErrorSchemaMismatch = 10, |
||||
|
||||
/** Denotes an error that occurs when attempting to open an incompatible synchronized Realm file.
|
||||
|
||||
This error occurs when the Realm file was created with an older version of Realm and an automatic migration |
||||
to the current version is not possible. When such an error occurs, the original file is moved to a backup |
||||
location, and future attempts to open the synchronized Realm will result in a new file being created. |
||||
If you wish to migrate any data from the backup Realm, you can open it using the provided Realm configuration. |
||||
*/ |
||||
RLMErrorIncompatibleSyncedFile = 11, |
||||
}; |
||||
|
||||
#pragma mark - Constants |
||||
|
||||
#pragma mark - Notification Constants |
||||
|
||||
/**
|
||||
A notification indicating that changes were made to a Realm. |
||||
*/ |
||||
typedef NSString * RLMNotification RLM_EXTENSIBLE_STRING_ENUM; |
||||
|
||||
/**
|
||||
This notification is posted by a Realm when the data in that Realm has changed. |
||||
|
||||
More specifically, this notification is posted after a Realm has been refreshed to |
||||
reflect a write transaction. This can happen when an autorefresh occurs, when |
||||
`-[RLMRealm refresh]` is called, after an implicit refresh from `-[RLMRealm beginWriteTransaction]`, |
||||
or after a local write transaction is completed. |
||||
*/ |
||||
extern RLMNotification const RLMRealmRefreshRequiredNotification |
||||
RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(RLMRealmRefreshRequiredNotification, RefreshRequired); |
||||
|
||||
/**
|
||||
This notification is posted by a Realm when a write transaction has been |
||||
committed to a Realm on a different thread for the same file. |
||||
|
||||
It is not posted if `-[RLMRealm autorefresh]` is enabled, or if the Realm is |
||||
refreshed before the notification has a chance to run. |
||||
|
||||
Realms with autorefresh disabled should normally install a handler for this |
||||
notification which calls `-[RLMRealm refresh]` after doing some work. Refreshing |
||||
the Realm is optional, but not refreshing the Realm may lead to large Realm |
||||
files. This is because Realm must keep an extra copy of the data for the stale |
||||
Realm. |
||||
*/ |
||||
extern RLMNotification const RLMRealmDidChangeNotification |
||||
RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(RLMRealmDidChangeNotification, DidChange); |
||||
|
||||
#pragma mark - Error keys |
||||
|
||||
/** Key to identify the associated backup Realm configuration in an error's `userInfo` dictionary */ |
||||
extern NSString * const RLMBackupRealmConfigurationErrorKey; |
||||
|
||||
#pragma mark - Other Constants |
||||
|
||||
/** The schema version used for uninitialized Realms */ |
||||
extern const uint64_t RLMNotVersioned; |
||||
|
||||
/** The corresponding value is the name of an exception thrown by Realm. */ |
||||
extern NSString * const RLMExceptionName; |
||||
|
||||
/** The corresponding value is a Realm file version. */ |
||||
extern NSString * const RLMRealmVersionKey; |
||||
|
||||
/** The corresponding key is the version of the underlying database engine. */ |
||||
extern NSString * const RLMRealmCoreVersionKey; |
||||
|
||||
/** The corresponding key is the Realm invalidated property name. */ |
||||
extern NSString * const RLMInvalidatedKey; |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,127 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMSchema; |
||||
@class RLMArray; |
||||
@class RLMObject; |
||||
|
||||
/**
|
||||
A block type which provides both the old and new versions of an object in the Realm. Object |
||||
properties can only be accessed using keyed subscripting. |
||||
|
||||
@see `-[RLMMigration enumerateObjects:block:]` |
||||
|
||||
@param oldObject The object from the original Realm (read-only). |
||||
@param newObject The object from the migrated Realm (read-write). |
||||
*/ |
||||
typedef void (^RLMObjectMigrationBlock)(RLMObject * __nullable oldObject, RLMObject * __nullable newObject); |
||||
|
||||
/**
|
||||
`RLMMigration` instances encapsulate information intended to facilitate a schema migration. |
||||
|
||||
A `RLMMigration` instance is passed into a user-defined `RLMMigrationBlock` block when updating |
||||
the version of a Realm. This instance provides access to the old and new database schemas, the |
||||
objects in the Realm, and provides functionality for modifying the Realm during the migration. |
||||
*/ |
||||
@interface RLMMigration : NSObject |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
Returns the old `RLMSchema`. This is the schema which describes the Realm before the |
||||
migration is applied. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSchema *oldSchema; |
||||
|
||||
/**
|
||||
Returns the new `RLMSchema`. This is the schema which describes the Realm after the |
||||
migration is applied. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSchema *newSchema; |
||||
|
||||
|
||||
#pragma mark - Altering Objects during a Migration |
||||
|
||||
/**
|
||||
Enumerates all the objects of a given type in the Realm, providing both the old and new versions |
||||
of each object. Within the block, object properties can only be accessed using keyed subscripting. |
||||
|
||||
@param className The name of the `RLMObject` class to enumerate. |
||||
|
||||
@warning All objects returned are of a type specific to the current migration and should not be cast |
||||
to `className`. Instead, treat them as `RLMObject`s and use keyed subscripting to access |
||||
properties. |
||||
*/ |
||||
- (void)enumerateObjects:(NSString *)className block:(__attribute__((noescape)) RLMObjectMigrationBlock)block; |
||||
|
||||
/**
|
||||
Creates and returns an `RLMObject` instance of type `className` in the Realm being migrated. |
||||
|
||||
The `value` argument is used to populate the object. It can be a key-value coding compliant object, an array or |
||||
dictionary returned from the methods in `NSJSONSerialization`, or an array containing one element for each managed |
||||
property. An exception will be thrown if any required properties are not present and those properties were not defined |
||||
with default values. |
||||
|
||||
When passing in an `NSArray` as the `value` argument, all properties must be present, valid and in the same order as |
||||
the properties defined in the model. |
||||
|
||||
@param className The name of the `RLMObject` class to create. |
||||
@param value The value used to populate the object. |
||||
*/ |
||||
- (RLMObject *)createObject:(NSString *)className withValue:(id)value; |
||||
|
||||
/**
|
||||
Deletes an object from a Realm during a migration. |
||||
|
||||
It is permitted to call this method from within the block passed to `-[enumerateObjects:block:]`. |
||||
|
||||
@param object Object to be deleted from the Realm being migrated. |
||||
*/ |
||||
- (void)deleteObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Deletes the data for the class with the given name. |
||||
|
||||
All objects of the given class will be deleted. If the `RLMObject` subclass no longer exists in your program, |
||||
any remaining metadata for the class will be removed from the Realm file. |
||||
|
||||
@param name The name of the `RLMObject` class to delete. |
||||
|
||||
@return A Boolean value indicating whether there was any data to delete. |
||||
*/ |
||||
- (BOOL)deleteDataForClassName:(NSString *)name; |
||||
|
||||
/**
|
||||
Renames a property of the given class from `oldName` to `newName`. |
||||
|
||||
@param className The name of the class whose property should be renamed. This class must be present |
||||
in both the old and new Realm schemas. |
||||
@param oldName The old name for the property to be renamed. There must not be a property with this name in the |
||||
class as defined by the new Realm schema. |
||||
@param newName The new name for the property to be renamed. There must not be a property with this name in the |
||||
class as defined by the old Realm schema. |
||||
*/ |
||||
- (void)renamePropertyForClass:(NSString *)className oldName:(NSString *)oldName newName:(NSString *)newName; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,650 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import <Realm/RLMObjectBase.h> |
||||
#import <Realm/RLMThreadSafeReference.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMNotificationToken; |
||||
@class RLMObjectSchema; |
||||
@class RLMPropertyChange; |
||||
@class RLMPropertyDescriptor; |
||||
@class RLMRealm; |
||||
@class RLMResults<RLMObjectType>; |
||||
|
||||
/**
|
||||
`RLMObject` is a base class for model objects representing data stored in Realms. |
||||
|
||||
Define your model classes by subclassing `RLMObject` and adding properties to be managed. |
||||
Then instantiate and use your custom subclasses instead of using the `RLMObject` class directly. |
||||
|
||||
// Dog.h
|
||||
@interface Dog : RLMObject |
||||
@property NSString *name; |
||||
@property BOOL adopted; |
||||
@end |
||||
|
||||
// Dog.m
|
||||
@implementation Dog |
||||
@end //none needed
|
||||
|
||||
### Supported property types |
||||
|
||||
- `NSString` |
||||
- `NSInteger`, `int`, `long`, `float`, and `double` |
||||
- `BOOL` or `bool` |
||||
- `NSDate` |
||||
- `NSData` |
||||
- `NSNumber<X>`, where `X` is one of `RLMInt`, `RLMFloat`, `RLMDouble` or `RLMBool`, for optional number properties |
||||
- `RLMObject` subclasses, to model many-to-one relationships. |
||||
- `RLMArray<X>`, where `X` is an `RLMObject` subclass, to model many-to-many relationships. |
||||
|
||||
### Querying |
||||
|
||||
You can initiate queries directly via the class methods: `allObjects`, `objectsWhere:`, and `objectsWithPredicate:`. |
||||
These methods allow you to easily query a custom subclass for instances of that class in the default Realm. |
||||
|
||||
To search in a Realm other than the default Realm, use the `allObjectsInRealm:`, `objectsInRealm:where:`, |
||||
and `objectsInRealm:withPredicate:` class methods. |
||||
|
||||
@see `RLMRealm` |
||||
|
||||
### Relationships |
||||
|
||||
See our [Cocoa guide](https://realm.io/docs/objc/latest#relationships) for more details.
|
||||
|
||||
### Key-Value Observing |
||||
|
||||
All `RLMObject` properties (including properties you create in subclasses) are |
||||
[Key-Value Observing compliant](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html),
|
||||
except for `realm` and `objectSchema`. |
||||
|
||||
Keep the following tips in mind when observing Realm objects: |
||||
|
||||
1. Unlike `NSMutableArray` properties, `RLMArray` properties do not require |
||||
using the proxy object returned from `-mutableArrayValueForKey:`, or defining |
||||
KVC mutation methods on the containing class. You can simply call methods on |
||||
the `RLMArray` directly; any changes will be automatically observed by the containing |
||||
object. |
||||
2. Unmanaged `RLMObject` instances cannot be added to a Realm while they have any |
||||
observed properties. |
||||
3. Modifying managed `RLMObject`s within `-observeValueForKeyPath:ofObject:change:context:` |
||||
is not recommended. Properties may change even when the Realm is not in a write |
||||
transaction (for example, when `-[RLMRealm refresh]` is called after changes |
||||
are made on a different thread), and notifications sent prior to the change |
||||
being applied (when `NSKeyValueObservingOptionPrior` is used) may be sent at |
||||
times when you *cannot* begin a write transaction. |
||||
*/ |
||||
|
||||
@interface RLMObject : RLMObjectBase <RLMThreadConfined> |
||||
|
||||
#pragma mark - Creating & Initializing Objects |
||||
|
||||
/**
|
||||
Creates an unmanaged instance of a Realm object. |
||||
|
||||
Call `addObject:` on an `RLMRealm` instance to add an unmanaged object into that Realm. |
||||
|
||||
@see `[RLMRealm addObject:]` |
||||
*/ |
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER; |
||||
|
||||
|
||||
/**
|
||||
Creates an unmanaged instance of a Realm object. |
||||
|
||||
Pass in an `NSArray` or `NSDictionary` instance to set the values of the object's properties. |
||||
|
||||
Call `addObject:` on an `RLMRealm` instance to add an unmanaged object into that Realm. |
||||
|
||||
@see `[RLMRealm addObject:]` |
||||
*/ |
||||
- (instancetype)initWithValue:(id)value NS_DESIGNATED_INITIALIZER; |
||||
|
||||
|
||||
/**
|
||||
Returns the class name for a Realm object subclass. |
||||
|
||||
@warning Do not override. Realm relies on this method returning the exact class |
||||
name. |
||||
|
||||
@return The class name for the model class. |
||||
*/ |
||||
+ (NSString *)className; |
||||
|
||||
/**
|
||||
Creates an instance of a Realm object with a given value, and adds it to the default Realm. |
||||
|
||||
If nested objects are included in the argument, `createInDefaultRealmWithValue:` will be recursively called |
||||
on them. |
||||
|
||||
The `value` argument can be a key-value coding compliant object, an array or dictionary returned from the methods in |
||||
`NSJSONSerialization`, or an array containing one element for each managed property. |
||||
|
||||
An exception will be thrown if any required properties are not present and those properties |
||||
were not defined with default values. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues` |
||||
*/ |
||||
+ (instancetype)createInDefaultRealmWithValue:(id)value; |
||||
|
||||
/**
|
||||
Creates an instance of a Realm object with a given value, and adds it to the specified Realm. |
||||
|
||||
If nested objects are included in the argument, `createInRealm:withValue:` will be recursively called |
||||
on them. |
||||
|
||||
The `value` argument can be a key-value coding compliant object, an array or dictionary returned from the methods in |
||||
`NSJSONSerialization`, or an array containing one element for each managed property. |
||||
|
||||
An exception will be thrown if any required properties are not present and those properties |
||||
were not defined with default values. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param realm The Realm which should manage the newly-created object. |
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues` |
||||
*/ |
||||
+ (instancetype)createInRealm:(RLMRealm *)realm withValue:(id)value; |
||||
|
||||
/**
|
||||
Creates or updates a Realm object within the default Realm. |
||||
|
||||
This method may only be called on Realm object types with a primary key defined. If there is already |
||||
an object with the same primary key value in the default Realm, its values are updated and the object |
||||
is returned. Otherwise, this method creates and populates a new instance of the object in the default Realm. |
||||
|
||||
If nested objects are included in the argument, `createOrUpdateInDefaultRealmWithValue:` will be |
||||
recursively called on them if they have primary keys, `createInDefaultRealmWithValue:` if they do not. |
||||
|
||||
The `value` argument is used to populate the object. It can be a Realm object, a key-value coding |
||||
compliant object, an array or dictionary returned from the methods in `NSJSONSerialization`, or an |
||||
array containing one element for each managed property. |
||||
|
||||
If the object is being created, an exception will be thrown if any required properties |
||||
are not present and those properties were not defined with default values. |
||||
|
||||
If the `value` argument is a Realm object already managed by the default Realm, the |
||||
argument's type is the same as the receiver, and the objects have identical values for |
||||
their managed properties, this method does nothing. |
||||
|
||||
If the object is being updated, each property defined in its schema will be set by copying from |
||||
`value` using key-value coding. If the `value` argument does not respond to `valueForKey:` for a |
||||
given property name (or getter name, if defined), that value will remain untouched. |
||||
Nullable properties on the object can be set to nil by using `NSNull` as the updated value. |
||||
Each property is set even if the existing value is the same as the new value being set, and |
||||
notifications will report them all being changed. See `createOrUpdateModifiedInDefaultRealmWithValue:` |
||||
for a version of this function which only sets the values which have changed. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues`, `primaryKey` |
||||
*/ |
||||
+ (instancetype)createOrUpdateInDefaultRealmWithValue:(id)value; |
||||
|
||||
/**
|
||||
Creates or updates a Realm object within the default Realm. |
||||
|
||||
This method may only be called on Realm object types with a primary key defined. If there is already |
||||
an object with the same primary key value in the default Realm, its values are updated and the object |
||||
is returned. Otherwise, this method creates and populates a new instance of the object in the default Realm. |
||||
|
||||
If nested objects are included in the argument, `createOrUpdateModifiedInDefaultRealmWithValue:` will be |
||||
recursively called on them if they have primary keys, `createInDefaultRealmWithValue:` if they do not. |
||||
|
||||
The `value` argument is used to populate the object. It can be a Realm object, a key-value coding |
||||
compliant object, an array or dictionary returned from the methods in `NSJSONSerialization`, or an |
||||
array containing one element for each managed property. |
||||
|
||||
If the object is being created, an exception will be thrown if any required properties |
||||
are not present and those properties were not defined with default values. |
||||
|
||||
If the `value` argument is a Realm object already managed by the default Realm, the |
||||
argument's type is the same as the receiver, and the objects have identical values for |
||||
their managed properties, this method does nothing. |
||||
|
||||
If the object is being updated, each property defined in its schema will be set by copying from |
||||
`value` using key-value coding. If the `value` argument does not respond to `valueForKey:` for a |
||||
given property name (or getter name, if defined), that value will remain untouched. |
||||
Nullable properties on the object can be set to nil by using `NSNull` as the updated value. |
||||
Unlike `createOrUpdateInDefaultRealmWithValue:`, only properties which have changed in value are |
||||
set, and any change notifications produced by this call will report only which properies have |
||||
actually changed. |
||||
|
||||
Checking which properties have changed imposes a small amount of overhead, and so this method |
||||
may be slower when all or nearly all of the properties being set have changed. If most or all |
||||
of the properties being set have not changed, this method will be much faster than unconditionally |
||||
setting all of them, and will also reduce how much data has to be written to the Realm, saving |
||||
both i/o time and disk space. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues`, `primaryKey` |
||||
*/ |
||||
+ (instancetype)createOrUpdateModifiedInDefaultRealmWithValue:(id)value; |
||||
|
||||
/**
|
||||
Creates or updates an Realm object within a specified Realm. |
||||
|
||||
This method may only be called on Realm object types with a primary key defined. If there is already |
||||
an object with the same primary key value in the given Realm, its values are updated and the object |
||||
is returned. Otherwise this method creates and populates a new instance of this object in the given Realm. |
||||
|
||||
If nested objects are included in the argument, `createOrUpdateInRealm:withValue:` will be |
||||
recursively called on them if they have primary keys, `createInRealm:withValue:` if they do not. |
||||
|
||||
The `value` argument is used to populate the object. It can be a Realm object, a key-value coding |
||||
compliant object, an array or dictionary returned from the methods in `NSJSONSerialization`, or an |
||||
array containing one element for each managed property. |
||||
|
||||
If the object is being created, an exception will be thrown if any required properties |
||||
are not present and those properties were not defined with default values. |
||||
|
||||
If the `value` argument is a Realm object already managed by the given Realm, the |
||||
argument's type is the same as the receiver, and the objects have identical values for |
||||
their managed properties, this method does nothing. |
||||
|
||||
If the object is being updated, each property defined in its schema will be set by copying from |
||||
`value` using key-value coding. If the `value` argument does not respond to `valueForKey:` for a |
||||
given property name (or getter name, if defined), that value will remain untouched. |
||||
Nullable properties on the object can be set to nil by using `NSNull` as the updated value. |
||||
Each property is set even if the existing value is the same as the new value being set, and |
||||
notifications will report them all being changed. See `createOrUpdateModifiedInRealm:withValue:` |
||||
for a version of this function which only sets the values which have changed. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param realm The Realm which should own the object. |
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues`, `primaryKey` |
||||
*/ |
||||
+ (instancetype)createOrUpdateInRealm:(RLMRealm *)realm withValue:(id)value; |
||||
|
||||
/**
|
||||
Creates or updates an Realm object within a specified Realm. |
||||
|
||||
This method may only be called on Realm object types with a primary key defined. If there is already |
||||
an object with the same primary key value in the given Realm, its values are updated and the object |
||||
is returned. Otherwise this method creates and populates a new instance of this object in the given Realm. |
||||
|
||||
If nested objects are included in the argument, `createOrUpdateInRealm:withValue:` will be |
||||
recursively called on them if they have primary keys, `createInRealm:withValue:` if they do not. |
||||
|
||||
The `value` argument is used to populate the object. It can be a Realm object, a key-value coding |
||||
compliant object, an array or dictionary returned from the methods in `NSJSONSerialization`, or an |
||||
array containing one element for each managed property. |
||||
|
||||
If the object is being created, an exception will be thrown if any required properties |
||||
are not present and those properties were not defined with default values. |
||||
|
||||
If the `value` argument is a Realm object already managed by the given Realm, the |
||||
argument's type is the same as the receiver, and the objects have identical values for |
||||
their managed properties, this method does nothing. |
||||
|
||||
If the object is being updated, each property defined in its schema will be set by copying from |
||||
`value` using key-value coding. If the `value` argument does not respond to `valueForKey:` for a |
||||
given property name (or getter name, if defined), that value will remain untouched. |
||||
Nullable properties on the object can be set to nil by using `NSNull` as the updated value. |
||||
Unlike `createOrUpdateInRealm:withValue:`, only properties which have changed in value are |
||||
set, and any change notifications produced by this call will report only which properies have |
||||
actually changed. |
||||
|
||||
Checking which properties have changed imposes a small amount of overhead, and so this method |
||||
may be slower when all or nearly all of the properties being set have changed. If most or all |
||||
of the properties being set have not changed, this method will be much faster than unconditionally |
||||
setting all of them, and will also reduce how much data has to be written to the Realm, saving |
||||
both i/o time and disk space. |
||||
|
||||
If the `value` argument is an array, all properties must be present, valid and in the same |
||||
order as the properties defined in the model. |
||||
|
||||
@param realm The Realm which should own the object. |
||||
@param value The value used to populate the object. |
||||
|
||||
@see `defaultPropertyValues`, `primaryKey` |
||||
*/ |
||||
+ (instancetype)createOrUpdateModifiedInRealm:(RLMRealm *)realm withValue:(id)value; |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The Realm which manages the object, or `nil` if the object is unmanaged. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) RLMRealm *realm; |
||||
|
||||
/**
|
||||
The object schema which lists the managed properties for the object. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMObjectSchema *objectSchema; |
||||
|
||||
/**
|
||||
Indicates if the object can no longer be accessed because it is now invalid. |
||||
|
||||
An object can no longer be accessed if the object has been deleted from the Realm that manages it, or |
||||
if `invalidate` is called on that Realm. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
|
||||
#pragma mark - Customizing your Objects |
||||
|
||||
/**
|
||||
Returns an array of property names for properties which should be indexed. |
||||
|
||||
Only string, integer, boolean, and `NSDate` properties are supported. |
||||
|
||||
@return An array of property names. |
||||
*/ |
||||
+ (NSArray<NSString *> *)indexedProperties; |
||||
|
||||
/**
|
||||
Override this method to specify the default values to be used for each property. |
||||
|
||||
@return A dictionary mapping property names to their default values. |
||||
*/ |
||||
+ (nullable NSDictionary *)defaultPropertyValues; |
||||
|
||||
/**
|
||||
Override this method to specify the name of a property to be used as the primary key. |
||||
|
||||
Only properties of types `RLMPropertyTypeString` and `RLMPropertyTypeInt` can be designated as the primary key. |
||||
Primary key properties enforce uniqueness for each value whenever the property is set, which incurs minor overhead. |
||||
Indexes are created automatically for primary key properties. |
||||
|
||||
@return The name of the property designated as the primary key. |
||||
*/ |
||||
+ (nullable NSString *)primaryKey; |
||||
|
||||
/**
|
||||
Override this method to specify the names of properties to ignore. These properties will not be managed by the Realm |
||||
that manages the object. |
||||
|
||||
@return An array of property names to ignore. |
||||
*/ |
||||
+ (nullable NSArray<NSString *> *)ignoredProperties; |
||||
|
||||
/**
|
||||
Override this method to specify the names of properties that are non-optional (i.e. cannot be assigned a `nil` value). |
||||
|
||||
By default, all properties of a type whose values can be set to `nil` are considered optional properties. |
||||
To require that an object in a Realm always store a non-`nil` value for a property, |
||||
add the name of the property to the array returned from this method. |
||||
|
||||
Properties of `RLMObject` type cannot be non-optional. Array and `NSNumber` properties |
||||
can be non-optional, but there is no reason to do so: arrays do not support storing nil, and |
||||
if you want a non-optional number you should instead use the primitive type. |
||||
|
||||
@return An array of property names that are required. |
||||
*/ |
||||
+ (NSArray<NSString *> *)requiredProperties; |
||||
|
||||
/**
|
||||
Override this method to provide information related to properties containing linking objects. |
||||
|
||||
Each property of type `RLMLinkingObjects` must have a key in the dictionary returned by this method consisting |
||||
of the property name. The corresponding value must be an instance of `RLMPropertyDescriptor` that describes the class |
||||
and property that the property is linked to. |
||||
|
||||
return @{ @"owners": [RLMPropertyDescriptor descriptorWithClass:Owner.class propertyName:@"dogs"] }; |
||||
|
||||
@return A dictionary mapping property names to `RLMPropertyDescriptor` instances. |
||||
*/ |
||||
+ (NSDictionary<NSString *, RLMPropertyDescriptor *> *)linkingObjectsProperties; |
||||
|
||||
|
||||
#pragma mark - Getting & Querying Objects from the Default Realm |
||||
|
||||
/**
|
||||
Returns all objects of this object type from the default Realm. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the default Realm. |
||||
*/ |
||||
+ (RLMResults *)allObjects; |
||||
|
||||
/**
|
||||
Returns all objects of this object type matching the given predicate from the default Realm. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the default Realm that match the given predicate. |
||||
*/ |
||||
+ (RLMResults *)objectsWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
+ (RLMResults<__kindof RLMObject *> *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
|
||||
/**
|
||||
Returns all objects of this object type matching the given predicate from the default Realm. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the default Realm that match the given predicate. |
||||
*/ |
||||
+ (RLMResults *)objectsWithPredicate:(nullable NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Retrieves the single instance of this object type with the given primary key from the default Realm. |
||||
|
||||
Returns the object from the default Realm which has the given primary key, or |
||||
`nil` if the object does not exist. This is slightly faster than the otherwise |
||||
equivalent `[[SubclassName objectsWhere:@"primaryKeyPropertyName = %@", key] firstObject]`. |
||||
|
||||
This method requires that `primaryKey` be overridden on the receiving subclass. |
||||
|
||||
@return An object of this object type, or `nil` if an object with the given primary key does not exist. |
||||
@see `-primaryKey` |
||||
*/ |
||||
+ (nullable instancetype)objectForPrimaryKey:(nullable id)primaryKey NS_SWIFT_NAME(object(forPrimaryKey:)); |
||||
|
||||
|
||||
#pragma mark - Querying Specific Realms |
||||
|
||||
/**
|
||||
Returns all objects of this object type from the specified Realm. |
||||
|
||||
@param realm The Realm to query. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the specified Realm. |
||||
*/ |
||||
+ (RLMResults *)allObjectsInRealm:(RLMRealm *)realm; |
||||
|
||||
/**
|
||||
Returns all objects of this object type matching the given predicate from the specified Realm. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
@param realm The Realm to query. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the specified Realm that match the given predicate. |
||||
*/ |
||||
+ (RLMResults *)objectsInRealm:(RLMRealm *)realm where:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
+ (RLMResults<__kindof RLMObject *> *)objectsInRealm:(RLMRealm *)realm where:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns all objects of this object type matching the given predicate from the specified Realm. |
||||
|
||||
@param predicate A predicate to use to filter the elements. |
||||
@param realm The Realm to query. |
||||
|
||||
@return An `RLMResults` containing all objects of this type in the specified Realm that match the given predicate. |
||||
*/ |
||||
+ (RLMResults *)objectsInRealm:(RLMRealm *)realm withPredicate:(nullable NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Retrieves the single instance of this object type with the given primary key from the specified Realm. |
||||
|
||||
Returns the object from the specified Realm which has the given primary key, or |
||||
`nil` if the object does not exist. This is slightly faster than the otherwise |
||||
equivalent `[[SubclassName objectsInRealm:realm where:@"primaryKeyPropertyName = %@", key] firstObject]`. |
||||
|
||||
This method requires that `primaryKey` be overridden on the receiving subclass. |
||||
|
||||
@return An object of this object type, or `nil` if an object with the given primary key does not exist. |
||||
@see `-primaryKey` |
||||
*/ |
||||
+ (nullable instancetype)objectInRealm:(RLMRealm *)realm forPrimaryKey:(nullable id)primaryKey NS_SWIFT_NAME(object(in:forPrimaryKey:)); |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
A callback block for `RLMObject` notifications. |
||||
|
||||
If the object is deleted from the managing Realm, the block is called with |
||||
`deleted` set to `YES` and the other two arguments are `nil`. The block will |
||||
never be called again after this. |
||||
|
||||
If the object is modified, the block will be called with `deleted` set to |
||||
`NO`, a `nil` error, and an array of `RLMPropertyChange` objects which |
||||
indicate which properties of the objects were modified. |
||||
|
||||
If an error occurs, `deleted` will be `NO`, `changes` will be `nil`, and |
||||
`error` will include information about the error. The block will never be |
||||
called again after an error occurs. |
||||
*/ |
||||
typedef void (^RLMObjectChangeBlock)(BOOL deleted, |
||||
NSArray<RLMPropertyChange *> *_Nullable changes, |
||||
NSError *_Nullable error); |
||||
|
||||
/**
|
||||
Registers a block to be called each time the object changes. |
||||
|
||||
The block will be asynchronously called after each write transaction which |
||||
deletes the object or modifies any of the managed properties of the object, |
||||
including self-assignments that set a property to its existing value. |
||||
|
||||
For write transactions performed on different threads or in differen |
||||
processes, the block will be called when the managing Realm is |
||||
(auto)refreshed to a version including the changes, while for local write |
||||
transactions it will be called at some point in the future after the write |
||||
transaction is committed. |
||||
|
||||
Notifications are delivered via the standard run loop, and so can't be |
||||
delivered while the run loop is blocked by other activity. When notifications |
||||
can't be delivered instantly, multiple notifications may be coalesced into a |
||||
single notification. |
||||
|
||||
Unlike with `RLMArray` and `RLMResults`, there is no "initial" callback made |
||||
after you add a new notification block. |
||||
|
||||
Only objects which are managed by a Realm can be observed in this way. You |
||||
must retain the returned token for as long as you want updates to be sent to |
||||
the block. To stop receiving updates, call `-invalidate` on the token. |
||||
|
||||
It is safe to capture a strong reference to the observed object within the |
||||
callback block. There is no retain cycle due to that the callback is retained |
||||
by the returned token and not by the object itself. |
||||
|
||||
@warning This method cannot be called during a write transaction, when the |
||||
containing Realm is read-only, or on an unmanaged object. |
||||
|
||||
@param block The block to be called whenever a change occurs. |
||||
@return A token which must be held for as long as you want updates to be delivered. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(RLMObjectChangeBlock)block; |
||||
|
||||
#pragma mark - Other Instance Methods |
||||
|
||||
/**
|
||||
Returns YES if another Realm object instance points to the same object as the receiver in the Realm managing |
||||
the receiver. |
||||
|
||||
For object types with a primary, key, `isEqual:` is overridden to use the same logic as this |
||||
method (along with a corresponding implementation for `hash`). |
||||
|
||||
@param object The object to compare the receiver to. |
||||
|
||||
@return Whether the object represents the same object as the receiver. |
||||
*/ |
||||
- (BOOL)isEqualToObject:(RLMObject *)object; |
||||
|
||||
#pragma mark - Dynamic Accessors |
||||
|
||||
/// :nodoc:
|
||||
- (nullable id)objectForKeyedSubscript:(NSString *)key; |
||||
|
||||
/// :nodoc:
|
||||
- (void)setObject:(nullable id)obj forKeyedSubscript:(NSString *)key; |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
Information about a specific property which changed in an `RLMObject` change notification. |
||||
*/ |
||||
@interface RLMPropertyChange : NSObject |
||||
|
||||
/**
|
||||
The name of the property which changed. |
||||
*/ |
||||
@property (nonatomic, readonly, strong) NSString *name; |
||||
|
||||
/**
|
||||
The value of the property before the change occurred. This will always be `nil` |
||||
if the change happened on the same thread as the notification and for `RLMArray` |
||||
properties. |
||||
|
||||
For object properties this will give the object which was previously linked to, |
||||
but that object will have its new values and not the values it had before the |
||||
changes. This means that `previousValue` may be a deleted object, and you will |
||||
need to check `invalidated` before accessing any of its properties. |
||||
*/ |
||||
@property (nonatomic, readonly, strong, nullable) id previousValue; |
||||
|
||||
/**
|
||||
The value of the property after the change occurred. This will always be `nil` |
||||
for `RLMArray` properties. |
||||
*/ |
||||
@property (nonatomic, readonly, strong, nullable) id value; |
||||
@end |
||||
|
||||
#pragma mark - RLMArray Property Declaration |
||||
|
||||
/**
|
||||
Properties on `RLMObject`s of type `RLMArray` must have an associated type. A type is associated |
||||
with an `RLMArray` property by defining a protocol for the object type that the array should contain. |
||||
To define the protocol for an object, you can use the macro RLM_ARRAY_TYPE: |
||||
|
||||
RLM_ARRAY_TYPE(ObjectType) |
||||
... |
||||
@property RLMArray<ObjectType *><ObjectType> *arrayOfObjectTypes; |
||||
*/ |
||||
#define RLM_ARRAY_TYPE(RLM_OBJECT_SUBCLASS)\ |
||||
@protocol RLM_OBJECT_SUBCLASS <NSObject> \
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,44 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMRealm; |
||||
@class RLMSchema; |
||||
@class RLMObjectSchema; |
||||
|
||||
/// :nodoc:
|
||||
@interface RLMObjectBase : NSObject |
||||
|
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
- (instancetype)init NS_DESIGNATED_INITIALIZER; |
||||
|
||||
+ (NSString *)className; |
||||
|
||||
// Returns whether the class is included in the default set of classes managed by a Realm.
|
||||
+ (BOOL)shouldIncludeInDefaultSchema; |
||||
|
||||
+ (nullable NSString *)_realmObjectName; |
||||
+ (nullable NSDictionary<NSString *, NSString *> *)_realmColumnNames; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,82 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMObject.h> |
||||
|
||||
@class RLMObjectSchema, RLMRealm; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
Returns the Realm that manages the object, if one exists. |
||||
|
||||
@warning This function is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is |
||||
recommended to retrieve the Realm that manages the object via `RLMObject`. |
||||
|
||||
@param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. |
||||
|
||||
@return The Realm which manages this object. Returns `nil `for unmanaged objects. |
||||
*/ |
||||
FOUNDATION_EXTERN RLMRealm * _Nullable RLMObjectBaseRealm(RLMObjectBase * _Nullable object); |
||||
|
||||
/**
|
||||
Returns an `RLMObjectSchema` which describes the managed properties of the object. |
||||
|
||||
@warning This function is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is |
||||
recommended to retrieve `objectSchema` via `RLMObject`. |
||||
|
||||
@param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. |
||||
|
||||
@return The object schema which lists the managed properties for the object. |
||||
*/ |
||||
FOUNDATION_EXTERN RLMObjectSchema * _Nullable RLMObjectBaseObjectSchema(RLMObjectBase * _Nullable object); |
||||
|
||||
/**
|
||||
Returns the object corresponding to a key value. |
||||
|
||||
@warning This function is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is |
||||
recommended to retrieve key values via `RLMObject`. |
||||
|
||||
@warning Will throw an `NSUndefinedKeyException` if `key` is not present on the object. |
||||
|
||||
@param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. |
||||
@param key The name of the property. |
||||
|
||||
@return The object for the property requested. |
||||
*/ |
||||
FOUNDATION_EXTERN id _Nullable RLMObjectBaseObjectForKeyedSubscript(RLMObjectBase * _Nullable object, NSString *key); |
||||
|
||||
/**
|
||||
Sets a value for a key on the object. |
||||
|
||||
@warning This function is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is |
||||
recommended to set key values via `RLMObject`. |
||||
|
||||
@warning Will throw an `NSUndefinedKeyException` if `key` is not present on the object. |
||||
|
||||
@param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`. |
||||
@param key The name of the property. |
||||
@param obj The object to set as the value of the key. |
||||
*/ |
||||
FOUNDATION_EXTERN void RLMObjectBaseSetObjectForKeyedSubscript(RLMObjectBase * _Nullable object, NSString *key, id _Nullable obj); |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,72 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMProperty; |
||||
|
||||
/**
|
||||
This class represents Realm model object schemas. |
||||
|
||||
When using Realm, `RLMObjectSchema` instances allow performing migrations and |
||||
introspecting the database's schema. |
||||
|
||||
Object schemas map to tables in the core database. |
||||
*/ |
||||
@interface RLMObjectSchema : NSObject<NSCopying> |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
An array of `RLMProperty` instances representing the managed properties of a class described by the schema. |
||||
|
||||
@see `RLMProperty` |
||||
*/ |
||||
@property (nonatomic, readonly, copy) NSArray<RLMProperty *> *properties; |
||||
|
||||
/**
|
||||
The name of the class the schema describes. |
||||
*/ |
||||
@property (nonatomic, readonly) NSString *className; |
||||
|
||||
/**
|
||||
The property which serves as the primary key for the class the schema describes, if any. |
||||
*/ |
||||
@property (nonatomic, readonly, nullable) RLMProperty *primaryKeyProperty; |
||||
|
||||
#pragma mark - Methods |
||||
|
||||
/**
|
||||
Retrieves an `RLMProperty` object by the property name. |
||||
|
||||
@param propertyName The property's name. |
||||
|
||||
@return An `RLMProperty` object, or `nil` if there is no property with the given name. |
||||
*/ |
||||
- (nullable RLMProperty *)objectForKeyedSubscript:(NSString *)propertyName; |
||||
|
||||
/**
|
||||
Returns whether two `RLMObjectSchema` instances are equal. |
||||
*/ |
||||
- (BOOL)isEqualToObjectSchema:(RLMObjectSchema *)objectSchema; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,22 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !TARGET_OS_IPHONE |
||||
#error Attempting to use Realm's iOS framework in an OSX project. |
||||
#endif |
||||
|
||||
@ -0,0 +1,126 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMConstants.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/// :nodoc:
|
||||
@protocol RLMInt @end |
||||
/// :nodoc:
|
||||
@protocol RLMBool @end |
||||
/// :nodoc:
|
||||
@protocol RLMDouble @end |
||||
/// :nodoc:
|
||||
@protocol RLMFloat @end |
||||
/// :nodoc:
|
||||
@protocol RLMString @end |
||||
/// :nodoc:
|
||||
@protocol RLMDate @end |
||||
/// :nodoc:
|
||||
@protocol RLMData @end |
||||
|
||||
/// :nodoc:
|
||||
@interface NSNumber ()<RLMInt, RLMBool, RLMDouble, RLMFloat> |
||||
@end |
||||
|
||||
/**
|
||||
`RLMProperty` instances represent properties managed by a Realm in the context |
||||
of an object schema. Such properties may be persisted to a Realm file or |
||||
computed from other data from the Realm. |
||||
|
||||
When using Realm, `RLMProperty` instances allow performing migrations and |
||||
introspecting the database's schema. |
||||
|
||||
These property instances map to columns in the core database. |
||||
*/ |
||||
@interface RLMProperty : NSObject |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The name of the property. |
||||
*/ |
||||
@property (nonatomic, readonly) NSString *name; |
||||
|
||||
/**
|
||||
The type of the property. |
||||
|
||||
@see `RLMPropertyType` |
||||
*/ |
||||
@property (nonatomic, readonly) RLMPropertyType type; |
||||
|
||||
/**
|
||||
Indicates whether this property is indexed. |
||||
|
||||
@see `RLMObject` |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL indexed; |
||||
|
||||
/**
|
||||
For `RLMObject` and `RLMArray` properties, the name of the class of object stored in the property. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *objectClassName; |
||||
|
||||
/**
|
||||
For linking objects properties, the property name of the property the linking objects property is linked to. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *linkOriginPropertyName; |
||||
|
||||
/**
|
||||
Indicates whether this property is optional. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL optional; |
||||
|
||||
/**
|
||||
Indicates whether this property is an array. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL array; |
||||
|
||||
#pragma mark - Methods |
||||
|
||||
/**
|
||||
Returns whether a given property object is equal to the receiver. |
||||
*/ |
||||
- (BOOL)isEqualToProperty:(RLMProperty *)property; |
||||
|
||||
@end |
||||
|
||||
|
||||
/**
|
||||
An `RLMPropertyDescriptor` instance represents a specific property on a given class. |
||||
*/ |
||||
@interface RLMPropertyDescriptor : NSObject |
||||
|
||||
/**
|
||||
Creates and returns a property descriptor. |
||||
|
||||
@param objectClass The class of this property descriptor. |
||||
@param propertyName The name of this property descriptor. |
||||
*/ |
||||
+ (instancetype)descriptorWithClass:(Class)objectClass propertyName:(NSString *)propertyName; |
||||
|
||||
/// The class of the property.
|
||||
@property (nonatomic, readonly) Class objectClass; |
||||
|
||||
/// The name of the property.
|
||||
@property (nonatomic, readonly) NSString *propertyName; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,56 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2017 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
#import "RLMRealm.h" |
||||
|
||||
@class RLMResults, RLMSyncSession; |
||||
|
||||
/**
|
||||
A callback used to vend the results of a partial sync fetch. |
||||
*/ |
||||
typedef void(^RLMPartialSyncFetchCallback)(RLMResults * _Nullable results, NSError * _Nullable error); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
///
|
||||
@interface RLMRealm (Sync) |
||||
|
||||
/**
|
||||
If the Realm is a partially synchronized Realm, fetch and synchronize the objects |
||||
of a given object type that match the given query (in string format). |
||||
|
||||
The results will be returned asynchronously in the callback. |
||||
Use `-[RLMResults addNotificationBlock:]` to be notified to changes to the set of |
||||
synchronized objects. |
||||
|
||||
@warning Partial synchronization is a tech preview. Its APIs are subject to change. |
||||
*/ |
||||
- (void)subscribeToObjects:(Class)type where:(NSString *)query callback:(RLMPartialSyncFetchCallback)callback |
||||
__deprecated_msg("Use -[RLMResults subscribe]"); |
||||
|
||||
/**
|
||||
Get the RLMSyncSession used by this Realm. Will be nil if this is not a |
||||
synchronized Realm. |
||||
*/ |
||||
@property (nonatomic, nullable, readonly) RLMSyncSession *syncSession; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,736 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import "RLMConstants.h" |
||||
|
||||
@class RLMRealmConfiguration, RLMRealm, RLMObject, RLMSchema, RLMMigration, RLMNotificationToken, RLMThreadSafeReference; |
||||
struct RLMRealmPrivileges; |
||||
struct RLMClassPrivileges; |
||||
struct RLMObjectPrivileges; |
||||
|
||||
/**
|
||||
A callback block for opening Realms asynchronously. |
||||
|
||||
Returns the Realm if the open was successful, or an error otherwise. |
||||
*/ |
||||
typedef void(^RLMAsyncOpenRealmCallback)(RLMRealm * _Nullable realm, NSError * _Nullable error); |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
An `RLMRealm` instance (also referred to as "a Realm") represents a Realm |
||||
database. |
||||
|
||||
Realms can either be stored on disk (see `+[RLMRealm realmWithURL:]`) or in |
||||
memory (see `RLMRealmConfiguration`). |
||||
|
||||
`RLMRealm` instances are cached internally, and constructing equivalent `RLMRealm` |
||||
objects (for example, by using the same path or identifier) multiple times on a single thread |
||||
within a single iteration of the run loop will normally return the same |
||||
`RLMRealm` object. |
||||
|
||||
If you specifically want to ensure an `RLMRealm` instance is |
||||
destroyed (for example, if you wish to open a Realm, check some property, and |
||||
then possibly delete the Realm file and re-open it), place the code which uses |
||||
the Realm within an `@autoreleasepool {}` and ensure you have no other |
||||
strong references to it. |
||||
|
||||
@warning `RLMRealm` instances are not thread safe and cannot be shared across |
||||
threads or dispatch queues. Trying to do so will cause an exception to be thrown. |
||||
You must call this method on each thread you want |
||||
to interact with the Realm on. For dispatch queues, this means that you must |
||||
call it in each block which is dispatched, as a queue is not guaranteed to run |
||||
all of its blocks on the same thread. |
||||
*/ |
||||
|
||||
@interface RLMRealm : NSObject |
||||
|
||||
#pragma mark - Creating & Initializing a Realm |
||||
|
||||
/**
|
||||
Obtains an instance of the default Realm. |
||||
|
||||
The default Realm is used by the `RLMObject` class methods |
||||
which do not take an `RLMRealm` parameter, but is otherwise not special. The |
||||
default Realm is persisted as *default.realm* under the *Documents* directory of |
||||
your Application on iOS, and in your application's *Application Support* |
||||
directory on OS X. |
||||
|
||||
The default Realm is created using the default `RLMRealmConfiguration`, which |
||||
can be changed via `+[RLMRealmConfiguration setDefaultConfiguration:]`. |
||||
|
||||
@return The default `RLMRealm` instance for the current thread. |
||||
*/ |
||||
+ (instancetype)defaultRealm; |
||||
|
||||
/**
|
||||
Obtains an `RLMRealm` instance with the given configuration. |
||||
|
||||
@param configuration A configuration object to use when creating the Realm. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return An `RLMRealm` instance. |
||||
*/ |
||||
+ (nullable instancetype)realmWithConfiguration:(RLMRealmConfiguration *)configuration error:(NSError **)error; |
||||
|
||||
/**
|
||||
Obtains an `RLMRealm` instance persisted at a specified file URL. |
||||
|
||||
@param fileURL The local URL of the file the Realm should be saved at. |
||||
|
||||
@return An `RLMRealm` instance. |
||||
*/ |
||||
+ (instancetype)realmWithURL:(NSURL *)fileURL; |
||||
|
||||
/**
|
||||
Asynchronously open a Realm and deliver it to a block on the given queue. |
||||
|
||||
Opening a Realm asynchronously will perform all work needed to get the Realm to |
||||
a usable state (such as running potentially time-consuming migrations) on a |
||||
background thread before dispatching to the given queue. In addition, |
||||
synchronized Realms wait for all remote content available at the time the |
||||
operation began to be downloaded and available locally. |
||||
|
||||
@param configuration A configuration object to use when opening the Realm. |
||||
@param callbackQueue The dispatch queue on which the callback should be run. |
||||
@param callback A callback block. If the Realm was successfully opened, |
||||
it will be passed in as an argument. |
||||
Otherwise, an `NSError` describing what went wrong will be |
||||
passed to the block instead. |
||||
|
||||
@note The returned Realm is confined to the thread on which it was created. |
||||
Because GCD does not guarantee that queues will always use the same |
||||
thread, accessing the returned Realm outside the callback block (even if |
||||
accessed from `callbackQueue`) is unsafe. |
||||
*/ |
||||
+ (void)asyncOpenWithConfiguration:(RLMRealmConfiguration *)configuration |
||||
callbackQueue:(dispatch_queue_t)callbackQueue |
||||
callback:(RLMAsyncOpenRealmCallback)callback; |
||||
|
||||
/**
|
||||
The `RLMSchema` used by the Realm. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMSchema *schema; |
||||
|
||||
/**
|
||||
Indicates if the Realm is currently engaged in a write transaction. |
||||
|
||||
@warning Do not simply check this property and then start a write transaction whenever an object needs to be |
||||
created, updated, or removed. Doing so might cause a large number of write transactions to be created, |
||||
degrading performance. Instead, always prefer performing multiple updates during a single transaction. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL inWriteTransaction; |
||||
|
||||
/**
|
||||
The `RLMRealmConfiguration` object that was used to create this `RLMRealm` instance. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMRealmConfiguration *configuration; |
||||
|
||||
/**
|
||||
Indicates if this Realm contains any objects. |
||||
*/ |
||||
@property (nonatomic, readonly) BOOL isEmpty; |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
The type of a block to run whenever the data within the Realm is modified. |
||||
|
||||
@see `-[RLMRealm addNotificationBlock:]` |
||||
*/ |
||||
typedef void (^RLMNotificationBlock)(RLMNotification notification, RLMRealm *realm); |
||||
|
||||
#pragma mark - Receiving Notification when a Realm Changes |
||||
|
||||
/**
|
||||
Adds a notification handler for changes in this Realm, and returns a notification token. |
||||
|
||||
Notification handlers are called after each write transaction is committed, |
||||
either on the current thread or other threads. |
||||
|
||||
Handler blocks are called on the same thread that they were added on, and may |
||||
only be added on threads which are currently within a run loop. Unless you are |
||||
specifically creating and running a run loop on a background thread, this will |
||||
normally only be the main thread. |
||||
|
||||
The block has the following definition: |
||||
|
||||
typedef void(^RLMNotificationBlock)(RLMNotification notification, RLMRealm *realm); |
||||
|
||||
It receives the following parameters: |
||||
|
||||
- `NSString` \***notification**: The name of the incoming notification. See |
||||
`RLMRealmNotification` for information on what |
||||
notifications are sent. |
||||
- `RLMRealm` \***realm**: The Realm for which this notification occurred. |
||||
|
||||
@param block A block which is called to process Realm notifications. |
||||
|
||||
@return A token object which must be retained as long as you wish to continue |
||||
receiving change notifications. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(RLMNotificationBlock)block __attribute__((warn_unused_result)); |
||||
|
||||
#pragma mark - Transactions |
||||
|
||||
|
||||
#pragma mark - Writing to a Realm |
||||
|
||||
/**
|
||||
Begins a write transaction on the Realm. |
||||
|
||||
Only one write transaction can be open at a time for each Realm file. Write |
||||
transactions cannot be nested, and trying to begin a write transaction on a |
||||
Realm which is already in a write transaction will throw an exception. Calls to |
||||
`beginWriteTransaction` from `RLMRealm` instances for the same Realm file in |
||||
other threads or other processes will block until the current write transaction |
||||
completes or is cancelled. |
||||
|
||||
Before beginning the write transaction, `beginWriteTransaction` updates the |
||||
`RLMRealm` instance to the latest Realm version, as if `refresh` had been |
||||
called, and generates notifications if applicable. This has no effect if the |
||||
Realm was already up to date. |
||||
|
||||
It is rarely a good idea to have write transactions span multiple cycles of |
||||
the run loop, but if you do wish to do so you will need to ensure that the |
||||
Realm participating in the write transaction is kept alive until the write |
||||
transaction is committed. |
||||
*/ |
||||
- (void)beginWriteTransaction; |
||||
|
||||
/**
|
||||
Commits all write operations in the current write transaction, and ends the |
||||
transaction. |
||||
|
||||
After saving the changes, all notification blocks registered on this specific |
||||
`RLMRealm` instance are invoked synchronously. Notification blocks registered |
||||
on other threads or on collections are invoked asynchronously. If you do not |
||||
want to receive a specific notification for this write tranaction, see |
||||
`commitWriteTransactionWithoutNotifying:error:`. |
||||
|
||||
This method can fail if there is insufficient disk space available to save the |
||||
writes made, or due to unexpected i/o errors. This version of the method throws |
||||
an exception when errors occur. Use the version with a `NSError` out parameter |
||||
instead if you wish to handle errors. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
*/ |
||||
- (void)commitWriteTransaction NS_SWIFT_UNAVAILABLE(""); |
||||
|
||||
/**
|
||||
Commits all write operations in the current write transaction, and ends the |
||||
transaction. |
||||
|
||||
After saving the changes, all notification blocks registered on this specific |
||||
`RLMRealm` instance are invoked synchronously. Notification blocks registered |
||||
on other threads or on collections are invoked asynchronously. If you do not |
||||
want to receive a specific notification for this write tranaction, see |
||||
`commitWriteTransactionWithoutNotifying:error:`. |
||||
|
||||
This method can fail if there is insufficient disk space available to save the |
||||
writes made, or due to unexpected i/o errors. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return Whether the transaction succeeded. |
||||
*/ |
||||
- (BOOL)commitWriteTransaction:(NSError **)error; |
||||
|
||||
/**
|
||||
Commits all write operations in the current write transaction, without |
||||
notifying specific notification blocks of the changes. |
||||
|
||||
After saving the changes, all notification blocks registered on this specific |
||||
`RLMRealm` instance are invoked synchronously. Notification blocks registered |
||||
on other threads or on collections are scheduled to be invoked asynchronously. |
||||
|
||||
You can skip notifiying specific notification blocks about the changes made |
||||
in this write transaction by passing in their associated notification tokens. |
||||
This is primarily useful when the write transaction is saving changes already |
||||
made in the UI and you do not want to have the notification block attempt to |
||||
re-apply the same changes. |
||||
|
||||
The tokens passed to this method must be for notifications for this specific |
||||
`RLMRealm` instance. Notifications for different threads cannot be skipped |
||||
using this method. |
||||
|
||||
This method can fail if there is insufficient disk space available to save the |
||||
writes made, or due to unexpected i/o errors. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param tokens An array of notification tokens which were returned from adding |
||||
callbacks which you do not want to be notified for the changes |
||||
made in this write transaction. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return Whether the transaction succeeded. |
||||
*/ |
||||
- (BOOL)commitWriteTransactionWithoutNotifying:(NSArray<RLMNotificationToken *> *)tokens error:(NSError **)error; |
||||
|
||||
/**
|
||||
Reverts all writes made during the current write transaction and ends the transaction. |
||||
|
||||
This rolls back all objects in the Realm to the state they were in at the |
||||
beginning of the write transaction, and then ends the transaction. |
||||
|
||||
This restores the data for deleted objects, but does not revive invalidated |
||||
object instances. Any `RLMObject`s which were added to the Realm will be |
||||
invalidated rather than becoming unmanaged. |
||||
Given the following code: |
||||
|
||||
ObjectType *oldObject = [[ObjectType objectsWhere:@"..."] firstObject]; |
||||
ObjectType *newObject = [[ObjectType alloc] init]; |
||||
|
||||
[realm beginWriteTransaction]; |
||||
[realm addObject:newObject]; |
||||
[realm deleteObject:oldObject]; |
||||
[realm cancelWriteTransaction]; |
||||
|
||||
Both `oldObject` and `newObject` will return `YES` for `isInvalidated`, |
||||
but re-running the query which provided `oldObject` will once again return |
||||
the valid object. |
||||
|
||||
KVO observers on any objects which were modified during the transaction will |
||||
be notified about the change back to their initial values, but no other |
||||
notifcations are produced by a cancelled write transaction. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
*/ |
||||
- (void)cancelWriteTransaction; |
||||
|
||||
/**
|
||||
Performs actions contained within the given block inside a write transaction. |
||||
|
||||
@see `[RLMRealm transactionWithBlock:error:]` |
||||
*/ |
||||
- (void)transactionWithBlock:(__attribute__((noescape)) void(^)(void))block NS_SWIFT_UNAVAILABLE(""); |
||||
|
||||
/**
|
||||
Performs actions contained within the given block inside a write transaction. |
||||
|
||||
Write transactions cannot be nested, and trying to execute a write transaction |
||||
on a Realm which is already participating in a write transaction will throw an |
||||
exception. Calls to `transactionWithBlock:` from `RLMRealm` instances in other |
||||
threads will block until the current write transaction completes. |
||||
|
||||
Before beginning the write transaction, `transactionWithBlock:` updates the |
||||
`RLMRealm` instance to the latest Realm version, as if `refresh` had been called, and |
||||
generates notifications if applicable. This has no effect if the Realm |
||||
was already up to date. |
||||
|
||||
@param block The block containing actions to perform. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return Whether the transaction succeeded. |
||||
*/ |
||||
- (BOOL)transactionWithBlock:(__attribute__((noescape)) void(^)(void))block error:(NSError **)error; |
||||
|
||||
/**
|
||||
Updates the Realm and outstanding objects managed by the Realm to point to the |
||||
most recent data. |
||||
|
||||
If the version of the Realm is actually changed, Realm and collection |
||||
notifications will be sent to reflect the changes. This may take some time, as |
||||
collection notifications are prepared on a background thread. As a result, |
||||
calling this method on the main thread is not advisable. |
||||
|
||||
@return Whether there were any updates for the Realm. Note that `YES` may be |
||||
returned even if no data actually changed. |
||||
*/ |
||||
- (BOOL)refresh; |
||||
|
||||
/**
|
||||
Set this property to `YES` to automatically update this Realm when changes |
||||
happen in other threads. |
||||
|
||||
If set to `YES` (the default), changes made on other threads will be reflected |
||||
in this Realm on the next cycle of the run loop after the changes are |
||||
committed. If set to `NO`, you must manually call `-refresh` on the Realm to |
||||
update it to get the latest data. |
||||
|
||||
Note that by default, background threads do not have an active run loop and you |
||||
will need to manually call `-refresh` in order to update to the latest version, |
||||
even if `autorefresh` is set to `YES`. |
||||
|
||||
Even with this property enabled, you can still call `-refresh` at any time to |
||||
update the Realm before the automatic refresh would occur. |
||||
|
||||
Write transactions will still always advance a Realm to the latest version and |
||||
produce local notifications on commit even if autorefresh is disabled. |
||||
|
||||
Disabling `autorefresh` on a Realm without any strong references to it will not |
||||
have any effect, and `autorefresh` will revert back to `YES` the next time the |
||||
Realm is created. This is normally irrelevant as it means that there is nothing |
||||
to refresh (as managed `RLMObject`s, `RLMArray`s, and `RLMResults` have strong |
||||
references to the Realm that manages them), but it means that setting |
||||
`RLMRealm.defaultRealm.autorefresh = NO` in |
||||
`application:didFinishLaunchingWithOptions:` and only later storing Realm |
||||
objects will not work. |
||||
|
||||
Defaults to `YES`. |
||||
*/ |
||||
@property (nonatomic) BOOL autorefresh; |
||||
|
||||
/**
|
||||
Writes a compacted and optionally encrypted copy of the Realm to the given local URL. |
||||
|
||||
The destination file cannot already exist. |
||||
|
||||
Note that if this method is called from within a write transaction, the |
||||
*current* data is written, not the data from the point when the previous write |
||||
transaction was committed. |
||||
|
||||
@param fileURL Local URL to save the Realm to. |
||||
@param key Optional 64-byte encryption key to encrypt the new file with. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return `YES` if the Realm was successfully written to disk, `NO` if an error occurred. |
||||
*/ |
||||
- (BOOL)writeCopyToURL:(NSURL *)fileURL encryptionKey:(nullable NSData *)key error:(NSError **)error; |
||||
|
||||
/**
|
||||
Invalidates all `RLMObject`s, `RLMResults`, `RLMLinkingObjects`, and `RLMArray`s managed by the Realm. |
||||
|
||||
A Realm holds a read lock on the version of the data accessed by it, so |
||||
that changes made to the Realm on different threads do not modify or delete the |
||||
data seen by this Realm. Calling this method releases the read lock, |
||||
allowing the space used on disk to be reused by later write transactions rather |
||||
than growing the file. This method should be called before performing long |
||||
blocking operations on a background thread on which you previously read data |
||||
from the Realm which you no longer need. |
||||
|
||||
All `RLMObject`, `RLMResults` and `RLMArray` instances obtained from this |
||||
`RLMRealm` instance on the current thread are invalidated. `RLMObject`s and `RLMArray`s |
||||
cannot be used. `RLMResults` will become empty. The Realm itself remains valid, |
||||
and a new read transaction is implicitly begun the next time data is read from the Realm. |
||||
|
||||
Calling this method multiple times in a row without reading any data from the |
||||
Realm, or before ever reading any data from the Realm, is a no-op. This method |
||||
may not be called on a read-only Realm. |
||||
*/ |
||||
- (void)invalidate; |
||||
|
||||
#pragma mark - Accessing Objects |
||||
|
||||
/**
|
||||
Returns the same object as the one referenced when the `RLMThreadSafeReference` was first created, |
||||
but resolved for the current Realm for this thread. Returns `nil` if this object was deleted after |
||||
the reference was created. |
||||
|
||||
@param reference The thread-safe reference to the thread-confined object to resolve in this Realm. |
||||
|
||||
@warning A `RLMThreadSafeReference` object must be resolved at most once. |
||||
Failing to resolve a `RLMThreadSafeReference` will result in the source version of the |
||||
Realm being pinned until the reference is deallocated. |
||||
An exception will be thrown if a reference is resolved more than once. |
||||
|
||||
@warning Cannot call within a write transaction. |
||||
|
||||
@note Will refresh this Realm if the source Realm was at a later version than this one. |
||||
|
||||
@see `+[RLMThreadSafeReference referenceWithThreadConfined:]` |
||||
*/ |
||||
- (nullable id)resolveThreadSafeReference:(RLMThreadSafeReference *)reference |
||||
NS_REFINED_FOR_SWIFT; |
||||
|
||||
#pragma mark - Adding and Removing Objects from a Realm |
||||
|
||||
/**
|
||||
Adds an object to the Realm. |
||||
|
||||
Once added, this object is considered to be managed by the Realm. It can be retrieved |
||||
using the `objectsWhere:` selectors on `RLMRealm` and on subclasses of `RLMObject`. |
||||
|
||||
When added, all child relationships referenced by this object will also be added to |
||||
the Realm if they are not already in it. |
||||
|
||||
If the object or any related objects are already being managed by a different Realm |
||||
an exception will be thrown. Use `-[RLMObject createInRealm:withObject:]` to insert a copy of a managed object |
||||
into a different Realm. |
||||
|
||||
The object to be added must be valid and cannot have been previously deleted |
||||
from a Realm (i.e. `isInvalidated` must be `NO`). |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param object The object to be added to this Realm. |
||||
*/ |
||||
- (void)addObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Adds all the objects in a collection to the Realm. |
||||
|
||||
This is the equivalent of calling `addObject:` for every object in a collection. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param objects An enumerable collection such as `NSArray`, `RLMArray`, or `RLMResults`, |
||||
containing Realm objects to be added to the Realm. |
||||
|
||||
@see `addObject:` |
||||
*/ |
||||
- (void)addObjects:(id<NSFastEnumeration>)objects; |
||||
|
||||
/**
|
||||
Adds or updates an existing object into the Realm. |
||||
|
||||
The object provided must have a designated primary key. If no objects exist in the Realm |
||||
with the same primary key value, the object is inserted. Otherwise, the existing object is |
||||
updated with any changed values. |
||||
|
||||
As with `addObject:`, the object cannot already be managed by a different |
||||
Realm. Use `-[RLMObject createOrUpdateInRealm:withValue:]` to copy values to |
||||
a different Realm. |
||||
|
||||
If there is a property or KVC value on `object` whose value is nil, and it corresponds |
||||
to a nullable property on an existing object being updated, that nullable property will |
||||
be set to nil. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param object The object to be added or updated. |
||||
*/ |
||||
- (void)addOrUpdateObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Adds or updates all the objects in a collection into the Realm. |
||||
|
||||
This is the equivalent of calling `addOrUpdateObject:` for every object in a collection. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param objects An enumerable collection such as `NSArray`, `RLMArray`, or `RLMResults`, |
||||
containing Realm objects to be added to or updated within the Realm. |
||||
|
||||
@see `addOrUpdateObject:` |
||||
*/ |
||||
- (void)addOrUpdateObjects:(id<NSFastEnumeration>)objects; |
||||
|
||||
/**
|
||||
Deletes an object from the Realm. Once the object is deleted it is considered invalidated. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param object The object to be deleted. |
||||
*/ |
||||
- (void)deleteObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Deletes one or more objects from the Realm. |
||||
|
||||
This is the equivalent of calling `deleteObject:` for every object in a collection. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@param objects An enumerable collection such as `NSArray`, `RLMArray`, or `RLMResults`, |
||||
containing objects to be deleted from the Realm. |
||||
|
||||
@see `deleteObject:` |
||||
*/ |
||||
- (void)deleteObjects:(id<NSFastEnumeration>)objects; |
||||
|
||||
/**
|
||||
Deletes all objects from the Realm. |
||||
|
||||
@warning This method may only be called during a write transaction. |
||||
|
||||
@see `deleteObject:` |
||||
*/ |
||||
- (void)deleteAllObjects; |
||||
|
||||
|
||||
#pragma mark - Migrations |
||||
|
||||
/**
|
||||
The type of a migration block used to migrate a Realm. |
||||
|
||||
@param migration A `RLMMigration` object used to perform the migration. The |
||||
migration object allows you to enumerate and alter any |
||||
existing objects which require migration. |
||||
|
||||
@param oldSchemaVersion The schema version of the Realm being migrated. |
||||
*/ |
||||
typedef void (^RLMMigrationBlock)(RLMMigration *migration, uint64_t oldSchemaVersion); |
||||
|
||||
/**
|
||||
Returns the schema version for a Realm at a given local URL. |
||||
|
||||
@param fileURL Local URL to a Realm file. |
||||
@param key 64-byte key used to encrypt the file, or `nil` if it is unencrypted. |
||||
@param error If an error occurs, upon return contains an `NSError` object |
||||
that describes the problem. If you are not interested in |
||||
possible errors, pass in `NULL`. |
||||
|
||||
@return The version of the Realm at `fileURL`, or `RLMNotVersioned` if the version cannot be read. |
||||
*/ |
||||
+ (uint64_t)schemaVersionAtURL:(NSURL *)fileURL encryptionKey:(nullable NSData *)key error:(NSError **)error |
||||
NS_REFINED_FOR_SWIFT; |
||||
|
||||
/**
|
||||
Performs the given Realm configuration's migration block on a Realm at the given path. |
||||
|
||||
This method is called automatically when opening a Realm for the first time and does |
||||
not need to be called explicitly. You can choose to call this method to control |
||||
exactly when and how migrations are performed. |
||||
|
||||
@param configuration The Realm configuration used to open and migrate the Realm. |
||||
@return The error that occurred while applying the migration, if any. |
||||
|
||||
@see RLMMigration |
||||
*/ |
||||
+ (BOOL)performMigrationForConfiguration:(RLMRealmConfiguration *)configuration error:(NSError **)error; |
||||
|
||||
#pragma mark - Privileges |
||||
|
||||
/**
|
||||
Returns the computed privileges which the current user has for this Realm. |
||||
|
||||
This combines all privileges granted on the Realm by all Roles which the |
||||
current User is a member of into the final privileges which will be enforced by |
||||
the server. |
||||
|
||||
The privilege calculation is done locally using cached data, and inherently may |
||||
be stale. It is possible that this method may indicate that an operation is |
||||
permitted but the server will still reject it if permission is revoked before |
||||
the changes have been integrated on the server. |
||||
|
||||
Non-synchronized Realms always have permission to perform all operations. |
||||
|
||||
@warning This currently returns incorrect results for non-partially-synchronized read-only Realms. |
||||
@return The privileges which the current user has for the current Realm. |
||||
*/ |
||||
- (struct RLMRealmPrivileges)privilegesForRealm; |
||||
|
||||
/**
|
||||
Returns the computed privileges which the current user has for the given object. |
||||
|
||||
This combines all privileges granted on the object by all Roles which the |
||||
current User is a member of into the final privileges which will be enforced by |
||||
the server. |
||||
|
||||
The privilege calculation is done locally using cached data, and inherently may |
||||
be stale. It is possible that this method may indicate that an operation is |
||||
permitted but the server will still reject it if permission is revoked before |
||||
the changes have been integrated on the server. |
||||
|
||||
Non-synchronized Realms always have permission to perform all operations. |
||||
|
||||
The object must be a valid object managed by this Realm. Passing in an |
||||
invalidated object, an unmanaged object, or an object managed by a different |
||||
Realm will throw an exception. |
||||
|
||||
@warning This currently returns incorrect results for non-partially-synchronized read-only Realms. |
||||
@return The privileges which the current user has for the given object. |
||||
*/ |
||||
- (struct RLMObjectPrivileges)privilegesForObject:(RLMObject *)object; |
||||
|
||||
/**
|
||||
Returns the computed privileges which the current user has for the given class. |
||||
|
||||
This combines all privileges granted on the class by all Roles which the |
||||
current User is a member of into the final privileges which will be enforced by |
||||
the server. |
||||
|
||||
The privilege calculation is done locally using cached data, and inherently may |
||||
be stale. It is possible that this method may indicate that an operation is |
||||
permitted but the server will still reject it if permission is revoked before |
||||
the changes have been integrated on the server. |
||||
|
||||
Non-synchronized Realms always have permission to perform all operations. |
||||
|
||||
@warning This currently returns incorrect results for non-partially-synchronized read-only Realms. |
||||
@return The privileges which the current user has for the given object. |
||||
*/ |
||||
- (struct RLMClassPrivileges)privilegesForClass:(Class)cls; |
||||
|
||||
/**
|
||||
Returns the computed privileges which the current user has for the named class. |
||||
|
||||
This combines all privileges granted on the class by all Roles which the |
||||
current User is a member of into the final privileges which will be enforced by |
||||
the server. |
||||
|
||||
The privilege calculation is done locally using cached data, and inherently may |
||||
be stale. It is possible that this method may indicate that an operation is |
||||
permitted but the server will still reject it if permission is revoked before |
||||
the changes have been integrated on the server. |
||||
|
||||
Non-synchronized Realms always have permission to perform all operations. |
||||
|
||||
@warning This currently returns incorrect results for non-partially-synchronized read-only Realms. |
||||
@return The privileges which the current user has for the given object. |
||||
*/ |
||||
- (struct RLMClassPrivileges)privilegesForClassNamed:(NSString *)className; |
||||
|
||||
#pragma mark - Unavailable Methods |
||||
|
||||
/**
|
||||
RLMRealm instances are cached internally by Realm and cannot be created directly. |
||||
|
||||
Use `+[RLMRealm defaultRealm]`, `+[RLMRealm realmWithConfiguration:error:]` or |
||||
`+[RLMRealm realmWithURL]` to obtain a reference to an RLMRealm. |
||||
*/ |
||||
- (instancetype)init __attribute__((unavailable("Use +defaultRealm, +realmWithConfiguration: or +realmWithURL:."))); |
||||
|
||||
/**
|
||||
RLMRealm instances are cached internally by Realm and cannot be created directly. |
||||
|
||||
Use `+[RLMRealm defaultRealm]`, `+[RLMRealm realmWithConfiguration:error:]` or |
||||
`+[RLMRealm realmWithURL]` to obtain a reference to an RLMRealm. |
||||
*/ |
||||
+ (instancetype)new __attribute__((unavailable("Use +defaultRealm, +realmWithConfiguration: or +realmWithURL:."))); |
||||
|
||||
/// :nodoc:
|
||||
- (void)addOrUpdateObjectsFromArray:(id)array __attribute__((unavailable("Renamed to -addOrUpdateObjects:."))); |
||||
|
||||
@end |
||||
|
||||
// MARK: - RLMNotificationToken
|
||||
|
||||
/**
|
||||
A token which is returned from methods which subscribe to changes to a Realm. |
||||
|
||||
Change subscriptions in Realm return an `RLMNotificationToken` instance, |
||||
which can be used to unsubscribe from the changes. You must store a strong |
||||
reference to the token for as long as you want to continue to receive notifications. |
||||
When you wish to stop, call the `-invalidate` method. Notifications are also stopped if |
||||
the token is deallocated. |
||||
*/ |
||||
@interface RLMNotificationToken : NSObject |
||||
/// Stops notifications for the change subscription that returned this token.
|
||||
- (void)invalidate; |
||||
|
||||
/// Stops notifications for the change subscription that returned this token.
|
||||
- (void)stop __attribute__((unavailable("Renamed to -invalidate."))) NS_REFINED_FOR_SWIFT; |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,43 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMRealmConfiguration.h> |
||||
|
||||
#import "RLMSyncUtil.h" |
||||
|
||||
@class RLMSyncConfiguration; |
||||
|
||||
/// Realm configuration options related to Sync.
|
||||
@interface RLMRealmConfiguration (Sync) |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
A configuration object representing configuration state for Realms intended |
||||
to sync with a Realm Object Server. |
||||
|
||||
This property is mutually exclusive with both `inMemoryIdentifier` and `fileURL`; |
||||
setting any one of the three properties will automatically nil out the other two. |
||||
|
||||
@see `RLMSyncConfiguration` |
||||
*/ |
||||
@property (nullable, nonatomic) RLMSyncConfiguration *syncConfiguration; |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
|
||||
@end |
||||
@ -0,0 +1,123 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2015 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
#import <Realm/RLMRealm.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
/**
|
||||
A block called when opening a Realm for the first time during the life |
||||
of a process to determine if it should be compacted before being returned |
||||
to the user. It is passed the total file size (data + free space) and the total |
||||
bytes used by data in the file. |
||||
|
||||
Return `YES` to indicate that an attempt to compact the file should be made. |
||||
The compaction will be skipped if another process is accessing it. |
||||
*/ |
||||
typedef BOOL (^RLMShouldCompactOnLaunchBlock)(NSUInteger totalBytes, NSUInteger bytesUsed); |
||||
|
||||
/**
|
||||
An `RLMRealmConfiguration` instance describes the different options used to |
||||
create an instance of a Realm. |
||||
|
||||
`RLMRealmConfiguration` instances are just plain `NSObject`s. Unlike `RLMRealm`s |
||||
and `RLMObject`s, they can be freely shared between threads as long as you do not |
||||
mutate them. |
||||
|
||||
Creating configuration objects for class subsets (by setting the |
||||
`objectClasses` property) can be expensive. Because of this, you will normally want to |
||||
cache and reuse a single configuration object for each distinct configuration rather than |
||||
creating a new object each time you open a Realm. |
||||
*/ |
||||
@interface RLMRealmConfiguration : NSObject<NSCopying> |
||||
|
||||
#pragma mark - Default Configuration |
||||
|
||||
/**
|
||||
Returns the default configuration used to create Realms when no other |
||||
configuration is explicitly specified (i.e. `+[RLMRealm defaultRealm]`). |
||||
|
||||
@return The default Realm configuration. |
||||
*/ |
||||
+ (instancetype)defaultConfiguration; |
||||
|
||||
/**
|
||||
Sets the default configuration to the given `RLMRealmConfiguration`. |
||||
|
||||
@param configuration The new default Realm configuration. |
||||
*/ |
||||
+ (void)setDefaultConfiguration:(RLMRealmConfiguration *)configuration; |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/// The local URL of the Realm file. Mutually exclusive with `inMemoryIdentifier` and `syncConfiguration`;
|
||||
/// setting any one of the three properties will automatically nil out the other two.
|
||||
@property (nonatomic, copy, nullable) NSURL *fileURL; |
||||
|
||||
/// A string used to identify a particular in-memory Realm. Mutually exclusive with `fileURL` and `syncConfiguration`;
|
||||
/// setting any one of the three properties will automatically nil out the other two.
|
||||
@property (nonatomic, copy, nullable) NSString *inMemoryIdentifier; |
||||
|
||||
/// A 64-byte key to use to encrypt the data, or `nil` if encryption is not enabled.
|
||||
@property (nonatomic, copy, nullable) NSData *encryptionKey; |
||||
|
||||
/// Whether to open the Realm in read-only mode.
|
||||
///
|
||||
/// This is required to be able to open Realm files which are not writeable or
|
||||
/// are in a directory which is not writeable. This should only be used on files
|
||||
/// which will not be modified by anyone while they are open, and not just to
|
||||
/// get a read-only view of a file which may be written to by another thread or
|
||||
/// process. Opening in read-only mode requires disabling Realm's reader/writer
|
||||
/// coordination, so committing a write transaction from another process will
|
||||
/// result in crashes.
|
||||
@property (nonatomic) BOOL readOnly; |
||||
|
||||
/// The current schema version.
|
||||
@property (nonatomic) uint64_t schemaVersion; |
||||
|
||||
/// The block which migrates the Realm to the current version.
|
||||
@property (nonatomic, copy, nullable) RLMMigrationBlock migrationBlock; |
||||
|
||||
/**
|
||||
Whether to recreate the Realm file with the provided schema if a migration is required. |
||||
This is the case when the stored schema differs from the provided schema or |
||||
the stored schema version differs from the version on this configuration. |
||||
Setting this property to `YES` deletes the file if a migration would otherwise be required or executed. |
||||
|
||||
@note Setting this property to `YES` doesn't disable file format migrations. |
||||
*/ |
||||
@property (nonatomic) BOOL deleteRealmIfMigrationNeeded; |
||||
|
||||
/**
|
||||
A block called when opening a Realm for the first time during the life |
||||
of a process to determine if it should be compacted before being returned |
||||
to the user. It is passed the total file size (data + free space) and the total |
||||
bytes used by data in the file. |
||||
|
||||
Return `YES` to indicate that an attempt to compact the file should be made. |
||||
The compaction will be skipped if another process is accessing it. |
||||
*/ |
||||
@property (nonatomic, copy, nullable) RLMShouldCompactOnLaunchBlock shouldCompactOnLaunch; |
||||
|
||||
/// The classes managed by the Realm.
|
||||
@property (nonatomic, copy, nullable) NSArray *objectClasses; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,118 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMRealm.h> |
||||
|
||||
#import <Realm/RLMObjectSchema.h> |
||||
#import <Realm/RLMProperty.h> |
||||
|
||||
@class RLMResults<RLMObjectType>; |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@interface RLMRealm (Dynamic) |
||||
|
||||
#pragma mark - Getting Objects from a Realm |
||||
|
||||
/**
|
||||
Returns all objects of a given type from the Realm. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. The preferred way to get objects of a single class is to use the class |
||||
methods on `RLMObject`. |
||||
|
||||
@param className The name of the `RLMObject` subclass to retrieve on (e.g. `MyClass.className`). |
||||
|
||||
@return An `RLMResults` containing all objects in the Realm of the given type. |
||||
|
||||
@see `+[RLMObject allObjects]` |
||||
*/ |
||||
- (RLMResults<RLMObject *> *)allObjects:(NSString *)className; |
||||
|
||||
/**
|
||||
Returns all objects matching the given predicate from the Realm. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. The preferred way to get objects of a single class is to use the class |
||||
methods on `RLMObject`. |
||||
|
||||
@param className The type of objects you are looking for (name of the class). |
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` containing results matching the given predicate. |
||||
|
||||
@see `+[RLMObject objectsWhere:]` |
||||
*/ |
||||
- (RLMResults<RLMObject *> *)objects:(NSString *)className where:(NSString *)predicateFormat, ...; |
||||
|
||||
/**
|
||||
Returns all objects matching the given predicate from the Realm. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. The preferred way to get objects of a single class is to use the class |
||||
methods on `RLMObject`. |
||||
|
||||
@param className The type of objects you are looking for (name of the class). |
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` containing results matching the given predicate. |
||||
|
||||
@see `+[RLMObject objectsWhere:]` |
||||
*/ |
||||
- (RLMResults<RLMObject *> *)objects:(NSString *)className withPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns the object of the given type with the given primary key from the Realm. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. The preferred way to get an object of a single class is to use the class |
||||
methods on `RLMObject`. |
||||
|
||||
@param className The class name for the object you are looking for. |
||||
@param primaryKey The primary key value for the object you are looking for. |
||||
|
||||
@return An object, or `nil` if an object with the given primary key does not exist. |
||||
|
||||
@see `+[RLMObject objectForPrimaryKey:]` |
||||
*/ |
||||
- (nullable RLMObject *)objectWithClassName:(NSString *)className forPrimaryKey:(id)primaryKey; |
||||
|
||||
/**
|
||||
Creates an `RLMObject` instance of type `className` in the Realm, and populates it using a given object. |
||||
|
||||
The `value` argument is used to populate the object. It can be a key-value coding compliant object, an array or |
||||
dictionary returned from the methods in `NSJSONSerialization`, or an array containing one element for each managed |
||||
property. An exception will be thrown if any required properties are not present and those properties were not defined |
||||
with default values. |
||||
|
||||
When passing in an array as the `value` argument, all properties must be present, valid and in the same order as the |
||||
properties defined in the model. |
||||
|
||||
@warning This method is useful only in specialized circumstances, for example, when building components |
||||
that integrate with Realm. If you are simply building an app on Realm, it is recommended to |
||||
use `[RLMObject createInDefaultRealmWithValue:]`. |
||||
|
||||
@param value The value used to populate the object. |
||||
|
||||
@return An `RLMObject` instance of type `className`. |
||||
*/ |
||||
-(RLMObject *)createObject:(NSString *)className withValue:(id)value; |
||||
|
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
@ -0,0 +1,351 @@ |
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2014 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#import <Realm/RLMCollection.h> |
||||
|
||||
NS_ASSUME_NONNULL_BEGIN |
||||
|
||||
@class RLMObject; |
||||
|
||||
/**
|
||||
`RLMResults` is an auto-updating container type in Realm returned from object |
||||
queries. It represents the results of the query in the form of a collection of objects. |
||||
|
||||
`RLMResults` can be queried using the same predicates as `RLMObject` and `RLMArray`, |
||||
and you can chain queries to further filter results. |
||||
|
||||
`RLMResults` always reflect the current state of the Realm on the current thread, |
||||
including during write transactions on the current thread. The one exception to |
||||
this is when using `for...in` fast enumeration, which will always enumerate |
||||
over the objects which matched the query when the enumeration is begun, even if |
||||
some of them are deleted or modified to be excluded by the filter during the |
||||
enumeration. |
||||
|
||||
`RLMResults` are lazily evaluated the first time they are accessed; they only |
||||
run queries when the result of the query is requested. This means that |
||||
chaining several temporary `RLMResults` to sort and filter your data does not |
||||
perform any extra work processing the intermediate state. |
||||
|
||||
Once the results have been evaluated or a notification block has been added, |
||||
the results are eagerly kept up-to-date, with the work done to keep them |
||||
up-to-date done on a background thread whenever possible. |
||||
|
||||
`RLMResults` cannot be directly instantiated. |
||||
*/ |
||||
@interface RLMResults<RLMObjectType> : NSObject<RLMCollection, NSFastEnumeration> |
||||
|
||||
#pragma mark - Properties |
||||
|
||||
/**
|
||||
The number of objects in the results collection. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) NSUInteger count; |
||||
|
||||
/**
|
||||
The type of the objects in the results collection. |
||||
*/ |
||||
@property (nonatomic, readonly, assign) RLMPropertyType type; |
||||
|
||||
/**
|
||||
Indicates whether the objects in the collection can be `nil`. |
||||
*/ |
||||
@property (nonatomic, readwrite, getter = isOptional) BOOL optional; |
||||
|
||||
/**
|
||||
The class name of the objects contained in the results collection. |
||||
|
||||
Will be `nil` if `type` is not RLMPropertyTypeObject. |
||||
*/ |
||||
@property (nonatomic, readonly, copy, nullable) NSString *objectClassName; |
||||
|
||||
/**
|
||||
The Realm which manages this results collection. |
||||
*/ |
||||
@property (nonatomic, readonly) RLMRealm *realm; |
||||
|
||||
/**
|
||||
Indicates if the results collection is no longer valid. |
||||
|
||||
The results collection becomes invalid if `invalidate` is called on the containing `realm`. |
||||
An invalidated results collection can be accessed, but will always be empty. |
||||
*/ |
||||
@property (nonatomic, readonly, getter = isInvalidated) BOOL invalidated; |
||||
|
||||
#pragma mark - Accessing Objects from an RLMResults |
||||
|
||||
/**
|
||||
Returns the object at the index specified. |
||||
|
||||
@param index The index to look up. |
||||
|
||||
@return An object of the type contained in the results collection. |
||||
*/ |
||||
- (RLMObjectType)objectAtIndex:(NSUInteger)index; |
||||
|
||||
/**
|
||||
Returns the first object in the results collection. |
||||
|
||||
Returns `nil` if called on an empty results collection. |
||||
|
||||
@return An object of the type contained in the results collection. |
||||
*/ |
||||
- (nullable RLMObjectType)firstObject; |
||||
|
||||
/**
|
||||
Returns the last object in the results collection. |
||||
|
||||
Returns `nil` if called on an empty results collection. |
||||
|
||||
@return An object of the type contained in the results collection. |
||||
*/ |
||||
- (nullable RLMObjectType)lastObject; |
||||
|
||||
#pragma mark - Querying Results |
||||
|
||||
/**
|
||||
Returns the index of an object in the results collection. |
||||
|
||||
Returns `NSNotFound` if the object is not found in the results collection. |
||||
|
||||
@param object An object (of the same type as returned from the `objectClassName` selector). |
||||
*/ |
||||
- (NSUInteger)indexOfObject:(RLMObjectType)object; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the results collection matching the predicate. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the results collection. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (NSUInteger)indexOfObjectWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns the index of the first object in the results collection matching the predicate. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return The index of the object, or `NSNotFound` if the object is not found in the results collection. |
||||
*/ |
||||
- (NSUInteger)indexOfObjectWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns all the objects matching the given predicate in the results collection. |
||||
|
||||
@param predicateFormat A predicate format string, optionally followed by a variable number of arguments. |
||||
|
||||
@return An `RLMResults` of objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)objectsWhere:(NSString *)predicateFormat, ...; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMResults<RLMObjectType> *)objectsWhere:(NSString *)predicateFormat args:(va_list)args; |
||||
|
||||
/**
|
||||
Returns all the objects matching the given predicate in the results collection. |
||||
|
||||
@param predicate The predicate with which to filter the objects. |
||||
|
||||
@return An `RLMResults` of objects that match the given predicate. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)objectsWithPredicate:(NSPredicate *)predicate; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from an existing results collection. |
||||
|
||||
@param keyPath The key path to sort by. |
||||
@param ascending The direction to sort in. |
||||
|
||||
@return An `RLMResults` sorted by the specified key path. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)sortedResultsUsingKeyPath:(NSString *)keyPath ascending:(BOOL)ascending; |
||||
|
||||
/**
|
||||
Returns a sorted `RLMResults` from an existing results collection. |
||||
|
||||
@param properties An array of `RLMSortDescriptor`s to sort by. |
||||
|
||||
@return An `RLMResults` sorted by the specified properties. |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)sortedResultsUsingDescriptors:(NSArray<RLMSortDescriptor *> *)properties; |
||||
|
||||
/**
|
||||
Returns a distinct `RLMResults` from an existing results collection. |
||||
|
||||
@param keyPaths The key paths used produce distinct results |
||||
|
||||
@return An `RLMResults` made distinct based on the specified key paths |
||||
*/ |
||||
- (RLMResults<RLMObjectType> *)distinctResultsUsingKeyPaths:(NSArray<NSString *> *)keyPaths; |
||||
|
||||
#pragma mark - Notifications |
||||
|
||||
/**
|
||||
Registers a block to be called each time the results collection changes. |
||||
|
||||
The block will be asynchronously called with the initial results collection, |
||||
and then called again after each write transaction which changes either any |
||||
of the objects in the results, or which objects are in the results. |
||||
|
||||
The `change` parameter will be `nil` the first time the block is called. |
||||
For each call after that, it will contain information about |
||||
which rows in the results collection were added, removed or modified. If a |
||||
write transaction did not modify any objects in the results collection, |
||||
the block is not called at all. See the `RLMCollectionChange` documentation for |
||||
information on how the changes are reported and an example of updating a |
||||
`UITableView`. |
||||
|
||||
If an error occurs the block will be called with `nil` for the results |
||||
parameter and a non-`nil` error. Currently the only errors that can occur are |
||||
when opening the Realm on the background worker thread. |
||||
|
||||
At the time when the block is called, the `RLMResults` object will be fully |
||||
evaluated and up-to-date, and as long as you do not perform a write transaction |
||||
on the same thread or explicitly call `-[RLMRealm refresh]`, accessing it will |
||||
never perform blocking work. |
||||
|
||||
Notifications are delivered via the standard run loop, and so can't be |
||||
delivered while the run loop is blocked by other activity. When |
||||
notifications can't be delivered instantly, multiple notifications may be |
||||
coalesced into a single notification. This can include the notification |
||||
with the initial results. For example, the following code performs a write |
||||
transaction immediately after adding the notification block, so there is no |
||||
opportunity for the initial notification to be delivered first. As a |
||||
result, the initial notification will reflect the state of the Realm after |
||||
the write transaction. |
||||
|
||||
RLMResults<Dog *> *results = [Dog allObjects]; |
||||
NSLog(@"dogs.count: %zu", dogs.count); // => 0
|
||||
self.token = [results addNotificationBlock:^(RLMResults *dogs, |
||||
RLMCollectionChange *changes, |
||||
NSError *error) { |
||||
// Only fired once for the example
|
||||
NSLog(@"dogs.count: %zu", dogs.count); // => 1
|
||||
}]; |
||||
[realm transactionWithBlock:^{ |
||||
Dog *dog = [[Dog alloc] init]; |
||||
dog.name = @"Rex"; |
||||
[realm addObject:dog]; |
||||
}]; |
||||
// end of run loop execution context
|
||||
|
||||
You must retain the returned token for as long as you want updates to continue |
||||
to be sent to the block. To stop receiving updates, call `-invalidate` on the token. |
||||
|
||||
@warning This method cannot be called during a write transaction, or when the |
||||
containing Realm is read-only. |
||||
|
||||
@param block The block to be called whenever a change occurs. |
||||
@return A token which must be held for as long as you want updates to be delivered. |
||||
*/ |
||||
- (RLMNotificationToken *)addNotificationBlock:(void (^)(RLMResults<RLMObjectType> *__nullable results, |
||||
RLMCollectionChange *__nullable change, |
||||
NSError *__nullable error))block __attribute__((warn_unused_result)); |
||||
|
||||
#pragma mark - Aggregating Property Values |
||||
|
||||
/**
|
||||
Returns the minimum (lowest) value of the given property among all the objects |
||||
represented by the results collection. |
||||
|
||||
NSNumber *min = [results minOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose minimum value is desired. Only properties of types `int`, `float`, `double`, and |
||||
`NSDate` are supported. |
||||
|
||||
@return The minimum value of the property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable id)minOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the maximum (highest) value of the given property among all the objects represented by the results collection. |
||||
|
||||
NSNumber *max = [results maxOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose maximum value is desired. Only properties of |
||||
types `int`, `float`, `double`, and `NSDate` are supported. |
||||
|
||||
@return The maximum value of the property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable id)maxOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the sum of the values of a given property over all the objects represented by the results collection. |
||||
|
||||
NSNumber *sum = [results sumOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose values should be summed. Only properties of |
||||
types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The sum of the given property. |
||||
*/ |
||||
- (NSNumber *)sumOfProperty:(NSString *)property; |
||||
|
||||
/**
|
||||
Returns the average value of a given property over the objects represented by the results collection. |
||||
|
||||
NSNumber *average = [results averageOfProperty:@"age"]; |
||||
|
||||
@warning You cannot use this method on `RLMObject`, `RLMArray`, and `NSData` properties. |
||||
|
||||
@param property The property whose average value should be calculated. Only |
||||
properties of types `int`, `float`, and `double` are supported. |
||||
|
||||
@return The average value of the given property, or `nil` if the Results are empty. |
||||
*/ |
||||
- (nullable NSNumber *)averageOfProperty:(NSString *)property; |
||||
|
||||
/// :nodoc:
|
||||
- (RLMObjectType)objectAtIndexedSubscript:(NSUInteger)index; |
||||
|
||||
#pragma mark - Unavailable Methods |
||||
|
||||
/**
|
||||
`-[RLMResults init]` is not available because `RLMResults` cannot be created directly. |
||||
`RLMResults` can be obtained by querying a Realm. |
||||
*/ |
||||
- (instancetype)init __attribute__((unavailable("RLMResults cannot be created directly"))); |
||||
|
||||
/**
|
||||
`+[RLMResults new]` is not available because `RLMResults` cannot be created directly. |
||||
`RLMResults` can be obtained by querying a Realm. |
||||
*/ |
||||
+ (instancetype)new __attribute__((unavailable("RLMResults cannot be created directly"))); |
||||
|
||||
@end |
||||
|
||||
/**
|
||||
`RLMLinkingObjects` is an auto-updating container type. It represents a collection of objects that link to its |
||||
parent object. |
||||
|
||||
For more information, please see the "Inverse Relationships" section in the |
||||
[documentation](https://realm.io/docs/objc/latest/#relationships).
|
||||
*/ |
||||
@interface RLMLinkingObjects<RLMObjectType: RLMObject *> : RLMResults |
||||
@end |
||||
|
||||
NS_ASSUME_NONNULL_END |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue