#0 0x35a4e870 in ___forwarding___ ()
#1 0x359a9650 in _CF_forwarding_prep_0 ()
#2 0x3366cf94 in objc_retain ()
#3 0x33679be4 in objc_retainAutoreleasedReturnValue ()
#4 0x0010c094 in -[PlayScene ccTouchesEnded:withEvent:] at /Users/gregt/SCG/Projects/SpellTower - Base2.1rc0a_ncp/Base2.1rc0a_ncp/PlayScene.m:300
#5 0x359a63fc in -[NSObject performSelector:withObject:withObject:] ()
#6 0x000b5a34 in -[CCTouchDispatcher touches:withEvent:withTouchType:] at /Users/gregt/SCG/Projects/SpellTower - Base2.1rc0a_ncp/Base2.1rc0a_ncp/libs/cocos2d/Platforms/iOS/CCTouchDispatcher.m:313
#7 0x000b60be in -[CCTouchDispatcher touchesEnded:withEvent:] at /Users/gregt/SCG/Projects/SpellTower - Base2.1rc0a_ncp/Base2.1rc0a_ncp/libs/cocos2d/Platforms/iOS/CCTouchDispatcher.m:366
#8 0x000b37a0 in -[CCGLView touchesEnded:withEvent:] at /Users/gregt/SCG/Projects/SpellTower - Base2.1rc0a_ncp/Base2.1rc0a_ncp/libs/cocos2d/Platforms/iOS/CCGLView.m:349
Ah. Yep. I figured something like that was happening.
So the ChipmunkMultiGrab is retaining the shape that is grabbed, but the shape does not retain it's .data property to avoid retain cycles. It's just an assigned property since the idea is that whatever you put in the .data property probably has a retained reference to the Chipmunk object. When the BasicCrate object is removed from the game, it's being deallocated since you are removing all of the retained references to it. Then when you release your finger, you are attempting to access the deallocated object. This is a pretty common problem when working with Objective-C's retain counting. You sort of have to design around it.
I think the simplest possible solution is to keep an array of the game objects you are dragging to retain them. Add the game object (to be clear, the BasicCrate and not the shape) to the array in touchesBegan, and remove them in touchesEnded. You could also avoid removing objects where .beingDragged is true if that doesn't break your gameplay.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Thanks so much for your clear help. The dragging array is how I'll go.
Regarding the other problem I had, with the cpHardAssert; if I disable that should I just return nil if the _grabs array is empty?
It's a kids game I'm making, and I don't want a crash if they have their hands all over it during a scene transition, which I know is likely from my own kids.
Thanks again for the help you have already provided many times.
Bringing up my own old thread, I am now having issues with multi touch when my play tester kids grab a shape with two fingers,when they let go and the object was removed as a result, and removed from my array of grabbed objects, I crash on the second touch going through.