Created
October 7, 2011 18:40
-
-
Save jeksys/1271047 to your computer and use it in GitHub Desktop.
Download URL
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 LoaderURL : NSObject | |
{ | |
NSMutableData *responseData; | |
NSURLConnection *connectionXML; | |
} | |
@property (nonatomic, copy) NSString *xmlFileName; | |
- (BOOL) updateFile; | |
@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
@implementation w2gLoader | |
@synthesize LoaderURL; | |
- (id)init | |
{ | |
self = [super init]; | |
if (self) { | |
} | |
self.xmlFileName = @"http://www.com/file.html"; | |
return self; | |
} | |
- (BOOL) updateFile | |
{ | |
responseData = [[NSMutableData data] retain]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.xmlFileName]]; | |
connectionXML = [[NSURLConnection alloc] initWithRequest:request delegate:self]; | |
return YES; | |
} | |
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { | |
[responseData setLength:0]; | |
} | |
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { | |
[responseData appendData:data]; | |
NSLog(@"didReceiveData: %d kB", [responseData length]/1024); | |
} | |
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { | |
[connection release]; | |
} | |
- (void)connectionDidFinishLoading:(NSURLConnection *)connection | |
{ | |
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; | |
[responseData release]; | |
NSLog(@"%d", [responseString length]); | |
[responseString release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment