CoreData 엔티티라는 이름 EntityOne
이 있고 두 가지 속성이 있습니다.
coreValue
유형 Int16
coreDate
유형NSDate
가져 오기 요청에서 핵심 데이터 항목에 액세스하고 값을 개별 배열에 추가하려고하면 줄에 오류가 나타납니다. coreDataValues.append(item.coreValue!)
let request = NSFetchRequest(entityName: "EntityOne")
let fetchResults = try context.executeFetchRequest(request) as! [EntityOne]
var coreDataDates = [NSDate]()
var coreDataValues = [Int16]()
for item in fetchResults {
coreDataDates.append(item.coreDate!)
coreDataValues.append(item.coreValue!)
}
다음을 시도하십시오.
item.coreValue!.shortValue
또한 사용하기 전에 안전하게 포장을 풀어야합니다.
if let value = item.coreValue {
coreDataValues.append(value.shortValue)
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다