触摸后立即EXC_BAD_ACCESS [英] EXC_BAD_ACCESS right after touchesBegan

查看:73
本文介绍了触摸后立即EXC_BAD_ACCESS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始了一个非常简单的项目来学习iOS编程,但是在touchesBegan之后我得到了 EXC_BAD_ACCESS .

I have started a very simple project to learn iOS programming, but I get EXC_BAD_ACCESS after touchesBegan.

您可以在此处从DropBox下载项目.

You can download the project from DropBox here .

我基本上有一个UIView子类,该子类应在用户触摸的任何地方绘制圆圈.

I basically have a UIView subclass that should draw circles wherever the user is touching.

非常简单,但我无法使其正常工作.

Very simple but I cannot make it work.

我们非常感谢您的帮助. 谢谢!

Any help is highly appreciated. Thanks!

编辑 原来问题出在touchesBegan:

    ts = [NSMutableSet setWithSet: [event touchesForView:self]];

我变成了:

    ts = [[NSMutableSet setWithSet: [event touchesForView:self]] retain];

推荐答案

为什么不使用ARC? :) 很好!您不保留您的ts集.注意,setWithSet:返回您的自动释放实例. (红色圆圈看起来很有希望:))

Why don't you use ARC??? :) Its good! You do not retain your ts set. Note, that setWithSet: returns you autoreleased instance. (The red circle looks promising :))

这篇关于触摸后立即EXC_BAD_ACCESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆