1 ////////////////////////////////////////////////////////////////////////////
3 // Copyright 2014 Realm Inc.
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 ////////////////////////////////////////////////////////////////////////////
19 #import <Foundation/Foundation.h>
21 NS_ASSUME_NONNULL_BEGIN
23 // For compatibility with Xcode 7, before extensible string enums were introduced,
24 #ifdef NS_EXTENSIBLE_STRING_ENUM
25 #define RLM_EXTENSIBLE_STRING_ENUM NS_EXTENSIBLE_STRING_ENUM
26 #define RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(_, extensible_string_enum) NS_SWIFT_NAME(extensible_string_enum)
28 #define RLM_EXTENSIBLE_STRING_ENUM
29 #define RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(fully_qualified, _) NS_SWIFT_NAME(fully_qualified)
32 #if __has_attribute(ns_error_domain) && (!defined(__cplusplus) || !__cplusplus || __cplusplus >= 201103L)
33 #define RLM_ERROR_ENUM(type, name, domain) \
34 _Pragma("clang diagnostic push") \
35 _Pragma("clang diagnostic ignored \"-Wignored-attributes\"") \
36 NS_ENUM(type, __attribute__((ns_error_domain(domain))) name) \
37 _Pragma("clang diagnostic pop")
39 #define RLM_ERROR_ENUM(type, name, domain) NS_ENUM(type, name)
46 `RLMPropertyType` is an enumeration describing all property types supported in Realm models.
48 For more information, see [Realm Models](https://realm.io/docs/objc/latest/#models).
50 typedef NS_ENUM(int32_t, RLMPropertyType) {
52 #pragma mark - Primitive types
54 /** Integers: `NSInteger`, `int`, `long`, `Int` (Swift) */
55 RLMPropertyTypeInt = 0,
56 /** Booleans: `BOOL`, `bool`, `Bool` (Swift) */
57 RLMPropertyTypeBool = 1,
58 /** Floating-point numbers: `float`, `Float` (Swift) */
59 RLMPropertyTypeFloat = 5,
60 /** Double-precision floating-point numbers: `double`, `Double` (Swift) */
61 RLMPropertyTypeDouble = 6,
63 #pragma mark - Object types
65 /** Strings: `NSString`, `String` (Swift) */
66 RLMPropertyTypeString = 2,
67 /** Binary data: `NSData` */
68 RLMPropertyTypeData = 3,
72 This property type is no longer supported for new models. However, old files
73 with any-typed properties are still supported for migration purposes.
75 RLMPropertyTypeAny = 9,
76 /** Dates: `NSDate` */
77 RLMPropertyTypeDate = 4,
79 #pragma mark - Linked object types
81 /** Realm model objects. See [Realm Models](https://realm.io/docs/objc/latest/#models) for more information. */
82 RLMPropertyTypeObject = 7,
83 /** Realm linking objects. See [Realm Models](https://realm.io/docs/objc/latest/#models) for more information. */
84 RLMPropertyTypeLinkingObjects = 8,
87 /** An error domain identifying Realm-specific errors. */
88 extern NSString * const RLMErrorDomain;
90 /** An error domain identifying non-specific system errors. */
91 extern NSString * const RLMUnknownSystemErrorDomain;
94 `RLMError` is an enumeration representing all recoverable errors. It is associated with the
95 Realm error domain specified in `RLMErrorDomain`.
97 typedef RLM_ERROR_ENUM(NSInteger, RLMError, RLMErrorDomain) {
98 /** Denotes a general error that occurred when trying to open a Realm. */
101 /** Denotes a file I/O error that occurred when trying to open a Realm. */
102 RLMErrorFileAccess = 2,
105 Denotes a file permission error that ocurred when trying to open a Realm.
107 This error can occur if the user does not have permission to open or create
108 the specified file in the specified access mode when opening a Realm.
110 RLMErrorFilePermissionDenied = 3,
112 /** Denotes an error where a file was to be written to disk, but another file with the same name already exists. */
113 RLMErrorFileExists = 4,
116 Denotes an error that occurs if a file could not be found.
118 This error may occur if a Realm file could not be found on disk when trying to open a
119 Realm as read-only, or if the directory part of the specified path was not found when
120 trying to write a copy.
122 RLMErrorFileNotFound = 5,
125 Denotes an error that occurs if a file format upgrade is required to open the file,
126 but upgrades were explicitly disabled.
128 RLMErrorFileFormatUpgradeRequired = 6,
131 Denotes an error that occurs if the database file is currently open in another
132 process which cannot share with the current process due to an
133 architecture mismatch.
135 This error may occur if trying to share a Realm file between an i386 (32-bit) iOS
136 Simulator and the Realm Browser application. In this case, please use the 64-bit
137 version of the iOS Simulator.
139 RLMErrorIncompatibleLockFile = 8,
141 /** Denotes an error that occurs when there is insufficient available address space. */
142 RLMErrorAddressSpaceExhausted = 9,
144 /** Denotes an error that occurs if there is a schema version mismatch, so that a migration is required. */
145 RLMErrorSchemaMismatch = 10,
147 /** Denotes an error that occurs when attempting to open an incompatible synchronized Realm file.
149 This error occurs when the Realm file was created with an older version of Realm and an automatic migration
150 to the current version is not possible. When such an error occurs, the original file is moved to a backup
151 location, and future attempts to open the synchronized Realm will result in a new file being created.
152 If you wish to migrate any data from the backup Realm, you can open it using the provided Realm configuration.
154 RLMErrorIncompatibleSyncedFile = 11,
157 #pragma mark - Constants
159 #pragma mark - Notification Constants
162 A notification indicating that changes were made to a Realm.
164 typedef NSString * RLMNotification RLM_EXTENSIBLE_STRING_ENUM;
167 This notification is posted by a Realm when the data in that Realm has changed.
169 More specifically, this notification is posted after a Realm has been refreshed to
170 reflect a write transaction. This can happen when an autorefresh occurs, when
171 `-[RLMRealm refresh]` is called, after an implicit refresh from `-[RLMRealm beginWriteTransaction]`,
172 or after a local write transaction is completed.
174 extern RLMNotification const RLMRealmRefreshRequiredNotification
175 RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(RLMRealmRefreshRequiredNotification, RefreshRequired);
178 This notification is posted by a Realm when a write transaction has been
179 committed to a Realm on a different thread for the same file.
181 It is not posted if `-[RLMRealm autorefresh]` is enabled, or if the Realm is
182 refreshed before the notification has a chance to run.
184 Realms with autorefresh disabled should normally install a handler for this
185 notification which calls `-[RLMRealm refresh]` after doing some work. Refreshing
186 the Realm is optional, but not refreshing the Realm may lead to large Realm
187 files. This is because Realm must keep an extra copy of the data for the stale
190 extern RLMNotification const RLMRealmDidChangeNotification
191 RLM_EXTENSIBLE_STRING_ENUM_CASE_SWIFT_NAME(RLMRealmDidChangeNotification, DidChange);
193 #pragma mark - Error keys
195 /** Key to identify the associated backup Realm configuration in an error's `userInfo` dictionary */
196 extern NSString * const RLMBackupRealmConfigurationErrorKey;
198 #pragma mark - Other Constants
200 /** The schema version used for uninitialized Realms */
201 extern const uint64_t RLMNotVersioned;
203 /** The corresponding value is the name of an exception thrown by Realm. */
204 extern NSString * const RLMExceptionName;
206 /** The corresponding value is a Realm file version. */
207 extern NSString * const RLMRealmVersionKey;
209 /** The corresponding key is the version of the underlying database engine. */
210 extern NSString * const RLMRealmCoreVersionKey;
212 /** The corresponding key is the Realm invalidated property name. */
213 extern NSString * const RLMInvalidatedKey;
215 NS_ASSUME_NONNULL_END