Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am attempting to build an app that allows a user to press a button that says "Play DVD" and it will then launch DVDPlayer.app. I know the best way of doing this is by using NSWorkspace and launchApplication but my problem is getting the button to recognize the command. How do I get the button to work?

Here is the code that I have so far:

dvd.m

#import "dvd.h"

@implementation dvd


- (BOOL)openDvd{
    [[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/DVDPlayer.app"];
    return TRUE;
    }

@end

dvd.h

#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#import <cocoa/Cocoa.h>
#import <ApplicationServices/ApplicationServices.h>

@interface dvd : NSObject

- (BOOL)openDvd;

@end

Any help would be greatly appreciated. Thanks in advance.

share|improve this question
I'm sorry, but programming questions are off topic for Ask Different. I suggest asking on Stack Overflow – Kyle Cronin Feb 8 '12 at 17:43

closed as off topic by Kyle Cronin Feb 8 '12 at 17:42

Questions on Ask Different are expected to relate to Apple hardware or software within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

I don't see any connection to the button in your code. Your method lacks an IBAction, so it isn't hook up directly. Did you connect it in Interface Builder?

share|improve this answer
Yes, the IBAction is set up in the AppDelegate and connected in the Interface Builder. – Stevezie Feb 8 '12 at 15:47
Can you show the AppDelegate method? – colbadhombre Feb 8 '12 at 17:21
Sure it is now in the body of the question. – Stevezie Feb 8 '12 at 18:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.