More Related Content
Similar to Meetup uikit programming
Similar to Meetup uikit programming (20)
Meetup uikit programming
- 8. ASIHTTPRequest (2) - (IBAction)grabURL:(id)sender { NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request startSynchronous]; NSError *error = [request error]; if (!error) { NSString *response = [request responseString]; } }
- 9. ASIHTTPRequest (3) - (IBAction)grabURLInBackground:(id)sender { NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request startAsynchronous]; } - (void)requestFinished:(ASIHTTPRequest *)request { // Use when fetching text data NSString *responseString = [request responseString]; // Use when fetching binary data NSData *responseData = [request responseData]; } - (void)requestFailed:(ASIHTTPRequest *)request { NSError *error = [request error]; }
- 12. JSON parsing example NSArray *list; NSString *jsonString = @"[amp;quot;Meetupamp;quot;, amp;quot;isamp;quot;, amp;quot;coolamp;quot;]"; list = [jsonString JSONValue]; NSLog(@"first entry: %@", [list objectAtIndex:0]); NSLog(@"second entry: %@", [list objectAtIndex:1]); NSLog(@"third entry: %@", [list objectAtIndex:2]); [json release];