NSString 和 UITouch...到底发生了什么?
我的 NSString 出现错误。在我的一个 .m 文件中,我有一个名为 NSString 类型的“conversions”成员,在该类的方法中,该字符串被操作并添加到等等。好吧,当我尝试用另一种方法记录该字符串时,稍后调用,由于某种原因,该字符串被打印为 UITouch 对象。具体来说,我尝试按如下方式记录字符串
NSLog(@"%@", conversions);
,并在我的控制台中打印
<UITouch 0x131700> phase: Ended tap count: 1 window: <UIWindow: 0x136470; frame = (0 0: 320 480) opaque = NO.....(and more property type stuff)
Why has my NSString gone into what like a UITouch object?到底是怎么回事?
I have an error with NSString. In one of my .m files I have a member called "conversions" of type NSString and within a method of that class the string is manipulated and added on to and etc. Well, when I try to Log that string in a different method that is later called, for some reason the string is printing as a UITouch object. Specifically, I try to log the string as follows
NSLog(@"%@", conversions);
and in my console it prints
<UITouch 0x131700> phase: Ended tap count: 1 window: <UIWindow: 0x136470; frame = (0 0: 320 480) opaque = NO.....(and more property type stuff)
Why has my NSString turned into what looks like a UITouch object? What is going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
造成此类问题的一个可能原因是“转换”释放得太早,因此被释放,并且您仍然保留对该内存位置的引用。然后另一个对象被分配在这个位置。
要调试此问题,请设置 NSZombieEnabled。它不会释放对象,而是用“僵尸”替换它们。例如,请参阅以下链接:
http://www. tomwhitson.co.uk/blog/2009/04/debugging-with-nszombiesenabled/
A likely cause for problems like these is that "conversions" got released too early, thus got deallocated and you were still holding a reference to that memory location. Then another object got allocated at this location.
To debug this, set NSZombieEnabled. It doesn't deallocate objects but replaces them with "zombies". See for example the following link:
http://www.tomwhitson.co.uk/blog/2009/04/debugging-with-nszombiesenabled/