我剛剛開始與迅速和核心數據。我有一個實體invoiceList並創建了一些屬性(一些字符串,整數32和十進制)。Swift與核心數據
我創建了一個編輯/添加視圖 - 控制,但現在我堅持附加的newitem部分。我收到錯誤「無法將字符串類型的值分配給類型爲NSNumber的值?」
我已經嘗試了不同的方式來投增值稅文本框爲INT但沒有成功。
我試圖
var invoiceVATString = nItem.valueForkey("invoiceVAT") as String
invoiceVATString = vat.text
這裏的newitem FUNC
func newItem(){
let context = self.context
let ent = NSEntityDescription.entityForName("invoiceList", inManagedObjectContext: context)
let nItem = InvoicesList(entity: ent!, insertIntoManagedObjectContext: context)
nItem.invoiceShopName = shopName.text
nItem.invoiceDescr = productDescription.text
nItem.invoiceVAT = vat.text<-cannot assign a value of type string? to a value of type NSNumber?
nItem.invoiceNumber = orderNumber.text<-cannot assign a value of type string? to a value of type NSNumber?
}
現在我知道invoiceVAT是一個核心型小數和還原數據屬性是一個文本框。我怎樣才能解決這個問題?
檢索一個NSNumber的一個簡單的例子?一些增值稅號碼包含字母,順便說一句。 – Aderstedt
對於invoiceVAT,我只需要數字和句點。 供參考:我想我已經命名它錯了,我的意思是bruto和netto的區別 – alex