Ok, will try again. This format is pretty simple.
componentsSeparatedByString:
is the magic method you want. Use it to break the text string into an array for each line, and then break each line to access the lines key and value on each side of the =
.
- (NSDictionary*)dictFromConfigString:(NSString*)myTxtFileAsString {
NSMutableDictionary *result = [NSMutableDictionary dictionary];
NSArray *lines = [myTxtFileAsString componentsSeparatedByString:@"\n"];
for (NSString *line in lines) {
NSArray *pair = [line componentsSeparatedByString:@" = "];
NSString *key = [pair objectAtIndex:0];
NSString *value = [pair objectAtIndex:1];
[result setObject:value forKey:key];
}
return result;
}