我正在为 iOS 7 更新应用程序。其中一项更改是切换到新的 drawInRect:withAttributes 函数而不是已弃用的 drawInRect:withFont... 这在 iOS 7 测试版上运行良好,但今天在升级到最新的 iOS 之后7版本,app崩溃上线:
[text drawInRect:theRect withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:fontSz], NSFontAttributeName, color, NSForegroundColorAttributeName, nil]];
随着消息:
*** -[NSStringDrawingTextStorage textContainerForAttributedString:containerSize:lineFragmentPadding:]: message sent to deallocated instance 0x187ed0f0
我尝试运行 Zombie 工具,这在我的代码中既没有分配也没有释放有问题的对象,这根本没有帮助。具体来说,我收到消息:
An Objective-C message was sent to a deallocated 'NSStringDrawingTextStorage' object (zombie) at address: 0x169edc50.
并且对象的 malloc/release 在调用者之下:
[NSStringDrawingTextStorage stringDrawingTextStorage]
我究竟做错了什么?