This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; | |
[request setHTTPMethod:@"GET"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[NSURLConnection alloc] initWithRequest:request delegate:self]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) connectionDidFinishLoading:(NSURLConnection *)connection { | |
[connection release]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface HttpWithObjectiveCViewController : UIViewController { | |
NSData* responseData; | |
} | |
@property (nonatomic, retain) NSData* responseData; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { | |
[responseData setLength:0]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { | |
[responseData appendData:data]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) connectionDidFinishLoading:(NSURLConnection *)connection { | |
[connection release]; | |
NSString* responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; | |
NSLog(@"the html from google was %@", responseString); | |
[responseString release]; | |
} |
OlderNewer