简体   繁体   中英

How to store an array of String with Core Data in SwiftUI?

I'm trying to understand which is the good way (and suggested by Apple) for storing an array of String ([String]) using the framework Core Data with SwiftUI.

I haven't found any clear documentation about.

For what I saw, I should create an attribute of type Transformable and then set the "Custom Class" to [String]

在此处输入图像描述

在此处输入图像描述

But then I start to see some warnings at build time:

warning: Misconfigured Property: Wine.pairings is using a nil or insecure value transformer. Please switch to NSSecureUnarchiveFromDataTransformerName or a custom NSValueTransformer subclass of NSSecureUnarchiveFromDataTransformer

So, I'm wondering that maybe this is not the good approach.

核心数据模型截图

If you put NSSecureUnarchiveFromData into the Transformer field (the one above custom class in your data model) the warning goes away

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM