Hi guys,
i'm coding a small app for the iphone (just for fun)
what i want:
if i press the "update" button:
- send something to the server
- parse the answer of the server
- update the content of some labels on the screen
- show the answer
- play a system sound //using the audio toolbox
- sleep some secods, just enough to finish the previos system sound call
- do other stuff
- end
actually, everything works but... for some reason, the label content is updated at the end of the method / callback / function that is called when pressed the "update" button.
what am i doing wrong? thanks!
some code:
-(void) playASound: (NSString *) file {
//Get the filename of the sound file:
NSString *path = [NSString stringWithFormat:@"%@/%@",
[[NSBundle mainBundle] resourcePath],
file];
SystemSoundID soundID;
//Get a URL for the sound file
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
//play the file
AudioServicesPlaySystemSound(soundID);
}
- (IBAction)update: (id) sender{
BOOL error=[self sendContent];
if ( error == NO ){
result.text=[self parseContent];
[self playSound:@"ready"];
sleep(4);
....
}
// here is updated the gui
}