I have two class. I have one property NSTimer
in my first class like this:
@interface KKProgressTimer : UIView
@property(nonatomic,retain) NSTimer *TimeCount;
@end
I could create two object from KKProgressTimer
class and add in my second class.
in my second class I want to allocate NSTimer
property to every object KKProgressTimer
class.but I can't please guide me!!!
//this loop check and get two object KKProgressTimer class
for (UIView *subview in self.view.subviews) {
if ([subview isKindOfClass:[KKProgressTimer class]]) {
KKProgressTimer *Progress = (KKProgressTimer*)subview;
//now I want to allocate NSTimer property this here and define scheduledTimerWithTimeInterval for it
//timing = [[NSTimer alloc]init];
//timing = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(CountDown:) userInfo:timing repeats:YES];
}
}
My friend maybe you forget set method for TimeCount.
write this code in second class:
Progress.TimeCount = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(CountDown:) userInfo:timing repeats:YES];
and write this code in .m file KKProgressTimer class
- (void)setTimeCount:(NSTimer *)TimeCount {
if (TimeCount) {
TimeCount = nil;
}
}