首页 > 代码库 > exc_bad_instruction(code=EXC_I386_INVOP,subcode=0x0) 错误
exc_bad_instruction(code=EXC_I386_INVOP,subcode=0x0) 错误
对象存储异常
对象存储要遵守NSCoding协议
<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #d12f1b } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #4f8187 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ba2da2 } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008400 } p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px "PingFang SC"; color: #008400 } p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000 } p.p7 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; min-height: 13.0px } span.s1 { color: #78492a } span.s2 { } span.s3 { color: #ba2da2 } span.s4 { color: #000000 } span.s5 { color: #703daa } span.s6 { font: 11.0px Menlo } span.s7 { color: #3e1e81 } span.s8 { color: #4f8187 } span.s9 { color: #d12f1b }</style>
#import "EmotionModel.h"
@interface EmotionModel()<NSCoding>
@end
@implementation EmotionModel
/**
*当一个对象要归档进沙盒中时,就会调用这个方法
*目的 在这个方法中说明这个对象的哪些属性要存进沙盒
*/
- (void)encodeWithCoder:(NSCoder *)enCoder{
[enCoder encodeObject:self.chs forKey:@"chs"];
[enCoder encodeObject:self.code forKey:@"code"];
[enCoder encodeObject:self.png forKey:@"png"];
}
/**
当从沙盒中解档一个对象时(从沙盒中加载一个对象时)就会调用这个方法
目的:在这个方法中说明沙盒中的属性该怎么解析(需要取出哪些属性)
*/
-(id)initWithCoder:(NSCoder *)decoder{
if(self = [super init]){
self.chs = [decoder decodeObjectForKey:@"chs"];
self.code = [decoder decodeObjectForKey:@"code"];
self.png = [decoder decodeObjectForKey:@"png"];
}
return self;
}
@end
exc_bad_instruction(code=EXC_I386_INVOP,subcode=0x0) 错误