objective c - Variable return runtime error -


i making iphone app cocos2d , everytime try return variable function run time error on code below...

     gb2shapecache *cache = [gb2shapecache sharedshapecache];     //exc_bad_access run time error here     *eggfixture = [cache addfixturestobody:body forshapename:@"egg3"]; 

i don't know doing wrong... here code addfixturestobody...

-(b2fixture) addfixturestobody:(b2body*)body forshapename:(nsstring*)shape {     bodydef *so = [shapeobjects objectforkey:shape];     assert(so);     b2fixture *fixi;        fixturedef *fix = so->fixtures;     while(fix)     {         fixi = body->createfixture(&fix->fixture);         fix = fix->next;     }      return *fixi; } 

and here define variable eggfixture

b2fixture *eggfixture; 

and here try use b2fixture eggfixture later

for(pos = _contactlistener->_contacts.begin();          pos != _contactlistener->_contacts.end(); ++pos) {         mycontact contact = *pos;          if ((contact.fixturea == locations.platformfixture && contact.fixtureb == eggfixture) ||             (contact.fixturea == eggfixture && contact.fixtureb == locations.platformfixture)) {             nslog(@"ball hit bottom!");         }     } 

any help? thankyou :)

looks body nil. crash here when body nil:

fixi = body->createfixture(&fix->fixture); 

this article has tips debugging issues exc_bad_access.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -