I can’t figure out why the output of self.tmp is null.
Here is the code I use
[self.dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop)
{
NSMutableString *t = [NSString stringWithFormat:@"%@ - %@", key, obj];
[self.tmp appendString:t];
}];
NSLog(@"%@", self.tmp) --> print null;
tmp is declared as NSMutableString.
I can confirm that dict ivar contain data.
Because
self.tmpis itselfnil. You declared it, but do you ever set it or allocate it initially? The append will only work if the thing you’re appending to is an existing string.In Objective-C, you won’t see an error if you try the append to a
nilobject, you’ll only see the result you’re seeing, which is that nothing happened.Just before the code you post here, you might want to do this: