簡體   English   中英

核心數據 + swift Int = 崩潰

[英]Core Data + swift Int = crash

在我的模型中,我有一個對象Object ,其屬性attributeInt類型。

這是 Object.swift 文件:

class Object: NSManagedObject {
  @NSManaged var attribute: Int
}

這是我使用它的地方:

let anInt: Int = 3
security.attribute = anInt

該代碼在 64 位設備上運行良好,但在 32 位設備上,由於無法識別的選擇器Object.attribute而崩潰。

解決辦法是在NSManagedObject對象中將該屬性標記為Int64

class Object: NSManagedObject {
  @NSManaged var attribute: Int64
}

並將IntInt64

let anInt: Int = 3
security.attribute = Int64(anInt)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM