Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Any object in a dictionary which is created by reading from disk will be properly initialized. You will not have to do it on your own. However, as pointed out by jlehr, <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/Reference/Reference.html#//apple_ref/occ/clm/NSDictionary/dictionaryWithContentsOfFile%3a" rel="nofollow">contents of the dictionary should be immutable</a>. If you want the contents of the dictionary to be mutable, you will need to change them on your own. I have no idea why your program is not throwing an exception.</p> <p>I do not know why you are getting memory errors while not using <code>initWithCapacity:1</code> in other situations. The following code is perfectly valid:</p> <pre><code>NSMutableArray *array = [[NSMutableArray alloc] init]; [array addObject:@"object1"]; [array addObject:@"object2"]; NSLog(@"%@",array); [array release]; </code></pre> <p>If you don't specify a capacity, the array won't pre-allocate any memory, but it will allocate memory as required later.</p> <p><strong>Edit</strong>:</p> <p>It is perfectly acceptable to use NSDictionary with <code>CFPropertyListCreateDeepCopy</code>. In Core Foundation, a CFPropertyList can be a CFDictionary, CFArray, CFNumber, CFString, or CFData. Since NSDictionary is <a href="http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW98" rel="nofollow">toll-free bridged</a> to CFDictionary, you can use it wherever a CFDictionary is asked for by casting, and vice-versa. Your code as is will give a warning, but you can suppress it by casting the dictionary and return values.</p> <pre><code>NSDictionary *testData = (NSDictionary*)CFPropertyListCreateDeepCopy(kCFAllocatorDefault, (CFDictionaryRef)[NSDictionary dictionaryWithContentsOfFile:path], kCFPropertyListMutableContainersAndLeaves); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload