I want to create endless loop while button is clicked. Loop will break when I will press button again. I did something like this at the moment.
- (IBAction)Butt_uruchom:(id)sender {
UIBarButtonItem *Button_Uruchom = (UIBarButtonItem *)sender;
NSString *title=Button_Uruchom.title;
if ([title isEqualToString:@"Start"])
{
Button_Uruchom.title = @"Stop";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
do{
[self WyslijZapytanie:@"010C1\r\n"];
}while([title isEqualToString:@"Stop"]);
});
}
else
{
Button_Uruchom.title = @"Start";
}
This code changes button title when button is clicked. I want to start loop when Start is pressed and stop when Stop is pressed. I tried to insert:
do{}while(title isEqualToString:@"Stop") in new Theard
in IF but it dosen't work. Could you help me make this? :)