Re: Newbies: Completed Cocoa project available for download
Re: Newbies: Completed Cocoa project available for download
- Subject: Re: Newbies: Completed Cocoa project available for download
- From: Jonathon Mah <email@hidden>
- Date: Thu, 20 Oct 2005 23:57:47 +0930
Hi Steve,
On 2005-10-20, at 15:05, Steve Weller wrote:
I have been learning Cocoa in my limited spare time and blogging my
progress. Recently I finished a project and have posted the
complete project source anyone to download.
Congratulations! As a mildly-experienced Cocoa hacker (5 years on and
off in my spare time), I thought I'd take a look and see if I could
give you any advice. I didn't go through it extensively, but here's a
quick list of what I came up with:
First of all, your Xcode project refers to credits.rtfd which is in a
separate folder (apparently in your Sites folder). This should be
fixed to point to the file in the project directory, or people who
download it will get build errors.
You don't use any localized strings. I know it's mainly a toy app,
but it's a good habit to get into. Search for NSLocalizedString if
you want more info.
In BTBagelturfNumberFactory, you specify the delegate methods in
comments. The more conventional way to do this is to put them in a
category, like so:
@interface NSObject (BTBagelturfNumberFactoryDelegate)
-(void)calculationDidStart:(id)caller;
// etc.
@end
This will stop the "may not respond" warnings, too.
Still in BTBagelturfNumberFactory: On line 132, you're alloc-initing
an NSLock, and then retaining it. This extra retain is unnecessary,
and will also lead to the lock leaking. And in the -dealloc method,
it's good form to release your own stuff before calling [super
dealloc]. Someone probably has a contrived example of bad things when
you call super first. And your -isCalculating method is empty (has a
semicolon after it, and also it just returns NO). Should this be the
case?
You're using NSString to store numbers and booleans often. NSNumber
is far more appropriate, if these need to be objects.
Things in MyDocument: You can set the "Display When Stopped"
attribute on the progress bar instead of manually managing its
visibility. The pop-up menus conventionally display ascending values
downwards, not upwards. Also with your pop-up menus, you're having
them call actions when they're changed. Since you're also using
bindings this is unnecessary -- you can move that code into -
setChosenOrder:, for example.
StringToBoolTransformer: Watch out here, one method returns either an
NSNumber or a BOOL!
And finally, NSLog itself takes a format string. Instead of:
NSLog([NSString stringWithFormat:@"Base chosen: %@",choicestring]);
use:
NSLog(@"Base chosen: %@", choicestring);
OK, that's all I had. :) Well done with this, and best of luck with
your future projects!
Jonathon Mah
email@hidden
_______________________________________________
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