nsthread

Objective C find caller of method

删除回忆录丶 提交于 2019-11-26 16:52:59
Is there a way to determine the line of code a certain method was called from? intropedro StackI hope that this helps: NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1]; // Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]]; [array removeObject:@""]; NSLog(@"Stack = %@", [array objectAtIndex:0]); NSLog(@

How to pause an NSThread until notified?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 16:16:33
问题 I have a worker thread that I want to do one bit of its task, then pause & wait for the "ok, continue" command from another thread, then pause & wait, etc. The use case is: the controlling object is a view that I want to display information about what's going on inside the worker-thread, and allow me to "single-step" through the worker as it does it's thing. The rather ugly and heavy-handed thing that I have in my worker is this: NSLog(@"paused"); paused = YES; while (paused) { [NSThread

Objective C find caller of method

一曲冷凌霜 提交于 2019-11-26 04:58:49
问题 Is there a way to determine the line of code a certain method was called from? 回答1: StackI hope that this helps: NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1]; // Example: 1 UIKit 0x00540c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163 NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet