added iOS source code
[wl-app.git] / iOS / Pods / Realm / include / RLMRealm_Dynamic.h
1 ////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright 2014 Realm Inc.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 ////////////////////////////////////////////////////////////////////////////
18
19 #import <Realm/RLMRealm.h>
20
21 #import <Realm/RLMObjectSchema.h>
22 #import <Realm/RLMProperty.h>
23
24 @class RLMResults<RLMObjectType>;
25
26 NS_ASSUME_NONNULL_BEGIN
27
28 @interface RLMRealm (Dynamic)
29
30 #pragma mark - Getting Objects from a Realm
31
32 /**
33  Returns all objects of a given type from the Realm.
34
35  @warning This method is useful only in specialized circumstances, for example, when building components
36           that integrate with Realm. The preferred way to get objects of a single class is to use the class
37           methods on `RLMObject`.
38
39  @param className   The name of the `RLMObject` subclass to retrieve on (e.g. `MyClass.className`).
40
41  @return    An `RLMResults` containing all objects in the Realm of the given type.
42
43  @see       `+[RLMObject allObjects]`
44  */
45 - (RLMResults<RLMObject *> *)allObjects:(NSString *)className;
46
47 /**
48  Returns all objects matching the given predicate from the Realm.
49
50  @warning This method is useful only in specialized circumstances, for example, when building components
51           that integrate with Realm. The preferred way to get objects of a single class is to use the class
52           methods on `RLMObject`.
53
54  @param className       The type of objects you are looking for (name of the class).
55  @param predicateFormat A predicate format string, optionally followed by a variable number of arguments.
56
57  @return    An `RLMResults` containing results matching the given predicate.
58
59  @see       `+[RLMObject objectsWhere:]`
60  */
61 - (RLMResults<RLMObject *> *)objects:(NSString *)className where:(NSString *)predicateFormat, ...;
62
63 /**
64  Returns all objects matching the given predicate from the Realm.
65
66  @warning This method is useful only in specialized circumstances, for example, when building components
67           that integrate with Realm. The preferred way to get objects of a single class is to use the class
68           methods on `RLMObject`.
69
70  @param className   The type of objects you are looking for (name of the class).
71  @param predicate   The predicate with which to filter the objects.
72
73  @return    An `RLMResults` containing results matching the given predicate.
74
75  @see       `+[RLMObject objectsWhere:]`
76  */
77 - (RLMResults<RLMObject *> *)objects:(NSString *)className withPredicate:(NSPredicate *)predicate;
78
79 /**
80  Returns the object of the given type with the given primary key from the Realm.
81
82  @warning This method is useful only in specialized circumstances, for example, when building components
83           that integrate with Realm. The preferred way to get an object of a single class is to use the class
84           methods on `RLMObject`.
85
86  @param className   The class name for the object you are looking for.
87  @param primaryKey  The primary key value for the object you are looking for.
88
89  @return    An object, or `nil` if an object with the given primary key does not exist.
90
91  @see       `+[RLMObject objectForPrimaryKey:]`
92  */
93 - (nullable RLMObject *)objectWithClassName:(NSString *)className forPrimaryKey:(id)primaryKey;
94
95 /**
96  Creates an `RLMObject` instance of type `className` in the Realm, and populates it using a given object.
97
98  The `value` argument is used to populate the object. It can be a key-value coding compliant object, an array or
99  dictionary returned from the methods in `NSJSONSerialization`, or an array containing one element for each managed
100  property. An exception will be thrown if any required properties are not present and those properties were not defined
101  with default values.
102
103  When passing in an array as the `value` argument, all properties must be present, valid and in the same order as the
104  properties defined in the model.
105
106  @warning This method is useful only in specialized circumstances, for example, when building components
107           that integrate with Realm. If you are simply building an app on Realm, it is recommended to
108           use `[RLMObject createInDefaultRealmWithValue:]`.
109
110  @param value    The value used to populate the object.
111
112  @return    An `RLMObject` instance of type `className`.
113  */
114 -(RLMObject *)createObject:(NSString *)className withValue:(id)value;
115
116 @end
117
118 NS_ASSUME_NONNULL_END