2011-10-17 105 views
-3

我試圖向我的視圖中添加一個類,並在此過程中設置NSNumber。然而,這個號碼一直返回爲空,我只是有點困惑,爲什麼。有人能幫助我嗎?如何將NSNumber從一個類別設置爲另一個類別

SelectionOptions* newClass = [[SelectionOptions alloc] initWithFrame:CGRectMake(140.0f, 80.0f, 620.0f, 610.0f)]; 


[self.superview addSubview:newClass]; 
[[self.superview.subviews lastObject] setMyNSNumber:[NSNumber numberWithInt:10]]; 

**從新類

的NSLog(@ 「檢查數量:%@」,myNSNumber);

+0

我們可以看看你是如何創建'newClass'對象的(至少我希望它是一個對象實例)?此外,您使用的代碼,以確定它「一直返回爲空」... – NSGod

+0

@NSGod請參閱上面 –

+1

爲什麼不''[newClass setMyNSNumber:[NSNumber numberWithInt:10]];'? – Nekto

回答

0

創建secondview一個號碼和爲此

secondclass.number = presentnumber;

相關問題