Trying to pass default values to instance of ViewController object. The code compiles without warning and I step through and see values being set, however, when app launches the values on UI are back to zero. It’s as if I’m creating two distinct instances, but for the life of me can’t figure why initialized value are not part of launched application. Here’s implementation and main.m code. Any help is appreciated.
#import "AppDelegate.h"
#import <UIKit/UIKit.h>
#import "ViewController.h"
int main(int argc, char *argv[]) {
//NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
@autoreleasepool {
ViewController *viewController;
viewController = [[ViewController alloc]initWithBinauralFrequencyLeft:82.4
binauralFreqRight:82.4
octaveValue:1
baseScaleSetting:82.4
binauralBaseVolume:800
globalBaseSongCount:0];
int retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
//[pool release];
return retVal;
}
}
-(id)initWithBinauralFrequencyLeft:(double)binauralFreqL
binauralFreqRight:(double)binauralFreqR
octaveValue:(double)octaveVal
baseScaleSetting:(double)baseScaleSet
binauralBaseVolume:(int)binauralVolume
globalBaseSongCount:(int)globalSongCount;
{
self = [super init];
if (self){
[self setBinauralFreqL:82.4];
[self setBinauralFreqR:82.4];
[self setOctaveVal:1];
[self setBaseScaleSet:82.4];
[self setBinauralVolume:800];
[self setGlobalSongCount:0];
}
return self;
}
-(id)init
{
return [self initWithBinauralFrequencyLeft:82.4 binauralFreqRight:82.4 octaveValue:1 baseScaleSetting:82.4 binauralBaseVolume:800 globalBaseSongCount:0];
}
It’s likely that the ViewController is actually being instantiated from your AppDelegate.m file – check in there. It’s probably just sending the standard init message, rather than your customised one.
I don’t think the ViewController should be created before the call to UIApplicationMain.