创build一个与NSJSONSerialization dataWithJSONObject一起使用的对象:options:error:
目前为了使用这个function,我把我的对象“转换”成一个字典。 即属性名称成为键,属性值成为值。
有没有办法正确做到这一点,使一个对象将与此function?
即类似于encodeWithCoder
和initWithCoder
用于NSUserDefaults
。
我想做…
NSData *data = [NSJSONSerialization dataWithJSONObject:myObject options:0 error:nil];
此刻我做了一些像…
NSData *data = [NSJSONSerialization dataWithJSONObject:[myObject dictionaryRepresentation] options:0 error:nil];
看看JSONCoding ,它build立在带NSCoding接口的NSJSONSerialization上。
- 使用变换旋转时调整UIView的大小
- 如何在Visual Studio 2015中设置OAuth以使用Google身份验证
- 如何合并/合并2个图像到1
- 将Core Data与JSON API同步的最有效方法是什么?
- 如何使用UIImagePickerControllerDelegate在viewDidLoad上启动相机?
- 如何使用iOS 12 Cydia越狱
- Swift 4.2无法将类型’(UIImagePickerController.InfoKey).Type’的值转换为预期的参数类型’UIImagePickerController.InfoKey’
- dynamic图标iOS
- 如何在iPhone上录制用户生成的声音输出