我更新了 xcode 4.4(使用 Apple LLVM 编译器 4.0),从那时起,当我尝试在控制台中打印 XML 时,xcode 和应用程序(在模拟器中)会阻止用户交互......我需要等待 30 秒或更长时间才能完成(我可以'什么都不做)
我正在使用 AFNetworking 和 TBXML,但问题不在解析中,因为如果我删除解析,问题还会继续。
所以我尝试了 NSOperationQueue、NSBlockOperation、grand dispatch central ......什么也没有,仍然冻结。
是因为 XML 太大了???(...我需要打印 XML 来调试和测试东西)
1º 请求和打印 XML
- (void) doRequestPOST:(NSString*)URL params:(NSString*)params withSuccess:(void(^)(BOOL,id))successBlock{
(....)
AFHTTPRequestOperation *op = [sharedAPI HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString* xml = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
//>>>>>PROBLEM HERE<<<<< if i remove next line (nslog) the problem does not occur
NSLog(@"\n\nResponse \nURL :\n%@\nXML :\n%@\n \n",operation.request.URL,xml);
[xml release];
TBXML * tbxml = [TBXML newTBXMLWithXMLData:responseObject error:nil];
[self saveCookiesFromHTTPHeaderFields:[operation response] withTBXML:tbxml.rootXMLElement];
if (successBlock) {
successBlock(TRUE,responseObject);
}
}
2º 将请求请求并解析 来自“successBlock(TRUE,responseObject);”的响应
[self doRequestPOST:stringURL params:nil withSuccess:^(BOOL success, id response) {
if (success) {
//will parse response
[self.dictionaryCategoryContents setObject:[Parser parseVodContent:response] forKey:idCategory];
if (responseBlock){
responseBlock (YES,[dictionaryCategoryContents objectForKey:idCategory]);
}
}else {
if (responseBlock){
responseBlock (NO,response);
}
}
}];