Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:31:36+00:00 2026-06-17T22:31:36+00:00

Follow this tutorial: http://www.raywenderlich.com/5492/working-with-json-in-ios-5 , I make simple App like that: #define kLatestKivaLoansURL [NSURL

  • 0

Follow this tutorial: http://www.raywenderlich.com/5492/working-with-json-in-ios-5 , I make simple App like that:

#define kLatestKivaLoansURL [NSURL URLWithString: @"http://api.kivaws.org/v1/loans/search.json?status=fundraising"] 

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        NSData* data = [NSData dataWithContentsOfURL: kLatestKivaLoansURL];
        NSError* error;
        NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data 
                                                             options:kNilOptions
                                                               error:&error];
        NSArray* latestLoans = [json objectForKey:@"loans"];
        NSLog(@"Error: %@",error);
        NSLog(@"loans: %@",latestLoans); 

        dispatch_async(dispatch_get_main_queue(), ^(){
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
            self.window.rootViewController = self.viewController;
            [self.window makeKeyAndVisible];
        });

    });

    return YES;
}

@end

When Network not OK or JSON link Error, I get same break: “* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘data parameter is nil”

How to catch this Error? I just want to display an Alert message, not break.

How many kind of Errors when parse JSON data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:31:38+00:00Added an answer on June 17, 2026 at 10:31 pm

    You should implement a check on NSData* data whether it is nil or not? If its nil then you should not run the code line

    NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data 
                                                                 options:kNilOptions
                                                                   error:&error];
    

    as you are trying to convert nil data into Dictionary.

    You can also check network availability by implementing Reachability classes in you code. A sample application demonstrates how to use the SystemConfiguration framework to monitor the network state of an iPhone or iPod touch

    http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today I tried to follow the basic Twitter tutorial on : --> http://www.noupe.com/ajax/create-a-simple-twitter-app.html But
I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
I am following this tutorial to set up a push notifications >> http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 Yet
trying to follow this tutorial http://www.codeguru.com/csharp/csharp/net30/article.php/c15489 I'm not able to select the sql server
i am making a sample program in hibernate follow this tutorial: http://www.myeclipseide.com/documentation/quickstarts/hibernateintroduction/ using reverse
I'm trying to follow this tutorial - http://www.dotnetcurry.com/ShowArticle.aspx?ID=231&AspxAutoDetectCookieSupport=1 I have both the vsdoc file
I follow this tutorial to learn some REST services and AJAX calls: http://www.mkyong.com/webservices/jax-rs/integrate-jackson-with-resteasy/ I
I am going through this tutorial http://www.9lessons.info/2009/04/exactly-twitter-like-follow-and-remove.html on how to implement a twitter-like follow/unfollow
I'm trying to follow this tutorial for an Accordion control in WPF: http://www.c-sharpcorner.com/UploadFile/dpatra/538/ I
I follow this tutorial to create a svn http://www.guyrutenberg.com/2007/10/29/creating-local-svn-repository-home-repository/ However after running $ svn

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.