EXC_BAD_ACCESS right after touchesBegan
I have started a very simple project to learn iOS programming, but I get EXC_BAD_ACCESS after
You can download the project from DropBox here .
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.
Turns out the problem is this line of code in
ts = [NSMutableSet setWithSet: [event touchesForView:self]];
That I changed into:
ts = [[NSMutableSet setWithSet: [event touchesForView:self]] retain];
3 Solutions Collect From Internet About “EXC_BAD_ACCESS right after touchesBegan”
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 :))
BAD_ACCESS errors are generally related to referencing objects that no longer exist (i.e. they were deallocated or they were autoreleased). Check for these issues inside
- Any incorrect placement of
releasecalls, when an object is still going to be used. Try commenting them out and see if the error is gone.
- Using autoreleased objects and not retaining them. Autoreleased objects are the ones created using the method names that refer directly to the class, like these:
[NSArray arrayWith...], instead of using
For further help, please try to include some code snippets for these methods.
- How to specify size for iPhone 6/7 customised edge-to-edge image?
- Mac OS X Lion Xcode problems using RVM
- 'Found an uxexpected Mach-O header code: 0x72613c21' when trying to export an archive to IPA.
- Round up a CGFloat in Swift
- How can I show alertview with activity indicator?
- Combinations of different NSArray objects
- Firebase on ios is slow in retrieving data
- MKMapItem with specific Location
- How to delete a class from realm file
- UIWebView loadHTMLString not working in iOS5
- Jailbroken iPhone 3G with iOS 4.2.1 can't be debugged with XCode
- Swift protocol defining class method returning self
- How to inherit animation properties while animating CALayer with implicit animation
- Can you override between extensions in Swift or not? (Compiler seems confused!)
- How to register a custom app opening URL scheme with Xcode 4?