2

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);
            }
        }
    }];
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
silvaric
  • 1,668
  • 17
  • 27

3 Answers3

2

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

T Lam
  • 162
  • 5
2

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

T Lam
  • 162
  • 5
1

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.

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
  • didn't work :( , i already try writeToURL or writeToFile.. load with stringWithContentsOfURL, and the problem continue – silvaric Jul 27 '12 at 12:02
  • You mean it still freezes when you write the `responseObject` without converting it to a string? – trojanfoe Jul 27 '12 at 12:07
  • hum... probably i'm doing wrong, so i define a path to URL and write [dataXML writeToURL:storeUrl atomically:YES] after i load with [NSString stringWithContentsOfURL:storeUrl encoding:NSASCIIStringEncoding error:&error] or [NSData dataWithContentsOfURL:storeUrl] but still freezes in both ways – silvaric Jul 27 '12 at 12:14
  • And if you remove **all** logging of the XML, the freezing goes away? I'm wondering if it's the actual loading of the data across the network... – trojanfoe Jul 27 '12 at 12:17
  • Yes, if i remove all nslog goes away – silvaric Jul 27 '12 at 12:23