您好我从此代码中收到以下错误:
EXC_BAD_ACCESS (code=2, address=0x3)
当我按下播放时,我基本上回放了CFRetain。
我无法弄清楚这有什么问题。
XCode专门指向这一行:
[NSDictionary dictionaryWithObjectsAndKeys:[self getCorrectName:oldController], @"ViewController", sec, @"duration", nil];
我检查了字典的两个值,他们似乎结帐了。
- (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 which controller will be clicked
[[Mixpanel sharedInstance] track:@"tab_clicked"
properties:[NSDictionary dictionaryWithObjectsAndKeys:
[self getCorrectName:viewController], @"ViewController", nil]];
// Tracking how long was spent on the last controller
UIViewController *oldController = [self.childViewControllers objectAtIndex:self.selectedIndex];
if (viewController != oldController) {
NSTimeInterval secondsBetween = [self.start timeIntervalSinceNow];
NSInteger sec = -1 * (secondsBetween + 0.5); // round up and down
if (sec > 0) {
NSLog(@"Changing controllers from %@, %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;
}
有什么想法吗?
答案 0 :(得分:1)
NSInteger不是一个类。
使用NSNumber