That's not the error message, because that's not an error that NSJSONSerialization
can return. Most likely the error message was something like The data couldn’t be read because it isn’t in the correct format
or JSON text did not start with array or object and option to allow fragments not set.
It's important to include the exact error message when asking a question if you want people to know what you're talking about.
Assuming that the error matches what I think it matches, the answer is simple: Your documentData
object does not contain valid JSON. As a result NSJSONSerialization
can't convert it to a dictionary. The first argument to that method must contain valid JSON data encoded into an NSData
object.
It's impossible to be certain why this is, since you didn't describe the data you're working with. However since you're using a file name of SessionInfo.plist
, you're probably working with a property list. Property lists are not JSON. Valid property list file formats include XML, binary (undocumented format), and ASCII (obsolete but still readable). None of those are JSON, and none will work with NSJSONSerialization
.