I am using a table view and download data using performSelectorInBackground, but I found I can scroll table view when I download, what can I do?
Thanks for your suggestion.
Thanks for your suggestion.
@interface MasterTableViewController : UITableViewController {
MonthData *monthData;
DetailViewController *detailViewController;
}
@interface MonthData : NSObject <NewerFileDownloadDelegate> {
NSArray *allData;
NewerFileDownload *download;
}
- (void)downloadData {
[download start];
}
@interface NewerFileDownload : NSObject {
ASINetworkQueue *networkQueue;
ASIHTTPRequest *request;
id delegate;
}
- (void)start {
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:fileName]];
[networkQueue addOperation:request];
[networkQueue go];
}
- (IBAction)download:(id)sender {
[self performSelectorInBackground:@selector(downloadEvents) withObject:nil];
}
- (void)downloadEvents {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[monthData downloadData];
[pool release];
}
I knew it, I use it in background because I can't scroll my view when downloading.ASIHTTP is already using an operation queue to perform the network request asynchronously; there is no need for you to call this selector on a background thread.