首页 > 解决方案 > Adding an array of HKWorkouts to UserDefaults

问题描述

Is there anyway to add an array of HKWorkouts to UserDefaults or do I have to save the array in core data?

标签: swifthealthkit

解决方案


HKObject and its subclasses conform to NSSecureCoding, so you can convert an array of them to Data using NSKeyedArchiver. See the NSKeyedArchiver documentation for more details.


推荐阅读