do runloops/multi-threading/timers behave differently on iOS6?

跟風遠走 提交于 2019-12-13 18:21:35

问题


I just installed Xcode 4.5 to start testing some code on iOS6 devices.. I wanted my existing code to be runnable on both iOS 5 and iOS 6 obviously. The same code (below) that used to work on Xcode 4.3 stopped working on Xcode 4.5:

-(BOOL)readFromRingBuffer
{                
    NSDate *fireDate = [NSDate dateWithTimeIntervalSinceNow:0];
    ringBufferReaderTimer = [[NSTimer alloc] initWithFireDate:fireDate
                                                    interval:0.25
                                                      target:self
                                                     selector:@selector(readRingBufferDataBit)
                                                    userInfo:NULL
                                                     repeats:YES];

    NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
    [runLoop addTimer:ringBufferReaderTimer forMode:NSDefaultRunLoopMode];
}

I had to put this line for the method to fire:[ringBufferReaderTimer fire]; (didn't have to do this on XCode 4.3)

but then it would go through the method once and nothing would happen.. in general.. I see weird things happening.. is there something I need to know about threading in iOS6 that I'm not aware of? A quick googling doesn't tell me much..

来源:https://stackoverflow.com/questions/12929526/do-runloops-multi-threading-timers-behave-differently-on-ios6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!