I’ve got the following code where program is an NSArray with NSNumber objects and NSString objects. After the code executes, even though I’ve confirmed that the second if condition is satisfied at at least once (when [obj isKindOfClass:[NSString class]] is true), the NSMutableSet variables is completely empty.
NSMutableSet *variables;
if ([program isKindOfClass:[NSArray class]]) {
for (id obj in program) {
if ([obj isKindOfClass:[NSString class]]) {
[variables addObject:obj];
}
}
}
Why?
You are not creating a NSMutableSet
or more convenient
(thanks to dreamlax for reminding me)