Problem iphone nsarray?

Well, maybe I just need another look at this, but I have the following lines of code in one of my controllers. It takes some data from the file and fills it into an array, using "\ n" as a delimiter. Then I use this array to create an NSDictionary, which is used to populate the table. It is very simple. However, it does not work. Here is 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);

therefore, the correct date setting in the log is correct; therefore, it correctly extracts data from the file. however for tempArray I get:

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

for the tempArray parameter that I get:

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

which is the correct number of rows in the array

. , . - NSLog, NSDictionary (), :

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"
    );

\

- ?

+3
2

NSLog , temp.

+3

, tempArray.

:

NSLog([NSString stringwithformat:@"temp array: %@",tempArray]);
+2

Source: https://habr.com/ru/post/1745911/


All Articles