• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
App Crashing when remove an Object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

App Crashing when remove an Object


  • Subject: App Crashing when remove an Object
  • From: Mario Gajardo Tassara <email@hidden>
  • Date: Fri, 28 Mar 2008 21:37:46 -0400

Hi to all,

In a portion of code of my app (collision detection part) i need to remove an object from an array of objects,
when two distinct objects crashed i decrement a life counter, and if this is equal to zero the object must be destroyed, but when the counter
reach de zero and the object is destroyed my app crash. Some one can help me with this problem, here is the code, and thanks in advance:



for(i=0;i<[spritesGoodObjectsArray_ count];i++) {
for(j=0;j<[spritesBadObjectsArray_ count];j++) {

CGRect collisionRectWithEnemy;

collisionRectWithEnemy = CGRectIntersection([[spritesGoodObjectsArray_ objectAtIndex:i] returnSpriteRect_],
[[spritesBadObjectsArray_ objectAtIndex:j] returnSpriteRect_]);

if (!CGRectIsEmpty(collisionRectWithEnemy)) {

[[spritesGoodObjectsArray_ objectAtIndex:i] invertSpriteMovement];
[[spritesBadObjectsArray_ objectAtIndex:j] invertSpriteMovement];

[[spritesGoodObjectsArray_ objectAtIndex:i] decrementSpriteLife];


if([[spritesGoodObjectsArray_ objectAtIndex:index] returnSpriteLife_] == 0) {
[spritesGoodObjectsArray_ removeObjectAtIndex:index]; // here my app crash
}
}
}
}



Mario Gajardo Tassara email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: App Crashing when remove an Object
      • From: Andrew Farmer <email@hidden>
  • Prev by Date: Re: machine with null serial number?
  • Next by Date: Re: machine with null serial number?
  • Previous by thread: Re: fixed width of a pane in NSSplitView (solved)
  • Next by thread: Re: App Crashing when remove an Object
  • Index(es):
    • Date
    • Thread