nsrunloop

NSRunLoop freezes with NSTimer and any input

两盒软妹~` 提交于 2019-12-08 04:30:31
For some reason when I push down (click and hold) on any control, the NSTimer in my App freezes and does not fire until I release the mouse button. It simply does not fire while I have the mouse pressed. This is fine for short periods, but it also freezes if I have a popup menu open, or a combobox dropped down. I'm not sure if there is something I missed, but it seems like this is incorrect behavior. I want to be able to click the down arrow of an NSPopUpButtonCell (or even click and hold an NSTableView) without the entire NSTimer freezing (which redraws an NSView). Any comments / suggestions

Adding Pinch/Zoom effect to a UIImageView inside a UIScrollView

﹥>﹥吖頭↗ 提交于 2019-12-07 17:33:48
问题 I have a very basic screen sharing iPhone app, I have successfully added the pinch/zoom effect to my app using a UIImageView inside a UIScrollView . The UIImageView receives the screen content from the PC on a regular interval. Everything works fine but as soon as I scroll/pinch/zoom it works at first but then it stops, and the delegate method that's updating the image view content stops firing up even though the server still sends the screen content. The whole app seems to be frozen but

how to use NSRunLoop in objective-C?

醉酒当歌 提交于 2019-12-07 10:31:14
问题 how to use how to use NSRunLoop in objective-C and wait for some variable to change value ? Thanks 回答1: We would not normally use a NSRunLoop in production to wait for a variable to change. One could use a callback. However, in unit test code we do have the following: NSDate *twoSecondsFromNow = [NSDate dateWithTimeIntervalSinceNow:2.0]; while (!callBackInvoked && !errorHasOccured && runCount-- && [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:twoSecondsFromNow]) {

How to “validate” a NSTimer after invalidating it?

亡梦爱人 提交于 2019-12-06 18:29:42
问题 So basically, I have this timer that should be repeated when it receives a key event, and invalidates when the user releases the key. However, I am unable to "validate" the timer back even by calling the addTimer:forMode: in NSRunLoop. Does anyone know why this is happening and how I can fix this? Thanks. 回答1: You cannot use invalidated timer. From Apple Docs: Once scheduled on a run loop, the timer fires at the specified interval until it is invalidated. A non-repeating timer invalidates

How to make NSRunLoop work inside a separate thread?

亡梦爱人 提交于 2019-12-06 05:19:17
问题 Please look at this code: @interface myObject:NSObject -(void)function:(id)param; @end @implementation myObject -(void)function:(id)param { NSLog(@"BEFORE"); [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:20]]; NSLog(@"AFTER"); } @end int main(int argc, char *argv[]) { myObject *object = [[myObject alloc] init]; [NSThread detachNewThreadSelector:@selector(function:) toTarget:object withObject:nil]; @autoreleasepool { return UIApplicationMain(argc, argv, nil,

Adding Pinch/Zoom effect to a UIImageView inside a UIScrollView

落爺英雄遲暮 提交于 2019-12-05 20:39:08
I have a very basic screen sharing iPhone app, I have successfully added the pinch/zoom effect to my app using a UIImageView inside a UIScrollView . The UIImageView receives the screen content from the PC on a regular interval. Everything works fine but as soon as I scroll/pinch/zoom it works at first but then it stops, and the delegate method that's updating the image view content stops firing up even though the server still sends the screen content. The whole app seems to be frozen but there are no error messages/exceptions/whatever. Can anyone help me, please? Chandan Shetty SP If you are

Should I use NSOperation or NSRunLoop?

倾然丶 夕夏残阳落幕 提交于 2019-12-05 07:48:03
问题 I am trying to monitor a stream of video output from a FireWire camera. I have created an Interface Builder interface with buttons and an NSImageView . While image monitoring is occurring within an endless loop, I want to: change some camera parameters on the fly (gain, gamma, etc.) tell the monitoring to stop so I can save an image to a file (set a flag that stops the while loop) Using the button features, I have been unable to loop the video frame monitor, while still looking for a button

NSRunLoop- Clarification needed

♀尐吖头ヾ 提交于 2019-12-05 01:06:45
问题 I am trying to understand the concept of RunLoops. I have read Apple developer's guide on RunLoops and to some extent I have understood the concept of RunLoops. To make my concept more clearer I wrote a very simple code which uses RunLoops in it. The code can be seen below. - (void)viewDidLoad { [super viewDidLoad]; thread = [[NSThread alloc] initWithTarget:self selector:@selector(testMethod) object:nil]; [thread start]; } - (void)testMethod { NSAutoreleasePool* pool = [[NSAutoreleasePool

Performing selector at beginning / end of run loop

为君一笑 提交于 2019-12-04 20:11:35
问题 All events and methods in iOS are processed using NSRunLoop : user events, method calls, rotations, timers, connections, etc. My question is : How can I perform a selector in a precise moment of the run loop as the beginning and the end? 回答1: You can create a CFRunLoopObserver which will call a block on loop entry and exit. You use CFRunLoopAddObserver to add your observer to the run loop, and CFRunLoopGetMain to obtain the run loop to add to. Here is a rather pointless example using these: -

How to make NSRunLoop work inside a separate thread?

末鹿安然 提交于 2019-12-04 10:13:16
Please look at this code: @interface myObject:NSObject -(void)function:(id)param; @end @implementation myObject -(void)function:(id)param { NSLog(@"BEFORE"); [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:20]]; NSLog(@"AFTER"); } @end int main(int argc, char *argv[]) { myObject *object = [[myObject alloc] init]; [NSThread detachNewThreadSelector:@selector(function:) toTarget:object withObject:nil]; @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } The function method is called but there's no 20 seconds pause