forked from RestKit/RestKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRKObjectUtilities.h
More file actions
105 lines (82 loc) · 4.33 KB
/
Copy pathRKObjectUtilities.h
File metadata and controls
105 lines (82 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// RKObjectUtilities.h
// RestKit
//
// Created by Blake Watters on 9/30/12.
// Copyright (c) 2012 RestKit. All rights reserved.
//
// 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>
///----------------
/// @name Functions
///----------------
/**
Returns a Boolean value that indicates whether the given objects are equal.
The actual method of comparison is dependendent upon the class of the objects given. For example, given two `NSString` objects equality would be tested using `isEqualToString:`.
@param object The first object to compare.
@param anotherObject The second object to compare.
@return `YES` if the objects are equal, otherwise `NO`.
*/
BOOL RKObjectIsEqualToObject(id object, id anotherObject);
/**
Returns a Boolean value that indicates if the given class is a collection.
The following classes are considered collections:
1. `NSSet`
1. `NSArray`
1. `NSOrderedSet`
`NSDictionary` objects are **not** considered collections as they are typically object representations.
@param aClass The class to check.
@return `YES` if the given class is a collection.
*/
BOOL RKClassIsCollection(Class aClass);
/**
Returns a Boolean value that indicates if the given object is a collection.
Implemented by invoking `RKClassIsCollection` with the class of the given object.
@param object The object to be tested.
@return `YES` if the given object is a collection, else `NO`.
@see `RKClassIsCollection`
*/
BOOL RKObjectIsCollection(id object);
/**
Returns a Boolean value that indicates if the given object is collection containing only instances of `NSManagedObject` or a class that inherits from `NSManagedObject`.
@param object The object to be tested.
@return `YES` if the object is a collection containing only `NSManagedObject` derived objects.
*/
BOOL RKObjectIsCollectionContainingOnlyManagedObjects(id object);
/**
Returns a Boolean value that indicates if the given object is a collection containing subcollections.
@param object The object to be tested.
@return `YES` if the object is a collection of collections, else `NO`.
*/
BOOL RKObjectIsCollectionOfCollections(id object);
/**
Returns an appropriate class to use for KVC access based on the Objective C runtime type encoding.
Objective C Runtime type encodings: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
KVC Scalar/Structure support: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/KeyValueCoding/Articles/DataTypes.html#//apple_ref/doc/uid/20002171-BAJEAIEE
@param type An Objective C Runtime type encoding
@return The class name for the property type encoded in the given attribute string, an appropriate class for wrapping/unwrapping the primitive type, or `Nil` when no transformation is required or possible.
*/
Class RKKeyValueCodingClassForObjCType(const char *type);
/**
Returns an appropriate class to use for KVC access based on the output obtained via the `property_getAttributes` reflection API.
@param attributeString A c string containing encoding attribute information.
@return The class name for the property type encoded in the given attribute string, an appropriate class for wrapping/unwrapping the primitive type, or `Nil` when no transformation is required or possible.
*/
Class RKKeyValueCodingClassFromPropertyAttributes(const char *attr);
/**
Returns the name of a property when provided the name of a property obtained via the `property_getAttributes` reflection API.
@param attributeString A string object encoding attribute information.
@return The class name for the property type encoded in the given attribute string or `@"NULL"` if the property does not have an object type (the declared property is for a primitive type).
*/
NSString *RKPropertyTypeFromAttributeString(NSString *attributeString);