I’m trying to update a UILabel within a “while loop” but it is not changing the UILabel text. I know that it is shown at the end of the current run loop cycle at the main thread as usual for iOS. But how can solve this problem ( the http://ftp.AsyncFinished function is provided by external chilkat ftp module) :
The data is updated every second. I searched this forum and in Apple’s documentation, but I could not figure out the correct way to update a UILabel within a “while loop” on the main thread. What can I use instead of a while loop, that allows the main thread to update the UILabel.
while (ftp.AsyncFinished != YES) {
// here is the code getting data from the cilkat FTP module stored in PercentOfFile and MinutesRemaining
NSString *content =[[NSString alloc] initWithFormat:@"%.0f%% done%.0fmin left",PercentOfFile,MinutesRemaining ];
[LabelProgress setText:content];
}
You will need to call your upload progress in another thread and register for call backs. Create a custom class that inherits from CkoFTP2Progress which has this method:
Assuming you have a CkoFTp2 object named “ftp” and your custom class named “UploadProgress”, register for callbacks: