Skip navigation.
 
mlCoding style question from ObjC newbie
FROM : Michael Norris
DATE : Thu Oct 31 22:02:24 2002

Hi folks

Just getting into ObjC from a C background. I'm finding most things
oddly intuitive, and refreshingly simple. I do have a question
relating to ObjC style, however.

I'm writing my first Cocoa app which takes a string off the
Pasteboard, does some text munging, and puts it back on. I'm looking
at using the OFRegularExpression object in the OmniFrameworks to help
out with the text munging. I'll need to add my own routine, however,
to do a search-and-replace.

In C, my routine would look something like:

(void) mungeText(NSString *mungeStr, NSString *findString, NSString
*replaceString)
{
  // munging code goes here
}

I was wondering whether in Objective-C it's better to:
1) define mungeText as an instance method of some new class of string
2) define mungeText as an instance method of my main app controller class
3) define mungeText as a new category of NSString
4) just leave mungeText as a C routine in a .c file

It seems to me that they'd all work (perhaps), but perhaps some ways
are more "elegant" than others, or more true to the spirit of MVC...

Any thoughts?
  -mike
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlCoding style question from ObjC newbie Michael Norris Oct 31, 22:02
mlRe: Coding style question from ObjC newbie Nicholas Riley Oct 31, 22:31
mlRe: Coding style question from ObjC newbie tonycate Nov 1, 04:37
mlRe: Coding style question from ObjC newbie Michael Norris Nov 1, 06:09
mlRE: Coding style question from ObjC newbie Jonathan E. Jackel Nov 1, 15:43