Reputation: 1529
I'm getting below error when i try to encode the data. If i print directly without encoding its printing properly
fatal error: unexpectedly found nil while unwrapping an Optional value
// get the NSURLRequestSession and get the data
let task = NSURLSession.sharedSession().dataTaskWithRequest(nsurlReq){
(data,response,error) in
// check whether there is no error
if(error==nil)
{
// println("Data \(data) ");
var encodedData = NSString(data: data, encoding: NSUTF8StringEncoding)!;
println(encodedData);
}
} //
// you need to resume the task
task.resume();
Upvotes: 0
Views: 241
Reputation: 2926
I would expect that your data has invalid encoding and that is why you're not able to print out the parsed data.
Upvotes: 1