我有这个功能:
-(id)initWithCoder:(NSCoder *)decoder
{
self = [super init];
if (self) {
_smID = [[decoder decodeObjectForKey:@"_smID"]intValue];
_link = [decoder decodeObjectForKey:@"_link"];
_trigger = [decoder decodeObjectForKey:@"_trigger"];
_status = [decoder decodeObjectForKey:@"_status"];
_expiration = [[decoder decodeObjectForKey:@"_expiration"]intValue];
_timeFromRegistratio = [[decoder decodeObjectForKey:@"_timeFromRegistratio"]intValue];
_timeFromSubsription = [[decoder decodeObjectForKey:@"_timeFromSubsription"]intValue];
_timeFromLastOpening = [[decoder decodeObjectForKey:@"_timeFromLastOpening"]intValue];
_timeToTrigger = [[decoder decodeObjectForKey:@"_timeToTrigger"]intValue];
}
return self;
}
当我之前打印对象时return self;
。但是当它返回到调用行时,对象已经消失了。这是调用线路:
SMBase *oldMonkeySurvayRule = [[NSKeyedUnarchiver unarchiveObjectWithData:oldMonkeySurvayRuleData]retain];
我收到了这个错误:
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x60000008
0x0449709b in objc_msgSend ()
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off"
Evaluation of the expression containing the function (_NSPrintForDebugger) will be abandoned.
这是.h:
@interface SMBase : NSObject{
NSString *_status;
NSString *_trigger;
int _expiration;
int _timeFromRegistratio;
int _timeFromSubsription;
int _timeFromLastOpening;
int _timeToTrigger;
int _smID;
NSString *_link;
}
@property (nonatomic, strong) NSString *status;
@property (nonatomic, strong) NSString *link;
@property (nonatomic, strong) NSString *trigger;
@property (nonatomic,assign)int expiration;
@property (nonatomic,assign)int timeFromRegistratio;
@property (nonatomic,assign)int timeFromSubsription;
@property (nonatomic,assign)int timeFromLastOpening;
@property (nonatomic,assign)int timeToTrigger;
@property (nonatomic,assign)int smID;
留存不够?