hey, I'm 13 years old and I've been learning iphone development. The problem is i have no one that can look at it and constructively help me. So i was wondering if one of you could help me get rid of errors for this code.
All my classes is attached as a .zip so check em out please and help me out. currently it won't even run.
P.S. this code belongs to me, the poster, and cannot be sold commercially
Warning: 'setImage:' is deprecated (declared at /developer/platforms/iphoneSimulator.pltform/developer/SDKs/iPhoneSimulator3.1.sdk/System/Library/Frameworks/UIKit.framework/header/UITableViewCell.h:200)
~these warning dont prohibit building and running but i'd like to know what they mean, they are in the .m of the viewcontrollers
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
//put all the views into this array that you want in the tab bar:
NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] init];
UINavigationController *navigationController;
//Create sales records view,navigation controller and add to array
FirstViewController *tableviewcontroller = [[FirstViewController alloc]
initWithStyle:UITableViewStyleGrouped];
navigationController = [[UINavigationController alloc] init];
navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
[navigationController pushViewController:tableviewcontroller animated:NO];
[tableviewcontroller release];
[tabBarViewControllers addObject:navigationController];
[navigationController release];
//Create view and add to array
FirstViewController *vc = [[FirstViewController alloc]
initWithNibName :nil bunle:nil];
[tabBarViewControllers addObject:vc];
[vc release];
//Create the tab bar controller and add the views you created above
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:tabBarViewControllers animated:NO];
[tabBarViewControllers release];
//Add the tab bar view to the window
[window addSubview:tabBarController.view];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
"Warning: Control reaches end of non void function"
This is caused by this function not returning a value, if a function is written to return a value ie the 1st enclosure, it must do so , in this case (NSInteger). So here you must return a integer that is the number of rows in the active section.
"warning: format not a string literal and no format arguments"
You dont need the NSString creation in a NSLog you can simply do this
NSLog(@"clicked index : %i",index);
3rd:
"warning: 'setImage:' is deprecated"
With 0S3.0 UITableCell.image is deprecated you should now use UITableCell.imageView.image.
This means it will still build but in a future OS version this call will be removed and it will stop working. Youll also see this warning on the cell.text line.
Thanks for the explanation, i don't understand where to add the UITableViewCell.imageView.image
Also, is there any way to fix the problem
Warning: Local declaration of 'navigationController' hides instance variables
it appears here
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
//put all the views into this array that you want in the tab bar:
NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] init];
UINavigationController *navigationController;
//Create sales records view,navigation controller and add to array
FirstViewController *tableviewcontroller = [[FirstViewController alloc]
initWithStyle:UITableViewStyleGrouped];
navigationController = [[UINavigationController alloc] init];
navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
[navigationController pushViewController:tableviewcontroller animated:NO];
//[tableviewcontroller release];
[tabBarViewControllers addObject:navigationController];
[navigationController release];
//Create view and add to array
FirstViewController *vc = [FirstViewController alloc] ;
//initWithNibName :nil bunle:nil];
[tabBarViewControllers addObject:vc];
[vc release];
//Create the tab bar controller and add the views you created above
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:tabBarViewControllers animated:NO];
[tabBarViewControllers release];
//Add the tab bar view to the window
[window addSubview:tabBarController.view];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
#1
in cellForRowAtIndexPath youre setting the cell.image= and cell.text=, these will need changing to cell.imageView.image= and cell.textLabel.text= to be compatible with later OS versions.
#2
"Warning: Local declaration of 'navigationController' hides instance variables"
this is beacuse you declare navigationController in the applicationDidFinishLaunching function:
UINavigationController *navigationController;
but you've already set navigationController to be a class instance property in the .h file, you cant have both, so just remove the above line and this will fix this.
thank you so much, that got rid of all the warnings, but "Warning control = end of non-void function. Also i get an error expected identifier '(' before = token
located in
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
//put all the views into this array that you want in the tab bar:
NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] init];
//UINavigationController *navigationController;
//Create sales records view,navigation controller and add to array
FirstViewController *tableviewcontroller = [[FirstViewController alloc]
initWithStyle:UITableViewStyleGrouped];
//here is where the error happens
navigationController = [[UINavigationController alloc] init];
navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
[navigationController pushViewController:tableviewcontroller animated:NO];
//[tableviewcontroller release];
[tabBarViewControllers addObject:navigationController];
[navigationController release];
//Create view and add to array
FirstViewController *vc = [FirstViewController alloc] ;
//initWithNibName :nil bunle:nil];
[tabBarViewControllers addObject:vc];
[vc release];
//Create the tab bar controller and add the views you created above
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:tabBarViewControllers animated:NO];
[tabBarViewControllers release];
//Add the tab bar view to the window
[window addSubview:tabBarController.view];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
i found by deleting the line in the header file and replacing it in applicationdidfinishlaunching, i was able to build and run with no errors. BUT it displays as a white screen in the Simulator. what do i do
Last edited by youngcoder; 10-24-2009 at 09:43 PM.
If you'd like to pm me the entire project Ill have a look at this tomorrow.
You seem to be hitting some quite simple beginners errors, are you working from scratch or from a book. I can highly recommend the Beginning iPhone 3 Development book if you're starting out, this will help you get the fundamental things right and you should then be able to make the app you want without all these errors.