我在viewDidLoad里方法就执行了,但我写到其他方法里,NStimer的方法就没执行?
-(void) addButton:(NSNotification *)nc {
DevInfo *devInfo =nc.object;
if(devInfo.name!=NULL && devInfo.name!=nil){
BOOL flag=FALSE;
for (int i=0; i<[self.devInfoList count]; i++) {
if ([[self.devInfoList objectAtIndex:i] isEqualToString:devInfo.name]) {
flag=TRUE;
}
}
if (flag==FALSE) {
//选择的是哪个设备++
[self.devInfoList addObject:devInfo.name];
selectedIndex++;
devInfo.selectedIndex = selectedIndex;
//把设备清单添加到链接项目中
[self.devInfoList addObject:devInfo.mac];
[_radarView addButtonItemAndroid:devInfo];
//手动重画这个View
// [_radarView setNeedsDisplay];
[self timer];
NSLog(@"%@",devInfo.mac);
NSLog(@"%ld",(long)selectedIndex);
if (selectedIndex == 0) {
[self timer];
}
}
}
}
-(void)timer{
_timers = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(clickes) userInfo:nil repeats:NO];
}
-(void)clickes{
[[NSNotificationCenter defaultCenter]postNotificationName:@"shuanxin" object:nil];
}