iPhone NSMutableDictionary setObject forKey after initWithContentsOfFile
- by andrew
so here's my function
+ (void) AddAddress:(NSString*)ip:(NSString*)mac {
NSMutableDictionary* currentAddresses = [[NSMutableDictionary alloc] initWithContentsOfFile:[self filePath:ADDRESSES_FILE]];
[currentAddresses setObject:mac forKey:ip];
[Configuration Write:currentAddresses];
[currentAddresses release];
}
[self filePath:ADDRESSES_FILE] returns a string containing the full path of a file (ADDRESSES_FILE) located in the Documents. The file may not exist, in this case I want to just write an object to the dictionary and then write it down
the problem is that when i do setObject forKey it doesn't add anything to the dict (if i just do alloc init to the dict, it works fine, but i want to read the records from the file, if there are any, and replace/add a record by using the AddAddress function)