Re: name that method!
Re: name that method!
- Subject: Re: name that method!
- From: Stig Brautaset <email@hidden>
- Date: Sat, 29 Sep 2007 09:55:10 +0100
Hi Guy,
Thank you for this detailed post. I find that it is a little bit
complicated for what I need right now, but I may go back and rework
it along the lines you suggest in the future should my needs change.
There's no reason why I couldn't keep backwards compatibility.
Stig
On 29 Sep 2007, at 01:20, Guy English wrote:
heh ... oops. Turns out the hotkey for send in Mail is the same
hotkey for Open Quickly in Xcode ... make sure you switch focus first!
Anyway:
Categories on NSString, NSDictionary, NSArray, etc
- (id) stringFromJSONRepresentation: (id) jsonRep;
- (id) dictionaryFromJSONRepresentation: (id) jsonRep;
- (id) arrayFromJSONRepresentation: (id) jsonRep;
For Mutable subclasses of the above just call the immutable version
then return an autoreleased mutable copy.
These just call into MyJSONRepresentation and check that the class
returned from - (id) objectFromJSONRepresentation is the right one.
Additionally on NSSString, since it's just convenient and matches
the plist stuff, I'd add:
- (id) objectFromJSONRepresentation;
You may want to add the mutability options that NSPropertyList does
if you require that.
Anyway I think that'll work well because people will be used to the
pattern, all your JSON code ends in one place (MyJSONSerialization)
and you can put the code for the categories on string, dictionary
and array in there too.
So that's my advice. This is very much bike shed territory though -
everyone's going to have an opinion on how to do it best. :)
Paint it green! ;)
--
http://code.brautaset.org
http://blog.brautaset.org
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden