I am a new Programmer of Iphone….. i have a little problem in accessing the NSMuttable array in my programe…
i am generating a view programmatically on button click …. code on button click is
-(IBAction)buttonClicked
{
secondView=[[TabBarSearchSecondView alloc]init];
[myView addSubview:secondView.view];
}
inTabBarSearchSecondView .h file…..
@interface ......
NSMuttableArray *searchResult;
@end
@property (nonatomic,retain)NSMuttableArray *searchResult;
in TabBarSearchSecondView .m file………
@synthesize searchResult;
- (void)loadView
{
CGRect cgRct = CGRectMake(0.0, 0.0, 480, 320); //define size and position of view
myView = [[UIView alloc] initWithFrame:cgRct]; //initilize the view
//open database
DbOpenAndClose *dbObject=[[DbOpenAndClose alloc]init];
[dbObject openDatabase];
//for call of search showroom
SearchProduct *object=[[SearchProduct alloc]init];
searchResult=[object searchShowrooms:productname:cityname];
[dbObject closeDatabase];
count=[searchResult count];/// print 3 because 3 record match in database
UITableView *table=[[UITableView alloc]initWithFrame:CGRectMake(4,80,312,325) style:UITableViewStylePlain];
//table.delegate=self;
table.dataSource=self;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//NSLog(@"%i", [searchResult count]);
return [searchResult count]; ///Not accessible here...Application Crash Here...
}
thanks for giving your valueable time for my Code…… thanks in Advance
you have to retain the
searchResultarray….after this code
retain the
searchResult. otherwise it is released.. retain thesearchResultlike this.