After following code uses the arc, when switching views will complain: progran received signal: "exc_bad_access"
After closing arc, normal switch, I ask what is the problem, where a mistake? Please enlighten us, thank you
- (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
{
self.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
/ / Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
/ / Generate the various view controllers
a * aa = [[a alloc] init];
b * bb = [[b alloc] init];
c * cc = [[c alloc] init];
d * dd = [[d alloc] init];
e * ee = [[e alloc] init];
/ / Add an array
NSArray * controllerArray = [[NSArray alloc] initWithObjects: aa, bb, cc, dd, ee, nil];
/ / Create the UITabBarController controller
UITabBarController * tabBarController = [[UITabBarController alloc] init];
/ / Set the delegate
tabBarController.delegate = self;
/ / Set UITabBarController controller viewControllers property to our previous generation array controllerArray
tabBarController.viewControllers = controllerArray;
/ / Default to select the first one the View tab (index starts at 0)
tabBarController.selectedIndex = 0;
/ / Read
UIViewController * activeController = tabBarController.selectedViewController;
if (activeController == aa) {
/ /
}
/ / Add the tabBarController of view as a subview to the window
[Self.window addSubview: tabBarController.view];
/ / Custom buttons
/ * NSMutableArray * customzableViewControllers = [[NSMutableArray alloc] init];
[CustomzableViewControllers addObject: musicList];
[CustomzableViewControllers addObject: currentPlay];
[CustomzableViewControllers addObject: favourite];
tabBarController.customizableViewControllers = customzableViewControllers;
tabBarController.customizableViewControllers = nil;
* /
/ /
/ / [MusicList release];
/ / [CurrentPlay release];
/ / [Favourite release];
/ / [SingerList release];
/ / [Settings release];
[Self.window makeKeyAndVisible];
return YES;
}
Reply:
arc? Please explain.
This error is caused by an object early release of.
Read a few posts, could not help popularize: release and autorelease
When managed to create their own objects completely destroyed release ---- self-control.
Unable to manage their own autorelease ----- objects can be created, destroyed uncontrolled.
As to why, not in this to say, access to relevant information.
Reply:
exc_bad_access
Upstairs positive solution. . . Where do you see the memory problems
There, it is recommended to use XIB link UITabbarController issues better.
Reply:
That found the problem, arc will UITabBarController advance release out, as long as it is defined in the h file solved, ha ha,
Thanks 2
No comments:
Post a Comment