iPhone NSMutableDictionary setObject forKey after initWithContentsOfFile

Posted by andrew on Stack Overflow See other posts from Stack Overflow or by andrew
Published on 2011-01-01T15:38:07Z Indexed on 2011/01/01 15:53 UTC
Read the original article Hit count: 214

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)

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c