线程
1. 创建一个新的线程:
[NSThread detachNewThreadSelector:@selector(myMethod)
toTarget:self
withObject:nil];
toTarget:self
withObject:nil];
2. 创建线程所调用的方法:
- (void)myMethod {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
*** code that should be run in the new thread goes here ***
[pool release];
}
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
*** code that should be run in the new thread goes here ***
[pool release];
}
假如我们需要在线程里面调用主线程的方法函数,就可以用performSelectorOnMainThread来实现:
[self performSelectorOnMainThread:@selector(myMethod)
withObject:nil
waitUntilDone:false];
withObject:nil
waitUntilDone:false];
读取crash的日记文件
假如很不幸,我们的某处代码引起了crash,那么就可以阅读这篇文章应该会有用: navigate here