I need a second set of eyes here. I have done this many times before with out a problem. I am getting 4 text files from the internet and then using NSScanner to read in each line, from each txt file. At that point I add each line of text to an NSString and further add that string to an NSMutableArray. When it finished reading in the txt file it adds the NSMutableArray to a NSMutableDictionary.
I used NSLog to verify the all the data exists in the MutableArray but when I try to verify that it was saved to the MutableDictionary it just prints out the keys and the objects are blank.
Here is the log and I can see clientArray hold values
Here is the Method so far. At the bottom is where I test it
I have looked at it for a couple hours now and can't track down the problem.
Thanks
I used NSLog to verify the all the data exists in the MutableArray but when I try to verify that it was saved to the MutableDictionary it just prints out the keys and the objects are blank.
Here is the log and I can see clientArray hold values
2012-02-16 13:45:00.994 SYV Traveler[5905:b903] ClientArray: (
"Olive House",
"Olive & olive oil tasting",
"River Course",
Golfing,
"Wine Country Mobile Massage",
"Mobile massage service"
)
2012-02-16 13:45:00.995 SYV Traveler[5905:b903] Client Dicts: {
activities = (
);
dining = (
);
shopping = (
);
wine = (
);
}
2012-02-16 13:45:00.995 SYV Traveler[5905:b903] items: (
)
kill
quit
Program ended with exit code: 0
Here is the Method so far. At the bottom is where I test it
Code:
@interface ViewController : UIViewController{
NSMutableDictionary *clientTableViewDict;
NSMutableArray *clientArray;
}
Code:
-(void)backgroundNameLoad{ //Load the tableView Lists
BOOL checkForFile;
int locationOfScanner = 0;
NSMutableString *tempStorageString = [[NSMutableString alloc] init];
clientArray = [[NSMutableArray alloc] init];
[COLOR="Red"]clientTableViewDict = [[NSMutableDictionary alloc] init];[/COLOR]
NSFileManager *fileManager = [NSFileManager defaultManager]; //Create File manager object
for (int i = 0; i < 4; i++) {
NSString *verifyLocalFile = [self dataPathToAllFiles:i];
checkForFile = [fileManager fileExistsAtPath:verifyLocalFile]; // BOOL to see if file exists
NSLog(@"Local File Path %@", verifyLocalFile);
if (checkForFile) {
NSLog(@"The file is here");
}
else{
NSLog(@"No file exists");
NSURL *fileLocation = [self getNextURL:i];
NSString *currentClientList = [NSString stringWithContentsOfURL:fileLocation encoding:NSUTF8StringEncoding error:nil];
NSScanner *scanner = [NSScanner scannerWithString:currentClientList];
while (![scanner isAtEnd]) {
[scanner setScanLocation:locationOfScanner];
[scanner scanUpToString:@"\n" intoString:&tempStorageString];
locationOfScanner = [scanner scanLocation];
[clientArray addObject:tempStorageString];
}
[COLOR="Red"][clientTableViewDict setValue: clientArray forKey:[self dictName:i]];[/COLOR]
NSLog(@"ClientArray: %@", clientArray);
locationOfScanner = 0;
[clientArray removeAllObjects];
}
}
NSLog(@"Client Dicts: %@", clientTableViewDict);
NSLog(@"items: %@", [clientTableViewDict objectForKey:@"wine"]);
}
I have looked at it for a couple hours now and can't track down the problem.
Thanks