Re: A good model header?
Re: A good model header?
- Subject: Re: A good model header?
- From: Chris Hanson <email@hidden>
- Date: Thu, 29 Jul 2004 19:20:28 -0700
On Jul 29, 2004, at 2:24 PM, Theodore H. Smith wrote:
@interface Frac : NSObject <NSCoding> {
double vTurn;
double vSquash;
NSDocument* Doc;
}
Your instance variables should follow the recommended naming
conventions.
<
http://developer.apple.com/documentation/Cocoa/Conceptual/
CodingGuidelines/index.html>
-(void)Draw : (CGContextRef)Ref;
-(double)Turn;
-(void)setTurn :(double) t;
-(double)Squash;
-(void)setSquash :(double) sq;
Your instance methods should follow the recommended naming conventions.
Also, the colon in methods that take arguments is part of the method
name, not part of the argument.
1) I've made it use NSCoding
This is what you should do to enable instances of your class to be
archived and unarchived.
2) It has accessor methods in case I ever want to script my app, or if
I want to make it undoable.
Or if you want to use bindings. Or if you want to use sort
descriptors. Or if you ever want to use key-value coding in any other
situation.
In particular you should be using your accessors *everywhere*,
including within your instance and class methods, so key-value
observing notifications are generated when necessary.
3) It has a reference to it's document (with which to access
NSUndoManager I think?)
You may or may not need this, depending on what your class represents.
If you need to access the document, or something owned by the document,
then maybe. Just be aware of object ownership when creating "back
links" like this so you don't get retain cycles.
-- Chris
--
Chris Hanson <email@hidden>
http://www.livejournal.com/users/chanson/
_______________________________________________
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.