2012-05-03 45 views
0

我想獲取textfields文本,將其轉換爲int,並將其存儲在覈心數據整數32屬性中。我在這個過程中得到一個錯誤:如何檢索文本字段文本並將其作爲整數32存儲在覈心數據中?

Implicit conversion of 'int' to 'NSNumber' disallowed with arc 

這裏是我試過:

// trying to convert 
int intLength = [self.length.text intValue]; 

// trying to set the current garden attribute to the converted int 
self.currentGarden.length = intLength; 

我怎樣才能解決這個問題?

回答

3

NSNumber是一個對象,與int不同。嘗試使用構造函數創建NSNumber:

self.currentGarden.length = [NSNumber numberWithInt:intLength]; 
相關問題