- Joined
- Jun 3, 2011
- Messages
- 54
- Reaction score
- 0
- Points
- 6
Dear All
I am able to assign values to NSarray timeZoneNames defined in RootViewController.m from SimpleTableViewAppDelegate.m and then I can use 'timeZoneNames' inside RootViewController.m perfectly.
But When the same procedure I follow for SubTable.m (where Nsarray timevalue is defined), a null array is assigned in SubTable.m
Codes are :
SimpleTableViewAppDelegate.m
RootViewController.h is like:
And inside RootViewController.m ,
In above case, correct value is getting displayed.
While
SUbTable.h looks like:
and Inside SUbTable.m
And here value displayed is always 0.
Where exactly I am making the mistake? What should I do so that timevalue can be assigned in the same way timeZoneNames is assigned.
I am able to assign values to NSarray timeZoneNames defined in RootViewController.m from SimpleTableViewAppDelegate.m and then I can use 'timeZoneNames' inside RootViewController.m perfectly.
But When the same procedure I follow for SubTable.m (where Nsarray timevalue is defined), a null array is assigned in SubTable.m
Codes are :
SimpleTableViewAppDelegate.m
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
RootViewController *rootViewController = [[RootViewController1 alloc] initWithStyle:UITableViewStylePlain];
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
SubTable *sub = [[SubTable alloc] initWithStyle:UITableViewStylePlain];
NSArray *timeZones = [NSTimeZone knownTimeZoneNames];
rootViewController.timeZoneNames = [timeZones sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
NSArray *test_array = [[NSArray alloc] initWithArray:timeZones];
sub.timevalue = [test_array copy];
//NSLog(@"count is %d", [sub.timevalue count]);
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;
[aNavigationController release];
[rootViewController release];
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
RootViewController.h is like:
Code:
@interface RootViewController : UITableViewController {
NSArray *timeZoneNames;
}
@property (nonatomic, retain) NSArray *timeZoneNames;
@end
And inside RootViewController.m ,
Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"timezonesname count is %d", [timeZoneNames count]);
return [timeZoneNames count];
}
In above case, correct value is getting displayed.
While
SUbTable.h looks like:
Code:
@interface SubTable: UITableViewController {
NSArray *timevalue;
}
@property (nonatomic ,retain) NSArray *timevalue;
@end
and Inside SUbTable.m
Code:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"timevalue count is %d", [timevalue count]);
return [timevalue count];
}
And here value displayed is always 0.
Where exactly I am making the mistake? What should I do so that timevalue can be assigned in the same way timeZoneNames is assigned.