EDITED
This is a very common problem I am facing during coding, please take a look at it.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
// Adding Landing screen landscape on mainwindow
self.landingViewController = [[LandingViewController alloc] initWithNibName:@"LandingViewController" bundle:nil];
[self.window addSubview:self.landingViewController.view];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
#import <UIKit/UIKit.h>
@class RecentPlanViewController;
@class ChevronViewController;
@interface LandingViewController : UIViewController
{
UINavigationController *navigationController;
// custom view controllers
RecentPlanViewController *recentPlanViewController;
ChevronViewController *chevronViewController;
}
- (void)popView:(NSNotification *)notification;
@property (nonatomic,retain) UINavigationController *navigationController;
@property (nonatomic,retain) RecentPlanViewController *recentPlanViewController;
@property (nonatomic,retain) ChevronViewController *chevronViewController;
@end
self.recentPlanViewController = [[RecentPlanViewController alloc] initWithNibName:@"RecentPlanViewController" bundle:nil];
[self.recentPlanViewController loadView]; // if I skip this : Memory to recentPlanViewController's IVs not allocated.
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.recentPlanViewController ];
#import <UIKit/UIKit.h>
@class RecentPlanCell;
@interface RecentPlanViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableView *recentPlanTableView; // Main recent TableView
RecentPlanCell *recentPlanCell;
IBOutlet UIButton *createPlanButton;
IBOutlet UIButton *viewAllPlanButton;
BOOL isViewingAllPlans; // Yes if view all plan pressed
}
@property (nonatomic,retain) RecentPlanCell *recentPlanCell;
@property (nonatomic,retain) IBOutlet UIButton *createPlanButton;
@property (nonatomic,retain) IBOutlet UIButton *viewAllPlanButton;
@end
There are two conclusions to above written code.
1.If I use loadView method. It calls out the view controller's view and allocate memory just to IBOutlets and doesn't do for other self.recentPlanViewController
Instance variables.
2.If I skip second line of code, it doesn't allocate memory to any IVR even after using it as rootVC.
Please guide me, what is the memory management concept I'm violating!
Thanks