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:
Any help would be greatly appreciated
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
}
...
Last edited by a moderator: