iOS 开发实用技术导航
NSHipster 中文版
› http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
› http://www.cocos2d-iphone.org/
CocoaPods
› http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
› http://code.google.com/mobile/analytics/
WWDC
› https://developer.apple.com/wwdc/
Design Guides and Resources
› https://developer.apple.com/design/
Transcripts of WWDC sessions
› http://asciiwwdc.com
Cocoa with Love
› http://cocoawithlove.com/
Cocoa Dev Central
› http://cocoadevcentral.com/
NSHipster
› http://nshipster.com/
Style Guides
› Google Objective-C Style Guide
› NYTimes Objective-C Style Guide
Useful Tools and Services
› Charles Web Debugging Proxy
› Smore
Linxing
0.85D
V2EX  ›  iDev

求大神帮忙看下 NSTimer 的问题...

  •  
  •   Linxing ·
    linxing · Feb 20, 2014 · 3566 views
    This topic created in 4602 days ago, the information mentioned may be changed or developed.




    不使用NSTimer手动获取json内容是可以的...
    11 replies  •  1970-01-01 08:00:00 +08:00
    wezzard
        1
    wezzard  
       Feb 20, 2014   ❤️ 1
    建议使用
    + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)repeats
    或者
    + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds invocation:(NSInvocation *)invocation repeats:(BOOL)repeats
    来创建 NSTimer 对象,这样 NSTimer 一旦被创建出来就被放到 Runloop 上了。不然你还得手动将其放置在 Runloop 上。
    Linxing
        2
    Linxing  
    OP
       Feb 20, 2014
    @wezzard 我是这么创建的啊....
    alexrezit
        3
    alexrezit  
       Feb 20, 2014
    [timer fire];

    這樣?
    alexrezit
        4
    alexrezit  
       Feb 20, 2014
    噢...

    -addTimer:forMode:
    alexrezit
        5
    alexrezit  
       Feb 20, 2014
    我好像又在夢游了... 抱歉!
    Linxing
        6
    Linxing  
    OP
       Feb 20, 2014
    @alexrezit 需要fire?
    alexrezit
        7
    alexrezit  
       Feb 20, 2014
    @Linxing
    你的代碼不是這麼說的... 用 scheduledTimer prefix 的 method 就可以了.
    也不清楚為什麼要重復獲取...
    alexrezit
        8
    alexrezit  
       Feb 20, 2014
    @Linxing
    忽略那條回復就好了.
    Linxing
        9
    Linxing  
    OP
       Feb 20, 2014
    @alexrezit 好吧..就想写个NSTimer,看书看到这..
    Linxing
        10
    Linxing  
    OP
       Feb 20, 2014
    @alexrezit 改好了,确实是我自己代码写得问题,scheduledTimer可以。。谢了
    Linxing
        11
    Linxing  
    OP
       Feb 20, 2014
    @Linxing 谢了..
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2539 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 11:08 · PVG 19:08 · LAX 04:08 · JFK 07:08
    ♥ Do have faith in what you're doing.