ios NSKeyedArchiver 释放 = 访问错误
我有一个菜鸟问题,我希望你能指出我正确的方向。基本上我有一个实现复制协议的自定义类。但是,当我在执行期间保存类时,我发布了自定义类,并且访问权限很差。我可以在仪器中看到保留计数为-2。我使用以下方法保存自定义类:
-(void)storeDataInFile:(NSString*)dataFileName DataArray:(NSArray*)dataToStore
{
//Get the path
NSString *path = [self pathToDocumentsForDataFile:dataFileName];
//Archive the file
[NSKeyedArchiver archiveRootObject:dataToStore toFile:path];
}
我是否使用该方法保存带有字符串的数组,它可以完美地工作。关于我的自定义课程,我应该更深入地研究什么?
问候
I have an noob problem and I would like you yo point me in the right direction. Basicly I have a custom class which implements the copying protocol. However when I save the class during execution the custom class i released and I get a bad access. I can see in instruments that the retain count is -2. I save the custom class with the following method:
-(void)storeDataInFile:(NSString*)dataFileName DataArray:(NSArray*)dataToStore
{
//Get the path
NSString *path = [self pathToDocumentsForDataFile:dataFileName];
//Archive the file
[NSKeyedArchiver archiveRootObject:dataToStore toFile:path];
}
Is I use the method sor saving a array with strings it works flawless. What should I look deeper into regarding my custom class?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了这个问题,但是我只在评论中提供了解决方案,该评论显然已被删除。所以我只是想发布答案,表明这是一个菜鸟错误。
从更早的测试实现中,我在类中有以下方法
这些方法破坏了我的保留计数:)
I soved this issue, however I only provided the solution in a comment which apprantly has been deleted. So I just wanted to post the answer which indicates it was a noob mistake.
From an eralier test implementation I had the following method in the class
These methods ruined my retain count :)