NSString 和 UITouch...到底发生了什么?

发布于 2024-09-13 11:35:27 字数 491 浏览 5 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静待花开 2024-09-20 11:35:31

造成此类问题的一个可能原因是“转换”释放得太早,因此被释放,并且您仍然保留对该内存位置的引用。然后另一个对象被分配在这个位置。

要调试此问题,请设置 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文