Re: Function overloading for ObjC classes
Re: Function overloading for ObjC classes
- Subject: Re: Function overloading for ObjC classes
- From: Ondra Cada <email@hidden>
- Date: Sun, 22 Feb 2004 11:44:52 +0100
On Sunday, Feb 22, 2004, at 08:00 Europe/Prague, Jens Bauer wrote:
B: Make one function, that checks if it's a NSData * or a
NSMutableData class.
C: Make one function that does not check anything, but uses a resonable
common interface. Implement this interface in each class a different
way using a category. That is, so far as I know, the cleanest and most
object oriented way to do such things.
Whilst argument type-based overloading like C++ does is just plain
wrong in most situations--consider
NSData *d=[NSMutableData dataWith...];
yourFunction(d); // this is definitely not what you wanted!
the runtime checks like isKindOfClass are no winner too. Also beware
the immutable and mutable class clusters are often indistinguishible
due to their CoreFoundation entrails!
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.