Guest User

Untitled

a guest
Jul 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Following is kicked off with this call:
  2.  
  3. [self stringWithUrl:[NSURL URLWithString:@"<URL HERE>"]];
  4.  
  5.  
  6.  
  7. - (void)stringWithUrl:(NSURL *)url
  8. {
  9. NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url
  10. cachePolicy:NSURLRequestReturnCacheDataElseLoad
  11. timeoutInterval:30];
  12.  
  13. [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
  14.  
  15. }
  16.  
  17. -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
  18. NSLog(@"did receive response");
  19. responseData = [[NSMutableData alloc] init];
  20. //jsonString = [[NSString alloc] init];
  21. }
  22.  
  23. -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
  24. NSLog(@"did receive data");
  25. //[jsonString appendData:data];
  26. [responseData appendData:data];
  27. }
  28.  
  29. -(void)connectionDidFinishLoading:(NSURLConnection *)connection {
  30. NSLog(@"Succeeded data! Received %d bytes of data",[responseData length]);
  31. jsonString = [[[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding] autorelease];
  32. SBJSON *jsonParser = [SBJSON new];
  33. //feed = [(NSDictionary *)feed initWithData:[jsonParser objectWithString:jsonString error:NULL]];
  34. id response = [jsonParser objectWithString:jsonString error:NULL];
  35. feed = (NSDictionary *)response;
  36. //[tableView reloadData];
  37. }
Add Comment
Please, Sign In to add comment