Skip to content

Instantly share code, notes, and snippets.

Toran Billups toranb

Block or report user

Report or block toranb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View HttpWithObjectiveCViewController.m
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
View HttpWithObjectiveCViewController.m
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[request setHTTPMethod:@"GET"];
View HttpWithObjectiveCViewController.m
[[NSURLConnection alloc] initWithRequest:request delegate:self];
View HttpWithObjectiveCViewController.m
- (void) viewDidLoad
{
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[request setHTTPMethod:@"GET"];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
View HttpWithObjectiveCViewController.m
- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
}
View HttpWithObjectiveCViewController.m
@interface HttpWithObjectiveCViewController : UIViewController {
NSData* responseData;
}
@property (nonatomic, retain) NSData* responseData;
@end
View HttpWithObjectiveCViewController.m
- (void) viewDidLoad
{
responseData = [NSMutableData new];
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[request setHTTPMethod:@"GET"];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
View HttpWithObjectiveCViewController.m
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[responseData setLength:0];
}
View HttpWithObjectiveCViewController.m
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}
View HttpWithObjectiveCViewController.m
- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString* responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"the html from google was %@", responseString);
[responseString release];
}
You can’t perform that action at this time.