且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

NSMutableArray : 无法识别的选择器发送到实例

更新时间:2022-05-31 22:14:20

你需要保留 TGrid !否则,它会被自动释放池解除分配,并且可能会有一个 CALayer 在内存中占据它的位置!

You need to retain TGrid ! Otherwise, it will be deallocate by the autorelease pool and probably a CALayer takes its place in the memory !

***的选择是创建一个带有保留属性的属性并访问 self.TGrid最后别忘了释放(dealloc)

Best option being to create a property with retain attribute out of it and access self.TGrid Don't forget to release it at the end (dealloc)

编辑它被释放是因为每个实例创建者类方法都提供了 Autoreleased 实例(这是每个人都应该遵循的规则,Apple 在整个 SDK 中都遵循).

edit It is deallocated because every instance creator class method provides Autoreleased instance (that's a rule that everyone should follow and that Apple does follow in the whole SDK).