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 <Realm/RLMObject.h>
21 @class RLMObjectSchema, RLMRealm;
23 NS_ASSUME_NONNULL_BEGIN
26 Returns the Realm that manages the object, if one exists.
28 @warning This function is useful only in specialized circumstances, for example, when building components
29 that integrate with Realm. If you are simply building an app on Realm, it is
30 recommended to retrieve the Realm that manages the object via `RLMObject`.
32 @param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`.
34 @return The Realm which manages this object. Returns `nil `for unmanaged objects.
36 FOUNDATION_EXTERN RLMRealm * _Nullable RLMObjectBaseRealm(RLMObjectBase * _Nullable object);
39 Returns an `RLMObjectSchema` which describes the managed properties of the object.
41 @warning This function is useful only in specialized circumstances, for example, when building components
42 that integrate with Realm. If you are simply building an app on Realm, it is
43 recommended to retrieve `objectSchema` via `RLMObject`.
45 @param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`.
47 @return The object schema which lists the managed properties for the object.
49 FOUNDATION_EXTERN RLMObjectSchema * _Nullable RLMObjectBaseObjectSchema(RLMObjectBase * _Nullable object);
52 Returns the object corresponding to a key value.
54 @warning This function is useful only in specialized circumstances, for example, when building components
55 that integrate with Realm. If you are simply building an app on Realm, it is
56 recommended to retrieve key values via `RLMObject`.
58 @warning Will throw an `NSUndefinedKeyException` if `key` is not present on the object.
60 @param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`.
61 @param key The name of the property.
63 @return The object for the property requested.
65 FOUNDATION_EXTERN id _Nullable RLMObjectBaseObjectForKeyedSubscript(RLMObjectBase * _Nullable object, NSString *key);
68 Sets a value for a key on the object.
70 @warning This function is useful only in specialized circumstances, for example, when building components
71 that integrate with Realm. If you are simply building an app on Realm, it is
72 recommended to set key values via `RLMObject`.
74 @warning Will throw an `NSUndefinedKeyException` if `key` is not present on the object.
76 @param object An `RLMObjectBase` obtained via a Swift `Object` or `RLMObject`.
77 @param key The name of the property.
78 @param obj The object to set as the value of the key.
80 FOUNDATION_EXTERN void RLMObjectBaseSetObjectForKeyedSubscript(RLMObjectBase * _Nullable object, NSString *key, id _Nullable obj);