ios - 使用 NSTimer 从服务器刷新数据

标签 ios objective-c xcode6 nstimer

我想从服务器刷新数据,但是刷新时间->我想从用户那里获取数据并传递给计时器,我该怎么做我知道要给出这样的值,

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/

相关文章:

ios - AudioKit示例MicrophoneAnalysis的最大频率

iOS 相当于 HTML/CSS 中的分层 div

objective-c - GPUImage 相当于 cv::findContours

ios - 为什么我的数组返回 null?

swift - Xcode 6/SpriteKit/Swift 中的场景大小

ios - 在单独的类中实现 UITextFieldDelegate

ios - 如何在 iOS 上生成音符并播放它们?

ios - 如何以正确的方式使用导航 Controller 实现标签栏 Controller

ios - 延迟后执行选择器只调用一次

ios - 找不到 PDF 标题 : `%PDF' not found