problem with ChipmunkSpace addBounds?

Discuss any Chipmunk bugs here.
Post Reply
mediamike
Posts: 3
Joined: Thu Jun 06, 2013 9:09 pm
Contact:

problem with ChipmunkSpace addBounds?

Post by mediamike »

I apologize if this is too simple a question - I just purchased a PRO license and don't have a lot of experience with Chipmunk. The following line of code:

[self.space addBounds:self.demoBounds thickness:10.0 elasticity:1.0 friction:1.0 layers:NOT_GRABABLE_MASK group:nil collisionType:nil];

worked fine with my non-pro libraries. Now, when I run I get the following error:

2013-06-06 22:18:20.720 ChipmunkTryPro[400:907] *** Terminating app due to uncaught exception 'NSArgumentError', reason: 'Attempted to add an object of type __NSArrayI to a ChipmunkSpace.'
*** First throw call stack:
(0x344d73e7 0x3c361963 0x344d7307 0xf5cfd 0xf6e0f 0xe8587 0xda34f 0xd067f 0xcf413 0x3c77b793 0x3c77e8c3 0x3c77b5db 0x3c77c48f 0x3c77ee07 0x344ab1b1 0x3441e23d 0x3441e0c9 0x37fd933b 0x3633a2b9 0xcea89 0xcdf50)
libc++abi.dylib: terminate called throwing an exception

I thought I would perhaps change the NSArray to something Mutable - maybe that was the problem. But unless I don't understand something, if this call is adding an NSArray it is doing it "beneath the sheets". Did something change that would have made this call acceptable in the past and problematic with a newer release?
User avatar
AndyKorth
Site Admin
Posts: 36
Joined: Wed Aug 15, 2007 3:56 pm

Re: problem with ChipmunkSpace addBounds?

Post by AndyKorth »

Hi Mike,

I think this is an issue that has been introduced recently in one of the new versions. NSArrays should implement ChipmunkObject, so they can be used as containers for the Chipmunk Object Protocol, but for some reason it doesn't seem to be working.

That's set up in ChipmunkObject.h.

We're figuring we'll have a fix for it either this weekend or Monday, when Scott is back from his trip. Sorry for the trouble!
mediamike
Posts: 3
Joined: Thu Jun 06, 2013 9:09 pm
Contact:

Re: problem with ChipmunkSpace addBounds?

Post by mediamike »

Ah, well - at least, thanks! Now I won't waste a few hours banging my head on the wall trying to figure out why I can't get it to work. I'll just keep developing with the trial version until it gets fixed.

-Mike
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: problem with ChipmunkSpace addBounds?

Post by slembcke »

Blah. So I think it's a linker settings problem. I made a category for NSArray to implement the ChipmunkObject protocol, but because the category is in a library it doesn't get linked in unless you have the right linker settings (which I thought were the default). Try adding -ObjC to your linker settings to see if that fixes the issue.

I'll have to implement it without using a category and do a small version bump.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: problem with ChipmunkSpace addBounds?

Post by slembcke »

Arg. Turns out it's even more complicated than that.

[NSArray arrayWithObjects:...] doesn't ACTUALLY return an NSArray. -_- I guess that ends up being a class cluster or something. I wonder if that changed in the iOS SDK recently. :-\ I've used it in the past a few times just fine. I guess I need to implement a subclass of NSArray that I return as an NSArray. How annoying.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: problem with ChipmunkSpace addBounds?

Post by slembcke »

Ok... Never mind my previous post. I was right originally and just confused myself when trying to reproduce the issue. :oops:

The correct flag is -ObjC (I had put -lobjc originally which was not correct). Adding it might cause you to get additional linker errors if you don't have the ImageIO.framework added to your project as well. I uploaded a fix where addBounds: returns a private subclass of NSArray that implements the ChipmunkObject protocol as well. So it should be linker error proof now.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
mediamike
Posts: 3
Joined: Thu Jun 06, 2013 9:09 pm
Contact:

Re: problem with ChipmunkSpace addBounds?

Post by mediamike »

-ObjC did the trick - Thanks!

MIke
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests