2013-01-22 24 views
0

試圖將默認值傳遞給ViewController對象的實例。代碼編譯時沒有警告,我逐步查看了值,但是,當應用程序啓動UI上的值回到零時。就好像我創建了兩個不同的實例,但是對於我來說,無法確定爲什麼初始化值不是啓動的應用程序的一部分。這裏是實現和main.m代碼。任何幫助表示讚賞。UI不顯示來自初始化程序的值

#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]; 
} 

回答

2

這很可能是ViewController實際上是從您的AppDelegate.m文件實例化 - 檢查那裏。它可能只是發送標準的init消息,而不是你定製的消息。

我不認爲應該在調用UIApplicationMain之前創建ViewController。

+0

好的。我認爲這可能是一個序列的事情。我將研究AppDelegate方法。謝謝! – Mickey