Apologies for a very basic question, but unfortunately one that I don't really know what keywords to search for an answer about.
Suppose I have two separate classes with init methods that have the same name, but which take different types. MyClassA has: -(id)initForCamera:(QICamera*)cam and MyClassB has: -(id)initForCamera:(PSCamera*)cam Then, when I do something like QICamera *cam; [[MyClassA alloc] initForCamera:cam]; I sometimes encounter compiler warnings saying for example: warning: incompatible Objective-C types 'PSCamera*', expected 'QICamera*' when passing argument 1 of 'initForCamera:' from distinct Objective-C type If instead I write: [(MyClassA*)[MyClassA alloc] initForCamera:cam]; then I do not get a warning. This leads me to believe that what I am writing is not actually doing anything wrong, and the compiler warning is associated with the fact that [MyClassA alloc] returns a plain id leaving the compiler to do some deducing about what the type actually is. This, combined with the confusion of having two methods (for different classes) with the same name but different parameter types, seems to be confusing things. One workaround is to include explicit casts like I have shown. However this leaves me wondering whether it goes against convention and/or recommendations to have two init methods with the same name but different parameter types, even for two unrelated different classes (hard to enforce - one could imagine completely different codebases colliding by chance in this respect). Can anybody comment on this? Thanks Jonny _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com