• 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
Re: How to write a "function" in Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to write a "function" in Cocoa?


  • Subject: Re: How to write a "function" in Cocoa?
  • From: Scott Stevenson <email@hidden>
  • Date: Sat, 4 Nov 2006 01:28:09 -0800


On Nov 4, 2006, at 12:56 AM, Joel Norvell wrote:

//  MyRectUtilities.h

#import <Cocoa/Cocoa.h>
@interface MyRectUtilities
- (NSString *) rectString:(NSRect) rectBounds;

Since there are no instance variables involved, you should make this a class method or even just a simple C function.


In terms of style, you probably want to call it "stringFromRect". The first part of the method name should describe what is returned, and the last part should describe the parameter.

One of these would be good:

	@interface MyRectUtilities
	+ (NSString *) stringFromRect: (NSRect)rect;
	@end

	NSString * stringFromRect (NSRect rect);


Some tutorials on style:

	http://cocoadevcentral.com/articles/000082.php
	http://cocoadevcentral.com/articles/000083.php

Finally, it looks like your method does something different, but I assume you're aware of NSStringFromRect() in Foundation's NSGeometry.h?

Hope that helps,

   - Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: How to write a "function" in Cocoa? (From: Joel Norvell <email@hidden>)

  • Prev by Date: Re: How to write a "function" in Cocoa?
  • Next by Date: Re: How to write a "function" in Cocoa?
  • Previous by thread: Re: How to write a "function" in Cocoa?
  • Next by thread: Re: How to write a "function" in Cocoa?
  • Index(es):
    • Date
    • Thread