nsthread

Xcode: How to set CA_DEBUG_TRANSACTIONS=1?

安稳与你 提交于 2019-11-30 11:39:55
I'm getting this warning in the log window of the debugger: CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces. I have to find out what code of mine is calling CATransaction so I can make sure it is running on the main thread. My code doesn't call CATransaction directly. I.e. a search of my code for CATransaction turns up nothing. In Xcode 5, what is the correct way to set CA_DEBUG_TRANSACTIONS=1 in the environment? Thanks in advance to all for any info. gilm Product -> Scheme -> Edit Scheme Select "Run" entry and

NSThread sleepfortimeinterval blocks main thread

谁说胖子不能爱 提交于 2019-11-30 11:29:34
I want to simulate a communication with a server. As the remote server will have some delays I want to use a background thread that has on it [NSThread sleepForTimeInterval:timeoutTillAnswer]; The thread is created with NSThread sub classing and started ... However I noticed that sleepForTimeInterval is blocking the main thread... Why??? Isn't a NSThread a backgroundThread by default? This is how the thread is created: self.botThread = [[PSBotThread alloc] init]; [self.botThread start]; Further info: This is the bot thread subclas - (void)main { @autoreleasepool { self.gManager = [

calling selector with two arguments on NSThread issue

梦想与她 提交于 2019-11-30 08:44:03
I'd like to make a Thread with multiple arguments. Is it possible? I have the function: -(void) loginWithUser:(NSString *) user password:(NSString *) password { } And I want to call this function as a selector: [NSThread detachNewThreadSelector:@selector(loginWithUser:user:password:) toTarget:self withObject:@"someusername" withObject:@"somepassword"]; // this is wrong How to pass two arguments on withObject parameter on this detachNewThreadSelect function? Is it possible? ennuikiller You need to pass the extra parameters in an object passed to withObject like so: NSDictionary *extraParams =

NSOperations or NSThread for bursts of smaller tasks that continuously cancel each other?

99封情书 提交于 2019-11-30 07:42:51
I would like to see if I can make a "search as you type" implementation, against a web service, that is optimized enough for it to run on an iPhone. The idea is that the user starts typing a word; "Foo", after each new letter I wait XXX ms. to see if they type another letter, if they don't, I call the web service using the word as a parameter. The web service call and the subsequent parsing of the result I would like to move to a different thread. I have written a simple SearchWebService class, it has only one public method: - (void) searchFor:(NSString*) str; This method tests if a search is

Keep NSThread alive and run NSRunLoop on it

老子叫甜甜 提交于 2019-11-30 06:27:24
问题 So I'm starting a new NSThread that I want to be able to use later by calling performSelector:onThread:... . From how I understand it calling that methods add that call to the runloop on that thread, so on its next iteration it will pop all these calls and subsequently call them until there is nothing left to call. So I need this kind of functionality, an idle thread ready for work that I just can call upon it. My current code looks like this: - (void)doInitialize { mThread = [[NSThread alloc

Difference in scheduling NSTimer in main thread and background thread?

风流意气都作罢 提交于 2019-11-30 01:21:11
When I call scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: on the main thread and set time interval to 5 seconds code below timer gets executed, and after 5 seconds timer selector is called. But if I try same in some background thread, the code below scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: will not be executed, it will wait for the timer to fire and then gets executed. Of course, in order to run the timer in the background thread, I first got an instance of NSRunLoop and run it. Is there a way to set the timer in the background thread and make it non

NSThread sleepfortimeinterval blocks main thread

混江龙づ霸主 提交于 2019-11-29 17:04:56
问题 I want to simulate a communication with a server. As the remote server will have some delays I want to use a background thread that has on it [NSThread sleepForTimeInterval:timeoutTillAnswer]; The thread is created with NSThread sub classing and started ... However I noticed that sleepForTimeInterval is blocking the main thread... Why??? Isn't a NSThread a backgroundThread by default? This is how the thread is created: self.botThread = [[PSBotThread alloc] init]; [self.botThread start];

iOS - how to be notified when a thread (using GCD) ends it's job

青春壹個敷衍的年華 提交于 2019-11-29 15:48:44
问题 I'm start to use GCD, and I need to know when a certain thread has ended it's job. My code: dispatch_queue_t registerDeviceQueue = dispatch_queue_create("RegisterDevice", NULL); dispatch_async(registerDeviceQueue, ^{ [self registerDevice]; dispatch_async(dispatch_get_main_queue(), ^{ [aiRegisterDevice stopAnimating]; }); }); dispatch_release(registerDeviceQueue); I need to know when this tread has ended, so that the UIActivityView can stop. The way it is now, it's stops before the thread ends

NSOperations or NSThread for bursts of smaller tasks that continuously cancel each other?

六月ゝ 毕业季﹏ 提交于 2019-11-29 11:00:02
问题 I would like to see if I can make a "search as you type" implementation, against a web service, that is optimized enough for it to run on an iPhone. The idea is that the user starts typing a word; "Foo", after each new letter I wait XXX ms. to see if they type another letter, if they don't, I call the web service using the word as a parameter. The web service call and the subsequent parsing of the result I would like to move to a different thread. I have written a simple SearchWebService

NSThreads in Automatic Reference Counting(ARC)

旧巷老猫 提交于 2019-11-29 10:27:00
i am trying to use NSThreads with ARC in 4.3.5. With iOS 5 everything works perfect, but if i try it on a older iOS like 4.3 its leaking. Normally i would use a Autoreleasepool for NSThreads but since there is no manual Autoreleasepool in ARC i don't know how to fix this. I get loads of Messages like "__NSAutoreleaseNoPool(): Object 0x4567b40 of class NSComparisonPredicate autoreleased with no pool in place - just leaking" in my Console after i start a Thread. NSThread detachNewThreadSelector:@selector(showAlert) toTarget:self withObject:nil]; How to correctly thread with ARC and iOS prior to