Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Eilon Krauthammer
4,768 PointsRuntime error: 'NSInvalidArgumentException', reason: 'data parameter is nil'
I did everything the same way Amit did yet I get a runtime error.. What's the problem? Thanks
4 Answers

Robert Bojor
Courses Plus Student 29,439 PointsYou are receiving that error because the response that comes from the server is empty and the NSJSONSerialization class cannot work with a nil string.
If you share some of the code you have, especially the part where you call the URL and handle the response, I will be able to help further.

Eilon Krauthammer
4,768 PointsThis is my viewDidLoad method, pretty much identical to what's shown in the video...
-
(void)viewDidLoad { [super viewDidLoad];
NSURL *blogURL = [NSURL URLWithString:@"http://blog.teamtreehouse.com/api/get_recent_summary/"];
NSData *jsonData = [NSData dataWithContentsOfURL:blogURL];
NSError *error = nil;
NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
self.blogPosts = [dataDictionary objectForKey:@"posts"]; }

Eilon Krauthammer
4,768 Points*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil' this is the error I'm receiving

Eilon Krauthammer
4,768 PointsOh I'm sorry I just noticed something was wrong with my URL address thanks anyways :)

Robert Bojor
Courses Plus Student 29,439 PointsNo problem :)

Kuan Chung Chang
5,607 PointsHave the same problem just like you, but there's more information besides NSInvalidArgumentException, here's the description: 2015-10-19 22:24:52.153 BlogReader[1857:94714] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. 2015-10-19 22:24:52.158 BlogReader[1857:94590] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
How can I solve this problem?
Robert Bojor
Courses Plus Student 29,439 PointsRobert Bojor
Courses Plus Student 29,439 PointsCan you copy/paste the error that you are receiving? It'll be easier to pinpoint the problem.