Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 核心数据&x2B;swift Int=崩溃_Ios_Swift_Core Data - Fatal编程技术网

Ios 核心数据&x2B;swift Int=崩溃

Ios 核心数据&x2B;swift Int=崩溃,ios,swift,core-data,Ios,Swift,Core Data,在我的模型中,我有一个对象object,其属性为attribute,类型为Int 以下是Object.swift文件: class Object: NSManagedObject { @NSManaged var attribute: Int } 这里是我使用它的地方: let anInt: Int = 3 security.attribute = anInt 代码在64位设备上运行正常,但在32位设备上,由于无法识别选择器对象。属性解决方案是在NSManagedObject对象中将属性

在我的模型中,我有一个对象
object
,其属性为
attribute
,类型为
Int

以下是Object.swift文件:

class Object: NSManagedObject {
  @NSManaged var attribute: Int
}
这里是我使用它的地方:

let anInt: Int = 3
security.attribute = anInt

代码在64位设备上运行正常,但在32位设备上,由于无法识别选择器
对象。属性

解决方案是在
NSManagedObject
对象中将属性标记为
Int64

class Object: NSManagedObject {
  @NSManaged var attribute: Int64
}
并将
Int
转换为
Int64

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

对,因为核心数据没有
Int
类型,所以它有几个整数类型,它们都有特定的大小。