Apple LLVM compiler 4.0 freeze xcode and app when print XML (NSLog)

738 Views Asked by At

I update for xcode 4.4 (with Apple LLVM compiler 4.0) and since then when i try to print XML in console the xcode and app (in simulator) block user interaction...and i need wait 30seconds or more until finish (i can't do nothing)

i´m using AFNetworking and TBXML, but the problem isn't in parse because if i remove the parse the problem continue.

So i try NSOperationQueue,NSBlockOperation, grand dispatch central ... and nothing, still freeze.

Is because XML is too big??? (...i need print XML to debug and test things)

1º The Request and print 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º Will ask for request and parse response from "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);
            }
        }
    }];
3

There are 3 best solutions below

0
On BEST ANSWER

This issue seems to be fixed by 4.4.1 released on 8/7/2012.

0
On

I am currently encountering the same problem. Whenever I NSLog a large string, I just see XCode and the Simulator hang (beachball). But if I wait 2-3 minutes, the app will proceed.

There seems to be a bug with XCode 4.4, and other devs reported the same behavior: http://openradar.appspot.com/11972490

5
On

If you need to log the response for debugging (or error reporting) then I think you should write the responseObject to a file in the caches directory (or whatever the equivalent folder is under iOS, if that is the O/S). Then you can access this file to see what the response was. The only problem to overcome then is how to keep the folder from getting too big; perhaps delete all previously written files when the app starts or at regular intervals.

You can write the response using the [NSData writeToURL:atomically:] method and this will be quicker as it doesn't require conversion to string first.