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

The Archive Base Latest Questions

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

This code has the JSON but no matter what I do I haven’t been

  • 0

This code has the JSON but no matter what I do I haven’t been able to figure out how to pass this JSON to an instance variable. Each time I set it to a variable and call that variable outside of this method its nil. So what I can gather is that the variable is called before the following async call returns.

So the question is what can I do to the following code so that I can extract the JSON value. Somewhere on the internet I read that I would need to pass it a block which would server as a call back on completion but I cannot figure out how to do that for the following code

 //Gets the JSON object that contains the entries from the server
 -(void)getEntriesFromServer 
 {
   NSLog(@"%s", __PRETTY_FUNCTION__);

   [[appAPIClient sharedClient] getPath:@"/entries"
                          parameters:nil
                             success:^(AFHTTPRequestOperation *operation, id JSON)
    {
      NSLog(@" JSON array = %@",[JSON valueForKeyPath:@"entries"]);
    }failure:^(AFHTTPRequestOperation *operation, NSError *error)
    {
      NSLog(@" Json not received");
    }];
  }

Thanks

  • 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:16:02+00:00Added an answer on June 17, 2026 at 10:16 pm

    try to add __block to definition of an array e.g __block NSArray* entriesArray;
    or make a property like

    @property (nonatomic, retain) NSArray* entriesArray;
    

    and change your code like this

    [[appAPIClient sharedClient] getPath:@"/entries"
                                   parameters:nil
                                      success:^(AFHTTPRequestOperation *operation, id JSON)
       {
    
         //NSLog(@" Json value received is : %@ ",[JSON description]);
         //NSLog(@" JSON array = %@",[JSON valueForKeyPath:@"entries"]);
    
         self.entriesArray = [NSArray arrayWithArray:[JSON valueForKeyPath:@"entries"]];
         NSLog(@" JSON array from inside block = %@", _entriesArray);
         }failure:^(AFHTTPRequestOperation *operation, NSError *error)
        {
            NSLog(@" Json not received");
        }];
    

    Hope it’ll help

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

Sidebar

Related Questions

I was checking out this question which has this code - (NSArray *) percentagesRGBArray:(float[])
I'm getting really tired of trying to figure out why this code works in
This code has an interesting bug: some_struct struct_array1[10] = {0}; some_struct struct_array2[10] = {0}
This code has generated a 1 result for r on the 1st toss 200
I translated this code(it has bad side effect that it just capture the outer
I have this code that has one button that let's me choose an entry
All my controller has this code on the top of class. public class TestController
I'm using a tutorial plugin - http://particlebits.com/code/jquery-tutorial/ which has this code attached to the
In my application I use the ShinyBlue.xaml resource dictionary which has this code for
This code I am looking at has a lot of places where I see

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.