0
之外我有這個appdelegate.h的iOS,無法委託viewDidLoad中
與.m文件
@synthesize name;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[email protected]"john";
return YES;
}
現在...我想從另一個控制器得到這個名字,如果我試圖把它裏面我的viewDidLoad方法,它的工作原理..
- (void)viewDidLoad
{
appDelegate *test= (appDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"%@", test.name);
}
,但如果我嘗試做同樣的事情在我的initWithNibName它只是沒有工作...
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
appDelegate *test= (appDelegate *)[[UIApplication sharedApplication] delegate];
NSLog(@"%@", test.name);
}
任何人都可以幫我嗎?這個問題讓我發瘋......
從哪裏調用'initWithNibName'即初始化您的視圖控制器?你有沒有調試過控制器嗎? – rishi
「沒有工作」=什麼? – borrrden
「沒有工作」=名稱沒有打印出來 – user486174