Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Deck of Cards
idhowManyTeamsCode
Card
labelObjectiveC
Code Block
borderColorGreen
langjava
titleJSON
CommunicationSingleton *CSS = [CommunicationSingleton sharedSingleton];
    
    //build an info object and convert to json
    NSError *requestError;
    NSHTTPURLResponse *responseHTTP;
    
    NSMutableURLRequest *requestForSlug = [[NSMutableURLRequest alloc] init];
    
    NSString *teamRequestString = [NSString stringWithFormat:@"%@teams",[CSS getDefaultAPIURL]];
    [requestForSlug setURL:[NSURL URLWithString:teamRequestString]];
    [requestForSlug setHTTPMethod:@"GET"];
    [requestForSlug setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [requestForSlug setValue:[CSS getAuthorization] forHTTPHeaderField:@"Authorization"];
    
    NSData *responseForSlug = [NSURLConnection sendSynchronousRequest:requestForSlug returningResponse:&responseHTTP error:&requestError];
    [requestForSlug release];
    
    if ([responseHTTP statusCode] == 200) {
        // Success. Team names array.
        NSArray *tempdictForSlug = [NSJSONSerialization JSONObjectWithData:responseForSlug options:NSJSONReadingMutableContainers error:&requestError];
        NSLog(@"How many teams I am part of: %d", [tempdictForSlug count]);
    }else{
        // Login Failed.
    }
Card
labelC#