Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

adfriedm

macrumors newbie
Original poster
Dec 28, 2011
1
0
I'm quite new to objective-C and come from Java and C++, so I am not too comfortable with the NSAutoreleasePool yet (if this is related to that). The error I'm getting is EXC_BAD_ACCESS. Anyway:
Code:
myController.h:

#import <Cocoa/Cocoa.h>
@interface myController : NSObject {
    IBOutlet NSButton *PlayPauseLabel;
	
	// Script stuff
	NSAppleScript* getPlayerStateScript;
	
	NSString* playerState;
}
- (IBAction)backPress:(id)sender;
- (IBAction)forwPress:(id)sender;
- (IBAction)plPaPress:(id)sender;
@end


myController.m:

#import "myController.h"

@implementation myController

- (void)awakeFromNib {
	getPlayerStateScript = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:@"tell application\"iTunes\"\n return player state as string\n end tell"]];	
	playerState = [[getPlayerStateScript executeAndReturnError:nil] stringValue];
	
	NSLog (@"%@", playerState); // This works
}

- (IBAction)backPress:(id)sender {
	NSLog (@"%@", playerState); // This doesn't work
}
...
Any help would be greatly appreciated
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.