To use UIProgressView and update, I will use two methods. One is performSelectorInBackground, another is performSelectorOnMainThread.
At the place you write codes down to get or put something to server(using NSURLConnection or socket program), use performSelectorInBackground.
For example,
CurlFunction *testCurl = [[CurlFunction alloc] initWithPath:@"Elm2"];
testCurl.listDelegate = self;
[test performSelectorInBackground:@selector(startDownloadZipFile) withObject:nil];
Afterward you make codes that NSAutoreleasePool in startDownloadZipFile.
- (void)startDownloadZipFile {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// write code will execute
[pool release];
}
Next, you should use performSelectorOnMainThread where you will update progress of UIProgressView.
- (void)sendSize:(NSNumber*)size {
if ([listDelegate respondsToSelector:@selector(sendSizeOfData:)])
{
[listDelegat performSelectorOnMainThread:@selector(sendSizeOfData:)
withObject:size
waitUntilDone:YES];
}
}