My application needs to show a temporary message, so I created Toast like android myself. It works well for only one toast. I am using NSTimer to hide the message. If I display more than one toast the timer becomes a problem. Only the last added toast becomes hidden, others do not become hidden. How can I hide all toasts?
Code:
Remove function:
-(void)removeToast
{
NSLog(@"removed");
[self.view removeFromSuperview];
}
Timer start:
timer = [NSTimer scheduledTimerWithTimeInterval:(4.0f)
target:self
selector:@selector(xxxx)
userInfo:nil repeats:NO];
I wrote this in above in separate NSObject
class and created an object. I need some clarification on how run the two NSTimer simultaneously or keep track of all NSObjects
.
Object creation in viewcontroller is
@property(nonatomic,strong)Toast *toast;