In my app I download an HTML file from a server and check if an image is currently on the website and set a status to a label when the image was found. All works great but I like to
show the user a Loading status label while the app is downloading the file. It works with static text but how can I show running points after the Loading text? I like to see: Loading > Loading. > Loading.. > Loading… > Loading > and so on (I don’t need an exact progress bar)
Code:
- (void)viewDidLoad
{
[super viewDidLoad];
platzStatusLabel.text = @"Loading";
if (myConnection == nil) {
myData = [NSMutableData new];
NSString *urlString = [NSString stringWithFormat:@"http://www.myURL.com"];
myConnection =[NSURLConnection connectionWithRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:urlString]]
delegate:self];
}
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *stringToLookup = [[NSString alloc]initWithData:myData encoding:NSASCIIStringEncoding];
if ([stringToLookup rangeOfString:@"image_green"].location != NSNotFound){
platzStatusLabel.text = @"Course is open.";
} else {
platzStatusLabel.text = @"Course is closed.";
}
[self initializeVariablesAgain];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[myData appendData:data];
}
- (void) initializeVariablesAgain {
myData = nil;
myConnection = nil;
}
Why not start a UIActivityIndicator (this circly thing that highlights) upon creation of the request and stop it in didFinishLoading?
Or start and stop an NSTimer that iterates through your several strings in the same fashion.
Lastly, you could iterate through your different strings in didReceiveData.
Cheers