views:

190

answers:

3

I'm converting data (from a web page) to a string). The basic code works (but there's been some subtle change somewhere - maybe on server).

NSLog shows the expected string (maybe 1000 chars long). However, when I float over responseString, it shows "Invalid". Worse, parsing with componentsSeparatedByCharactersInSet does not work.

Ideas?

NSString *responseString;
responseString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSLog([NSString stringWithFormat:@"responsestring ='%@'",responseString]);
if ([responseString compare:@""] != NSOrderedSame) {
 lines = [responseString componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@";"]];
A: 

Do not trust what the debugger says, it is not accurate, this has happened to me and took me a while to realise that the xcode debugger is not always right and should not be trusted, so i no longer trust the debugger and i use nslog statements whenever it tries to tell me something is invalid. So dont worry about it it happens, and when it happened to me I was also parsing responses from some webservice.

Daniel
Dead on. I went back and realized I set version to "release". The debugger should provide different values like "unknown - using release version" if it can't figure out the value.
BankStrong
+2  A: 

This may happen when the configuration is set to "Release" rather than "Debug" I think.

Ushox
A: 

Just to be clear -- my experience with seeing "Invalid" in the debugger means that the reference is to an already-released object.

Your question and the comments below seem to suggest that you are thinking "Invalid" is an actual string value -- but are you sure you don't just have a memory management probably?

Amagrammer