-1

My strings are fine, but when they get added to an array a weird grouping of "\n\t\t" gets added to the end. So the string "Apple", becomes "Apple\n\t\t" when I look at the array description.

Whats the deal with that? and how do I fix it?

Addition:

Its XML code. It seemed like [currentPlace appendString:string]; would get the right part, then add the \n\t\t next time round. I solved this by alternating using a boolean:

    if (alternate == NO) {
        [currentPlace appendString:string];
        alternate = YES;
    }   else {
        alternate = NO;
    }

Is there a better way to alternate? I remember there being a case + break way, but I forget how to do it.

Zac Altman
  • 1,215
  • 4
  • 25
  • 37
  • 2
    ..and how are you adding them to the array(Please post the CODE) – erastusnjuki Feb 16 '10 at 14:35
  • Your addition makes things even less clear. – Nikolai Ruhe Feb 16 '10 at 14:47
  • When the XML is being parsed, it checks back for characters until it reaches the end of the tag. In my case, when I was checking the strings, it was only showing me after the first check (because it is a loop). Because of that I only received the first portion of characters which appeared correct. But when I was checking the array, the loop had time to check for additional characters, and added them. Hence I was seeing the \n\t\t. I managed to fix this by adding a switch so that it accepted the first part, and rejected the second part - meaning the string in the array was without the \n\t\t. – Zac Altman Feb 16 '10 at 14:55

2 Answers2

1

Adding strings to an array obviously does not modify their contents. Your bug is somewhere else, a part of your program you did not describe. Without code, nobody would be able to help you.

Nikolai Ruhe
  • 81,520
  • 17
  • 180
  • 200
0

I solved this by adding a switch to:

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string;

All is good now.

Zac Altman
  • 1,215
  • 4
  • 25
  • 37