views:

65

answers:

2

Okay maybe i just need another set of eyes on this, but I have the following lines of code in one of my view controllers. It takes some data from a file, and populates it into an array using "\n" as a separator. I then use that array to make an NSDictionary, which is used to populate a tableview. It's very simple. However it isnt working. Here's the code:

NSString *dataString = [NSString stringWithContentsOfFile:checklistPath encoding: NSUTF8StringEncoding error:NULL];


    if ([dataString hasPrefix:@"\n"]) {
        dataString = [dataString substringFromIndex:1];

    }
    NSArray *tempArray = [dataString componentsSeparatedByString:@"\n"];
    NSLog(@"datastring:%@",dataString);
    NSLog(@"temp array:",tempArray);
    NSLog(@"%i",[tempArray count]);

    NSDictionary *temporaryDictionary = [NSDictionary dictionaryWithObject: tempArray forKey:@"User Generated Checklist"];
    self.names = temporaryDictionary;
            NSLog(@"names:%@",names);

so in the log, datastring is correct, so it's correctly pulling the data from a file. however for tempArray, i get:

2010-05-17 19:15:55.825 MyApp[7309:207] temp array:

for the tempArray count i get:

2010-05-17 19:15:55.826 myApp[7309:207] 5

which is the correct number of strings in the array

So i'm stumped. I have the EXACT same few lines of code in a different view controller and it works perfectly. Whats crazier is the last NSLog, that shows the final NSDictionary (names) displays this, which looks correct:

2010-05-17 19:15:55.827 FS Companion[7309:207] names:{
    "User Generated Checklist" =     (
        "System|||ACTION",
        "System|||ACTION",
        "System|||ACTION",
        "System|||ACTION",
        "System|||ACTION"
    );

\

am i missing something really obvious??

+2  A: 

you don't have a variable in the string that logs tempArray.

it should look like this:

NSLog([NSString stringwithformat:@"temp array: %@",tempArray]);
pop850
thank you. i feel like an idiot. I have been staring at this code for over an hour...
Brodie
I know the feeling...
pop850
+3  A: 

There's no format specifier in the NSLog statement that prints out the temp array.

warrenm
haha thanks - it WAS something stupid...it's still not working (populating the tableView) but at least now i can look somewhere else for the bug...boy i need a break lol
Brodie