So i spent the last hour or so fighting with my code, and eventually discovered that the NSSet I was trying to use was empty. Once I switched from the first line of code to the second, everything worked great. I was just hoping someone could tell me what is wrong with the first line. It compiles just fine, but apparently doesn’t do what I’m hoping for.
NSSet *singleOperandOperations = [singleOperandOperations initWithObjects: @"cos", @"sin", @"sqrt", nil];
v.s.
NSSet *singleOperandOperations = [NSSet setWithObjects: @"cos", @"sin", @"sqrt", nil];
Thanks!
setWithObjects:is a so called convenience constructor, which in fact does anallocand then aninitWithObjects:.setWithObjects:is just a little less typing. Note that the returnedidof such a convenience constructor isautorelease‘d, by convention.So your first example should be:
And this can be replaced by: