Note that there are some explanatory texts on larger screens.

plurals
  1. POReading NSMutableArray from File
    text
    copied!<p>I am trying to read an 2 NSMutableArrays from file. I am saving and loading as such:</p> <p>SAVE:</p> <pre><code>NSMutableDictionary *saveDict = [NSMutableDictionary dictionary]; [saveDict setValue:name forKey:@"name"]; [saveDict setValue:last_episodue forKey:@"whereat"]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingString:@"/ShopFile.sav"]; [saveDict writeToFile:filePath atomically:YES]; </code></pre> <p>LOAD: </p> <pre><code> name = [[NSMutableArray alloc]init]; last_episodue = [[NSMutableArray alloc]init]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingString:@"/ShopFile.sav"]; NSDictionary *loadDict = [NSDictionary dictionaryWithContentsOfFile:filePath]; name = [loadDict valueForKey:@"name"]; last_episodue= [loadDict valueForKey:@"whereat"]; </code></pre> <p>The variables name and last_episodue have been declared in the header file. </p> <p>The program compiles and runs, however at runtime when trying to load the file, the LOAD part of the code executes, and when it finishes, the program stops working. This is the debugging information (first part):</p> <pre><code>2012-10-13 12:14:10.801 series[5223:303] -[NSISRestrictedToZeroMarkerVariable copyWithZone:]: unrecognized selector sent to instance 0x1001900c0 2012-10-13 12:14:10.803 series[5223:303] -[NSISRestrictedToZeroMarkerVariable copyWithZone:]: unrecognized selector sent to instance 0x1001900c0 2012-10-13 12:14:10.906 series[5223:303] ( </code></pre> <p>Any idea what the problem might be? Thanks!</p> <p>Edit: This is the content of the file where the saving takes place:</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;name&lt;/key&gt; &lt;array&gt; &lt;string&gt;a&lt;/string&gt; &lt;/array&gt; &lt;key&gt;whereat&lt;/key&gt; &lt;array&gt; &lt;string&gt;a&lt;/string&gt; &lt;/array&gt; &lt;/dict&gt; &lt;/plist&gt; </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