【发布时间】:2015-01-21 01:53:32
【问题描述】:
我正在编译一个包含以下内容的静态库(FAT 二进制文件):
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
NSOperationQueue *queue = [[NSOperationQueue alloc] init]; // also tried [NSOperationQueue mainQueue]
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
// CRASH BEFORE BLOCK EXECUTES
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
...
如果在设备和模拟器上使用应用程序编译,代码本身运行良好,但仅在模拟器上用作另一个应用程序中的静态库时会崩溃。静态库在 iOS 设备上运行良好。崩溃是EXC_BAD_ACCESS,通过进行一些日志记录,我将其缩小到sendAsynchronousRequest。该块不会被调用。
知道可能出了什么问题吗?
【问题讨论】:
标签: ios iphone nsurlconnection static-libraries objective-c-blocks