On 22 Jan 2013, at 21:27, Jens Alfke wrote:


On Jan 22, 2013, at 10:15 AM, Dave <d...@looktowindward.com> wrote:

This has to work with classes that exist already as well as classes that don't. If initWithManager is defined in the class in question "knows" what it is being called like this, if not then it defaults to the regular NSObject init.

For instance it could be NSString or NSArray that is the class, in which case it won't have "initWithManager" so it calls init instead.

That will still work fine with protocols. NSString doesn’t implement your protocol, so your code skips the custom init and just calls -init instead.

If you don’t believe us, then try typing in and compiling the examples people have given, and experiment with them until you’re convinced. But this thread is kind of going around in circles, with you asking us for advice and then not accepting it.


I just wanted rid of the warning which I have, so I'm happy. I tried with the protocols etc. but it makes the method very messy and I have to double up on local variables etc. The fact is that it's a one parameter method that accepts an id and returns an id. If someone did define "initWithManager" on a class then it's likely to match the method pattern anyway, so it probably wouldn't help stop problems like that occurring anyway, and I'm not defining the classes that have the "initWithManager" method in them, so I can't define the class as conforming to a protocol.

Bottom line, it works as it is and it isn't that fragile, so it ain't broke and ain't likely to break then leave it alone is my motto.

Thanks a lot for all your help
All the Best
Dave


_______________________________________________

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

Reply via email to