NSArray 到 CALayerArray
我有一个问题,我无法弄清楚发生了什么
我有一个表视图,并且我有一个名为 newsData 的属性。 我设置了一切并且工作正常! 然后在模拟器中我调用内存警告来查看应用程序如何工作。 我可以看到 tableview 正在被释放,当我回调 viewdidload 时,我可以看到这个数组现在是类 CALayerArray! 当我尝试访问它时,我的程序崩溃了!
到底是怎么回事? 感谢您的帮助。
I have a problem and I cannot figure out what is going on
I have a tableview and I have a property names newsData.
I setup everything and its working fine!
Then in the simulator I call memory warning to see how the app is working.
I can see that the tableview is being released and when I call back the viewdidload I can see that this array is now class CALayerArray!!!
When I try to access it my program crashes!
What is going on?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否在 viewdidload 调用中重新分配了 tableview?发布后,您需要执行此操作。您可能希望在释放 tableView 后将其设置为 nil,以避免崩溃(这仍然需要您在释放 tableView 后重新分配并初始化它!)
澄清:我的意思不是,您需要在释放后将任何对象设置为 nil释放了!但是释放它之后,你应该知道该对象已经被释放了!
Have you reallocated tableview within the viewdidload call? After you released it you need to do that. You might want to set your tableView nil after releasing it, in order to avoid the crashes (This still requires you to reallocate and initialize the tableView after you released it!)
Clearification: I dont mean, you need to set any object nil after you released it! But after releasing it, you should be aware of the object being already released!
根据代码的不同,造成这种情况的可能原因有很多。首先,当你说“我有一个表视图并且我有一个名为 newsData 的属性”时,我很困惑。
newsData
属于什么对象?您是否子类化了UITableView
,或者您的意思是这是您的UITableViewDataSource
的 ivar?什么是新闻数据?这听起来应该是一个
NSData
,但你是说它是一个NSArray
吗?您应该首先审核分配
newsData
的所有位置。在大多数情况下,我会说你将它分配给不返回 NSArray 的东西。我对此表示怀疑,因为 CALayerArray 是私有的。这看起来更像是您正在访问正在用于其他用途的内存。我会检查您的内存警告代码和viewDidUnload:
代码并运行静态分析器作为开始。There are many possible causes for this depending on the code. First, I'm confused when you say "I have a tableview and I have a property names newsData." What object does
newsData
belong to? Did you subclassUITableView
, or do you mean this is an ivar of yourUITableViewDataSource
?What is
newsData
? This sounds like it should be anNSData
, but are you saying that it's anNSArray
?You should first audit everywhere you assign
newsData
. In most cases I would say you're assigning it to something that does not return anNSArray
. I doubt that in this case becauseCALayerArray
is private. This looks more like you're accessing memory that's being used for something else. I would check your memory warning code and yourviewDidUnload:
code and run the static analyzer as a start.