Re: @class
Re: @class
- Subject: Re: @class
- From: Andrew Farmer <email@hidden>
- Date: Sun, 23 Mar 2008 04:07:09 -0700
On 23 Mar 08, at 03:28, Audun Frøysaa wrote:
Hello.
I need some help with different controllers.
You seem confused. Is this your first Cocoa project? If so, have you
run through the CurrencyConverter tutorial?
I have
mainController.h & .m
iTunesMainController.h & .m
I then tries to access a method in the iTunesMainController from the
mainController.
First things first: How are these two objects instantiated? How are
they connected to each other? Simply declaring an instance variable
(as you do below) doesn't create an object.
Also, as a point of style, most Cocoa programmers use the convention
of capitalizing the first letter of class names to distinguish them
from variable names.
mainController.h
@class iTunesMainController;
@interface mainController : NSObject {
iTunesMainController *iTunes;
Per above, unless this is a stealth outlet, it never gets initialized.
mainController.m
#import "iTunesMainController.h"
- (void)applicationDidFinishLaunching:(NSNotification *)notification{
[iTunes setPlayMode:NO];
}
iTunesMainController.h i have this after the interface.
- (void)setPlayMode:(BOOL)mode;
iTunesMainController.m
- (void)setPlayMode:(BOOL)mode
{
BOOL stat;
if(mode == NO)
{
[[NSAppleScript alloc] initWithSource:@"tell application \"iTunes
\" to stop"];
stat = NO;
} else {
[[NSAppleScript alloc] initWithSource:@"tell application \"iTunes
\" to play"];
stat = YES;
}
}
This doesn't work at all.
You're creating NSAppleScript instances, initializing them with
scripts, and promptly leaking them. Surely you mean to be running
them, placing them in a variable, and/or releasing them?
Also, I'm not sure what you're doing with the stat variable here.
Setting its value within this function has no lasting effect._______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >@class (From: Audun Frøysaa <email@hidden>) |