• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Coding style question from ObjC newbie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coding style question from ObjC newbie


  • Subject: Coding style question from ObjC newbie
  • From: Michael Norris <email@hidden>
  • Date: Fri, 1 Nov 2002 10:02:24 +1300

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@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.

  • Next by Date: Re: metallized interface
  • Next by thread: Re: Coding style question from ObjC newbie
  • Index(es):
    • Date
    • Thread