Created
January 12, 2012 10:40
-
-
Save roolo/1599797 to your computer and use it in GitHub Desktop.
Your First Mac App -- updateUserInterface reference issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
@class Track; | |
@interface AppDelegate : NSObject <NSApplicationDelegate> | |
@property (assign) IBOutlet NSWindow *window; | |
@property (weak) IBOutlet NSTextField *textField; | |
@property (weak) IBOutlet NSSlider *slider; | |
@property (strong) Track *track; | |
- (IBAction)takeFloatValueForVolumeFrom:(id)sender; | |
- (IBAction)mute:(id)sender; | |
- (void)updateUserInterface; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AppDelegate.h" | |
#import "Track.h" | |
@implementation AppDelegate | |
@synthesize track; | |
@synthesize window = _window; | |
@synthesize textField = _textField; | |
@synthesize slider = _slider; | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | |
{ | |
Track *aTrack = [[Track alloc] init]; | |
[self setTrack:aTrack]; | |
} | |
- (IBAction)takeFloatValueForVolumeFrom:(id)sender { | |
float newValue = [sender floatValue]; | |
[self.track setVolume:newValue]; | |
[self updateUserInteface]; | |
} | |
- (IBAction)mute:(id)sender { | |
[self.track setVolume:0.0]; | |
[self updateUserInterface]; | |
} | |
- (void)updateUserInterface { | |
float volume = [self.track volume]; | |
[self.textField setFloatValue:volume]; | |
[self.slider setFloatValue:volume]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment