问题
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