I have an NSDictionary with NSStrings
Some of the valueForKey:@"Key" have no entry so it's (null)
NSMutableString* addressDictionaryToString = [NSMutableString string]; // use mutable string!
for (NSDictionary* item in address) { // use fast enumeration!
[addressDictionaryToString appendFormat:@"%@, %@, %@, %@",
[item objectForKey:@"Street"],
[item objectForKey:@"City"],
[item objectForKey:@"State"],
[item objectForKey:@"ZIP"]
];
NSLog(@"MutableString: %@", addressDictionaryToString);
}
So I want to build an NSMutableString but filter out those keys that are null. Any ideas?
UPDATE:::::
Basically I want my resulting String to look like
1 Infinite Loop, Cupertino, CA, 95014 (IF all fields are available)
If Im missing the Street then
Cupertino, CA, 95014
If I'm missing the State then
1 Infinite Loop, Cupertino, 95014
If I only have the state then it should print
CA
(notice that there are no commas on the last element)