Note that there are some explanatory texts on larger screens.

plurals
  1. POreading a file using NSFileManager causing an error
    text
    copied!<p>I am getting the following error:</p> <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil' *** First throw call stack: </code></pre> <p>The code that's causing the error is:</p> <pre><code>NSDictionary *dict = nil; @synchronized(self) { dict = [pendingDictionarySaves objectForKey:file]; } if (dict) return dict; @synchronized(self) { dict = [savedDictionaries objectForKey:file]; } if (dict) return dict; NSData *plistData = [[NSFileManager defaultManager] contentsAtPath:file]; NSError *error = nil; if ([[NSPropertyListSerialization class] respondsToSelector:@selector(propertyListWithData:options:format:error:)]) { return [NSPropertyListSerialization propertyListWithData:plistData options:NSPropertyListImmutable format:NULL error:&amp;error]; } </code></pre> <p>Basically the reason is because the plistData is null. The filepath is:</p> <pre><code>/Users/aditya15417/Library/Application Support/iPhone Simulator/5.1/Applications/A355D003-668C-4B81-80DC-66C968FE57D3/Library/Caches/NewsfeedCache/?type=news </code></pre> <p>Here's how I initialize the path:</p> <pre><code> NSString *path = [basePath stringByAppendingPathComponent:[streamURL uniqueFileName]]; // Create the directories if needed if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:nil]; } return path; </code></pre> <p>The question is how is it possible to get it to work without having to check if pListData is null?</p>
 

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