Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON parsing in Cocoa only displaying first 20 entries
    primarykey
    data
    text
    <p><strong>Update 22nd April:</strong></p> <p><em>Problem solved: Turned out that the API required OAUTH to work... which explained why it would load correctly in the browser (I was already signed in) and not in other applications such as the JSON validator or my own App.</em></p> <p>I'm trying to write a class which will fetch and parse a JSON file in Xcode 4.3.2 on Lion. I've only been coding for a few weeks so sorry if this is a bit of a stupid question! The code seems to work fine except for the fact that only the first 20 entries in the JSON file show up (there should be 200). Any idea why this might be?</p> <pre><code> - (void) initJSON { NSString *urlstri = [[NSString alloc] initWithFormat:@"http://api.t.sina.com.cn/statuses/followers.json?source=?????&amp;count=200&amp;screen_name=%@", userName]; NSURL *newURL = [[NSURL alloc] initWithString:urlstri]; NSURLRequest *request = [NSURLRequest requestWithURL:newURL]; [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:NO]; } ];} - (void) fetchedData:(NSData *)responseData { //parse out the json data NSError* error; NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData //1 options:kNilOptions error:&amp;error]; NSArray* newestFollower = [json objectForKey:@"users"]; //2 fnumber = 0; mnumber = 0; int arraySize = [newestFollower count]; NSLog(@"%i",arraySize); for (i=0; i&lt;arraySize; ++i) { NSDictionary* userProfile = [newestFollower objectAtIndex: i]; NSString* userGender = [userProfile objectForKey:@"gender"]; //NSLog(@"%@", userGender); if([userGender isEqualToString:@"m"]){ //NSLog (@"man"); ++mnumber; } if([userGender isEqualToString:@"f"]){ //NSLog(@"notman"); ++fnumber;} } mOutput = [NSNumber numberWithInt:(mnumber)]; fObj = [NSString stringWithFormat:@"%i", fnumber]; mObj = [NSString stringWithFormat:@"%i", mnumber]; NSLog (@"Boys:%@", mObj); NSLog (@"Girls:%@", fObj); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload