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 8745143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:57:29+00:00 2026-06-13T11:57:29+00:00

When launching my app it checks if user is subscribed. If it dosent detect

  • 0

When launching my app it checks if user is subscribed. If it dosent detect an internet connection it crashes with the error:

Failed to retrieve subscription with error 'The Internet connection appears to be offline.' and responseString: (null)*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

.m

  [self getPath:path
   parameters:parameters
      success:^(AFHTTPRequestOperation *operation, id responseObject) {
          if (![responseObject isKindOfClass:[NSDictionary class]])
          {
              failureBlock(@"Invalid response received");
              return;
          }
          NSDictionary *responseDict = (NSDictionary *)responseObject;
          if (responseDict[@"error"] == nil)
          {
              [self saveUserDict:responseDict];
              successBlock(responseDict);
          }
          else
          {
              failureBlock(responseDict[@"error"]);
          }
      }
      failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          DebugLog(@"Failed to log in with error '%@' and response: %@", error.localizedDescription, operation.responseString);
          failureBlock(@"An unknown error occurred");
      }];

 }



 - (void)getSubscriptionWithSuccessBlock:(void (^)(NSDictionary *subscriptionDict))successBlock
                       failureBlock:(void (^)(id responseObject))failureBlock
 {
static NSString *path = @"/api/subscription";

NSDictionary *parameters = @{
    @"userId" : userDict[@"userId"],
    @"token" : userDict[@"token"]
};

 DebugLog(@"Getting subscription with parameters: %@", parameters);



     [self getPath:path
     parameters:parameters
      success:^(AFHTTPRequestOperation *operation, id responseObject) {
          if (![responseObject isKindOfClass:[NSDictionary class]])
          {
              failureBlock(@"Invalid response received");
              return;
          }
          NSDictionary *subscriptionDict = (NSDictionary *)responseObject;
          if (subscriptionDict[@"error"] == nil)
          {
              DebugLog(@"Successfully retrieved subscription");
              successBlock(subscriptionDict);
          }
          else
          {
              failureBlock(responseObject);
          }
      }
      failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          DebugLog(@"Failed to retrieve subscription with error '%@' and responseString: %@", error.localizedDescription, operation.responseString);
          id responseObject = [NSJSONSerialization JSONObjectWithData:operation.responseData
                                                              options:0
                                                                error:nil];
          failureBlock(responseObject);
      }];
    }
  • 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-13T11:57:30+00:00Added an answer on June 13, 2026 at 11:57 am

    You need to check for the error before proceeding with the below line. In case there is an error do not call JSONObjectWithData: method with null data.

    [self getPath:path
           parameters:parameters
              success:^(AFHTTPRequestOperation *operation, id responseObject) {
                  if (![responseObject isKindOfClass:[NSDictionary class]])
                  {
                      failureBlock(@"Invalid response received");
                      return;
                  }
                  NSDictionary *responseDict = (NSDictionary *)responseObject;
                  if (responseDict[@"error"] == nil)
                  {
                      [self saveUserDict:responseDict];
                      successBlock(responseDict);
                  }
                  else
                  {
                      failureBlock(responseDict[@"error"]);
                  }
              }
              failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                  if (!error) {
                      DebugLog(@"Failed to retrieve subscription with error '%@' and responseString: %@", error.localizedDescription, operation.responseString);
                      id responseObject = [NSJSONSerialization JSONObjectWithData:operation.responseData
                                                                          options:0
                                                                            error:nil];
                      failureBlock(responseObject);
                  } else {
                      //handle the error scenario
                      failureBlock(@"error occured");
                  }
              }];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Upon launching a sinatra app, I get the following error message: /home/matt/.rvm/gems/ruby-1.9.3-p125/gems/backports-2.5.1/lib/backports/tools.rb:310:in `require': cannot
I am launching my app in the instruments to detect leaked objects and debug
I am developing an app that requires an internet connection, so I want to
after launching your app on google app engine. you can use the 'logs' page
I have an app launching an executable which is in the same folder as
I have an HTML file which is launching an app if I open it
My android app was launching fine to both my HTC phone and my Android
We're launching an iPhone app soon, and if everything goes well, we might reach
My team will soon be launching a web app in Beta. At what point
From my app I am launching the calendar with an intent: Calendar cal =

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.