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/RLMObjectSchema.h>
21 #import <objc/runtime.h>
23 NS_ASSUME_NONNULL_BEGIN
25 // RLMObjectSchema private
26 @interface RLMObjectSchema () {
31 /// The object type name reported to the object store and core.
32 @property (nonatomic, readonly) NSString *objectName;
34 // writable redeclaration
35 @property (nonatomic, readwrite, copy) NSArray<RLMProperty *> *properties;
36 @property (nonatomic, readwrite, assign) bool isSwiftClass;
38 // class used for this object schema
39 @property (nonatomic, readwrite, assign) Class objectClass;
40 @property (nonatomic, readwrite, assign) Class accessorClass;
41 @property (nonatomic, readwrite, assign) Class unmanagedClass;
43 @property (nonatomic, readwrite, nullable) RLMProperty *primaryKeyProperty;
45 @property (nonatomic, copy) NSArray<RLMProperty *> *computedProperties;
46 @property (nonatomic, readonly) NSArray<RLMProperty *> *swiftGenericProperties;
48 // returns a cached or new schema for a given object class
49 + (instancetype)schemaForObjectClass:(Class)objectClass;
52 @interface RLMObjectSchema (Dynamic)
54 This method is useful only in specialized circumstances, for example, when accessing objects
55 in a Realm produced externally. If you are simply building an app on Realm, it is not recommended
56 to use this method as an [RLMObjectSchema](RLMObjectSchema) is generated automatically for every [RLMObject](RLMObject) subclass.
58 Initialize an RLMObjectSchema with classname, objectClass, and an array of properties
60 @warning This method is useful only in specialized circumstances.
62 @param objectClassName The name of the class used to refer to objects of this type.
63 @param objectClass The Objective-C class used when creating instances of this type.
64 @param properties An array of RLMProperty instances describing the managed properties for this type.
66 @return An initialized instance of RLMObjectSchema.
68 - (instancetype)initWithClassName:(NSString *)objectClassName objectClass:(Class)objectClass properties:(NSArray *)properties;