1

0131 - SwiftUI Drap & Drop

 7 months ago
source link: https://atjason.com/daily/2024-01-31.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

0131 - SwiftUI Drap & Drop

2024-01-31

| 每天写一点

看一遍接口文档:

尝试让 SwiftData @Model 支持 Codable、Transferable,但遇到很诡异的问题:在 encode 时,读取 Model 的属性时,直接卡死,无任何异常。

换了种方式,拖拽时传递的不是 Model,而是 PersistentIdentifier。接收方通过 ModelContext,使用这一 ID 拿到 Model。多了一个取的过程,也许会增加开销,但至少工作了。并且,Model 不需要做任何修改。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK