In the .h file
@interface AppMain : NSObject//-ADD THIS DELEGATE{FileDownloader *fileDownloader1; //-ADD THIS
In the .m file
//********** DOWNLOAD FILE **********- (void) SomeMethodName{NSLog(@"STARTING DOWNLOAD");if (!fileDownloader1)fileDownloader1 = [[FileDownloader alloc] init];[fileDownloader1 setDelegate:self];[fileDownloader1 DownloadFile:@"http://www.somedomain.com/somefile.html"];}//********** FILE DOWNLOAD FINISHED CALLBACK **********- (void)FileDownloadFinished:(NSData *)file{NSString *filePath;NSError *error;NSString *path;NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"OurFiles"];//Create a new cache directoryif (![[NSFileManager defaultManager] createDirectoryAtPath:pathwithIntermediateDirectories:NOattributes:nilerror:&error]){NSLog(@"Create directory error: %@", error);}//Save the filefilePath = [path stringByAppendingPathComponent:@"somefile.html"];[[NSFileManager defaultManager] createFileAtPath:filePathcontents:fileattributes:nil];}
No comments:
Post a Comment