-
Notifications
You must be signed in to change notification settings - Fork 8
/
NSDictionary+NSArray+PlistMutableCopy.m
50 lines (46 loc) · 1.9 KB
/
NSDictionary+NSArray+PlistMutableCopy.m
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
#import "NSDictionary+NSArray+PlistMutableCopy.h"
#import <CoreFoundation/CFPropertyList.h>
/*!
* Simple shortcut for deep mutable copying an NSDictionary.
*
* @see <a href="http://developer.apple.com/documentation/CoreFoundation/Reference/CFPropertyListRef/Reference/chapter_2.1_section_2.html" class="classLink">
* CFPropertyListCreateDeepCopy()</a>
*/
@implementation NSDictionary (ComBelkadanUtils_PlistMutableCopying)
/*!
* Creates a deep mutable copy of this dictionary with a <code>retainCount</code> of 1.
* Returns <code>nil</code> if an error occured, such as this method being called on
* a dictionary containing non-property-list objects (i.e., anything besides NSArray,
* NSData, NSDate, NSDictionary, NSNumber, and NSString).
*
* @functiongroup Copying
*/
- (id)mutableDeepPropertyListCopy
{
CFPropertyListRef plist = CFPropertyListCreateDeepCopy(NULL, (CFPropertyListRef) self, kCFPropertyListMutableContainersAndLeaves);
if (plist) return (id)CFMakeCollectable(plist);
else return nil;
}
@end
/*!
* Simple shortcut for deep mutable copying an NSArray.
*
* @see <a href="http://developer.apple.com/documentation/CoreFoundation/Reference/CFPropertyListRef/Reference/chapter_2.1_section_2.html" class="classLink">
* CFPropertyListCreateDeepCopy()</a>
*/
@implementation NSArray (ComBelkadanUtils_PlistMutableCopying)
/*!
* Creates a deep mutable copy of this array with a <code>retainCount</code> of 1.
* Returns <code>nil</code> if an error occured, such as this method being called on
* an array containing non-property-list objects (i.e., anything besides NSArray, NSData,
* NSDate, NSDictionary, NSNumber, and NSString).
*
* @functiongroup Copying
*/
- (id)mutableDeepPropertyListCopy
{
CFPropertyListRef plist = CFPropertyListCreateDeepCopy(NULL, (CFPropertyListRef) self, kCFPropertyListMutableContainersAndLeaves);
if (plist) return (id)CFMakeCollectable(plist);
else return nil;
}
@end