On Oct 24, 2013, at 9:19 AM, Jerry Krinock <je...@ieee.org> wrote: > Starting somewhere after OS X 10.6, NSArray instances respond to the NSSet > method -allObjects. I can’t find any documentation of this. Also, it is not > declared in the header NSArray.h > > Although it does what you’d expect, returning a copy of self, this can lead > to some interesting bugs, particularly when running in 10.6 after testing in > a current system :( And in some cases one may want to reconsider the usual > strategy of preferring -respondsToSelector: instead of -isKindOfClass: for > introspection.
That is precisely why I dislike the -respondsToSelector: approach. You never know if you might accidentally call some undocumented method that you were unaware some class had. Either -isKindOfClass: or making a protocol containing -allObjects and making NSSet and other methods conform to it via categories seems safer in general. On Oct 24, 2013, at 9:56 AM, Roland King <r...@rols.org> wrote: > Depends what you want to do with introspection. If you want to ensure a class > responds to allObjects and you expect if it does it returns an NSArray, that > still works in this case It may work, but you're still calling private methods... :-/ Charles _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com