我想从服务器刷新数据,但是刷新时间->我想从用户那里获取数据并传递给计时器,我该怎么做我知道要给出这样的值,
self.timerCounter =[NSTimer scheduledTimerWithTimeInterval:300.0
target:self selector:@selector(getGraphData) userInfo:nil repeats:YES];
我还尝试使用协议(protocol)和代表,例如,
self.timerCounter =[NSTimer scheduledTimerWithTimeInterval:strTime
target:self selector:@selector(getGraphData) userInfo:nil repeats:YES];
但我遇到了错误
Sending NSString _strong to parameter of incompatible type NSTimerInterval
现在,我想从文本字段中的用户那里得到它,请帮我这样做
最佳答案
我认为转换 strTime
存在问题到 NSTimeInterval。
self.timerCounter =[NSTimer scheduledTimerWithTimeInterval:[strTime doubleValue] target:self selector:@selector(getGraphData) userInfo:nil repeats:YES];
试试这个,如果有转换问题,这应该可以工作..
关于ios - 使用 NSTimer 从服务器刷新数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35424335/