iphone - Invalidate NSTimer not working -
I have a timer where I format the remaining time as a string: "mm: ss" and When the string value of time is 00:00, I want to invalidate the timer. For some reason this does not work, even when I log in the remaining time, I think that is the correct form of value, so I do not know why there is no branch in "counttime".
Can anyone help?
- (id) init {if (self = [super init]) {NSDate * date = [[NSDate alloc] init]; Self.intervalLength = Date; [Date release]; NSString * timeRem = [[NSString alloc] init]; Self. Timeline = timeline; [Time release]; Formatter = [[NSDateFormatter alloc] init]; [Formatter setDateFormat: @ "mm: ss"]; Notification = [NSOtification NotificationWith: @ "Timer" item: Self]; NotificationandRed = [NSOtification NotificationName: @ "TimerFinished" Object: Self]; NSMutableDictionary * information = [[NSMUTABADADA] alloc] init]; [Information set object: formatter forKey: @ "format"]; [Info setObject: Notice for: @ "Notification"]; [Information set object: Key for notification: @ "Notification End"]; NSTimer * timer = [[NSTimer alloc] init]; Timer = [[Enestimer Elok] Init]; Timer = [nstimer timer with time interval: 1.0 target: auto selector: @sillector (counttime) userinfo: information repeats: yes]; Self.intervalTimer = Timer; } Healthy return; } - (Zero) StartInternval Countdown {runLoop = [NSRunLoop currentRunLoop]; [Run Loop Adapter: self.intervalTimer forMode: NSDefaultRunLoopMode]; } - (zero) countTime: (NSTimer *) timer {if (self.timeRemaining == @ "00:00") {[invalid timer]; Timer = zero; [[NSNotificationCenter defaultCenter] Post Notification: [[Timer User Efo] ObjectForekey: @ "Notification End"]]; } D = [Automator wall timetable time-interval: -1.0]; Self.intervalLength = [D copy]; Self.timeRemaining = [[[Timer user information] ObjectForreake: @ "format"] stringFromDate: d]; [[NSNotificationCenter defaultCenter] Postnotation: [[Timer user ifo] ObjectForcae: @ "Notification"]];
You're comparing the parallelism rather than string similarity. You want
[self.time.RemainingEqualToString: @ "00:00"]
Comments
Post a Comment