nsthread

why do I get “wait_fences: failed to receive reply” for this code?

☆樱花仙子☆ 提交于 2019-12-30 11:29:30
问题 why do I get "wait_fences: failed to receive reply" for this code? Is it the way I'm using notification to communicate back to the main thread? #import "ViewController.h" @implementation ViewController @synthesize alert; #pragma mark - Background Thread Test Methods - (void) ConfigTasksForBackground:(id)sender{ NSLog(@"ConfigTasksForBackground - Starting"); [NSThread sleepForTimeInterval:6]; [[NSNotificationCenter defaultCenter] postNotificationName:@"ModelChanged" object:self]; NSLog(@

why do I get “wait_fences: failed to receive reply” for this code?

China☆狼群 提交于 2019-12-30 11:27:07
问题 why do I get "wait_fences: failed to receive reply" for this code? Is it the way I'm using notification to communicate back to the main thread? #import "ViewController.h" @implementation ViewController @synthesize alert; #pragma mark - Background Thread Test Methods - (void) ConfigTasksForBackground:(id)sender{ NSLog(@"ConfigTasksForBackground - Starting"); [NSThread sleepForTimeInterval:6]; [[NSNotificationCenter defaultCenter] postNotificationName:@"ModelChanged" object:self]; NSLog(@

NSThread number on iOS? [duplicate]

余生颓废 提交于 2019-12-29 07:33:08
问题 This question already has answers here : po [NSThread currentThread] (2 answers) Closed 6 years ago . When you print a NSThread's description, you get something like this: <NSThread: 0x1e511b70>{name = (null), num = 1} Is this "num" available somehow? This is for debugging only, so it does not need to clear Apple's approval process. 回答1: That number is actually an ivar in NSThread's private implementation class. The class is _NSThreadInternal , and its name is "_private". Inside that object,

checking for equality on dispatch_queue_t

和自甴很熟 提交于 2019-12-29 07:15:12
问题 How can I check for equality between dispatch_queue_t vars? dispatch_queue_t currentQueue = dispatch_get_current_queue(); dispatch_queue_t mainQueue = dispatch_get_main_queue(); if (currentQueue == mainQueue) { } from the docs: typedef struct dispatch_queue_s *dispatch_queue_t; I'm not sure but does this mean that it's a pointer to a dispatch_queue_s struct? Since I can't check equality on pointers, I'm not sure how can I check if a dispatch_queue_t is the same as another? 回答1: This depends

Is it ok to create a UIView on a background thread?

孤人 提交于 2019-12-28 05:58:49
问题 I know UIView are not thread safe so i cant add a view on a background thread, to work around this is it ok to create a UIView on a background thread then add it on the main thread? Note: the reason im not doing this on the main thread is because my actual code is a lot more complex and therefor takes a while to create all the views and fill the values. I dont want the UI to become un-responsive when I do this so im trying to work around this. for example.. -(void)addLabel//called on

Objective-C: [NSObject performSelector: onThread…] does not get called if the thread is not the main one

独自空忆成欢 提交于 2019-12-25 09:13:27
问题 Very similar issue is already discussed here. The problem at hand and what I am trying to achieve is to call a function on a given object in the thread it is created at. Here is the complete case: an instance of class A is created in a given NSThread (Thread A) (not the main one). The instance keeps its creating NSThread as a member variable. an instance of class B has one of its member functions executing in another NSThread - Thread B, and wants to call a function of A in A's creation

Can an open, but inactive, NSStream that is scheduled on the main thread be moved to a different thread?

独自空忆成欢 提交于 2019-12-25 02:19:51
问题 I am using (and am required to use) a third-party framework to which I do not have source. The third-party framework handles creating an authenticated client/server connection and hands back a pair of open NSStreams. The challenge that I have is the NSStreams are scheduled on the main thread (creating situations where the UI may become unresponsive - which I would like to avoid). At the point that the streams are handed off from the third party framework, no network traffic is in progress. So

Problem with Thread and NSTimer

▼魔方 西西 提交于 2019-12-25 01:55:29
问题 I have a problem in my code. I want to launch the thread but when it is launched they can't start a NSTimer istruction. Can you help me? -(void)detectionMove:(NSTimer*)timer{ int indexArray = [[[timer userInfo] objectForKey:@"arrayIndex"] intValue]; // do something } -(void)callDectectionMove:(NSNumber*)arrayIndex{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] init]; [myDictionary setObject:arrayIndex forKey:@

Threads and autoreleasepool questions

感情迁移 提交于 2019-12-24 16:18:15
问题 As I understand there are several ways to send tasks to be performed in threads. The most common ones that I use are: 1) performSelector:withObject:afterDelay: 2) performSelectorOnMainThread:withObject:waitUntilDone: 3) performSelectorInBackground:withObject: 4) [NSThread detachNewThreadSelector:toTarget:withObject:] My first question is, what is the difference between 1) and 2), besides the obvious parameter differences? Are they actually both working in the Main thread (whose autorelease

Killing a thread or an alternative

故事扮演 提交于 2019-12-24 11:27:44
问题 Is there any way I can kill a thread spawn through: [NSThread detachNewThreadSelector:@selector(serverFetchInThread) toTarget:self withObject:nil]; The scenario I am working on is that in my main thread I am letting user enter data in my search bar and what ever user is typing I need to send to server for searching in a separate thread. Now, if user changes his selection by deleting old data and entering new data I do not want the previous thread to waste its time, kill it and spawn a new