iphone nsarray problem?
Posted
by Brodie4598
on Stack Overflow
See other posts from Stack Overflow
or by Brodie4598
Published on 2010-05-18T01:29:10Z
Indexed on
2010/05/18
1:40 UTC
Read the original article
Hit count: 254
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??
© Stack Overflow or respective owner