They changed some things with Xcode 4, so I was wondering if I needed to initialize an NSSet by
NSMutableSet *variablesUsed = [NSMutableSet set];
or is
NSMutableSet *variablesUsed;
sufficient? Or does the second option initialize to nil? Is that the same as empty set?
Thanks for your help!
If you just use
NSMutableSet *variablesUsed;then you will get a pointer which is set toniland therefore will not be pointing to any kind of set.nilmeans that it is set to nothing, and is not the same thing as an empty set. You will get no functionality out ofnilso you will then need to set variablesUsed to some “real” set in order to make much use of it.When you use
NSMutableSet *variablesUsed = [NSMutableSet set];orNSMutableSet *variablesUsed = [[NSMutableSet alloc] init];you are setting the pointer to a brand new, empty set which has been initialized and is ready to use.