iphone - EXC_BAD_ACCESS (code=2, address=0x3) -
hi getting following error code:
exc_bad_access (code=2, address=0x3)
when press play looped cfretain.
i can't figure out what's problem this.
xcode pointing @ line:
[nsdictionary dictionarywithobjectsandkeys:[self getcorrectname:oldcontroller], @"viewcontroller", sec, @"duration", nil];
i checked both values of dictionary , seem check out.
- (nsstring *)getcorrectname:(uiviewcontroller *)viewcontroller { if (viewcontroller.class == [uinavigationcontroller class]) { uiviewcontroller *vc = [viewcontroller.childviewcontrollers objectatindex:0]; return nsstringfromclass(vc.class); } else { return nsstringfromclass(viewcontroller.class); } } # pragma mark - uitabbarcontrollerdelegate - (bool)tabbarcontroller:(uitabbarcontroller *)tbcontroller shouldselectviewcontroller:(uiviewcontroller *)viewcontroller { // tracking controller clicked [[mixpanel sharedinstance] track:@"tab_clicked" properties:[nsdictionary dictionarywithobjectsandkeys: [self getcorrectname:viewcontroller], @"viewcontroller", nil]]; // tracking how long spent on last controller uiviewcontroller *oldcontroller = [self.childviewcontrollers objectatindex:self.selectedindex]; if (viewcontroller != oldcontroller) { nstimeinterval secondsbetween = [self.start timeintervalsincenow]; nsinteger sec = -1 * (secondsbetween + 0.5); // round , down if (sec > 0) { nslog(@"changing controllers %@, %d seconds", [self getcorrectname:oldcontroller], sec); [nsdictionary dictionarywithobjectsandkeys:[self getcorrectname:oldcontroller], @"viewcontroller", sec, @"duration", nil]; /* [[mixpanel sharedinstance] track:@"tab_viewed" properties:[nsdictionary dictionarywithobjectsandkeys: [self getcorrectname:oldcontroller], @"viewcontroller", sec, @"duration", nil]]; */ self.start = [nsdate date]; } } return yes; }
any ideas?
nsinteger not class.
use nsnumber
Comments
Post a Comment