Problem with cellForRowAtIndexPath method in UITableView iphone (indexPath.row is null)?

You are initializing your subviews in the if(cell== nil) block, but in the corresponding else block, you overwrite them again You should rethink your design: Do not load different views by searchon but set their properties depending on searchon if(cell == nil){ //do all initializing } if(searchon){ //set view/label properties for searching style } else { //set view/label properties for not-searching style } another approach could be to have totally separated NIB files for the searchon/! Searchon if(searchon){ static NSString *SearchOnCellIdentifier = @"SearchOnCell"; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier: SearchOnCellIdentifier; if (cell == nil){ //load cell from extra nib } } else { static NSString *SearchOFFCellIdentifier = @"SearchOFFCell"; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier: SearchOFFCellIdentifier; if (cell == nil){ //load cell from extra nib } } NOTE : I never did that and it is not tested.

You are initializing your subviews in the if(cell== nil) block, but in the corresponding else-block, you overwrite them again. You should rethink your design: Do not load different views by searchon, but set their properties depending on searchon if(cell == nil){ //do all initializing } if(searchon){ //set view/label properties for searching style } else { //set view/label properties for not-searching style } another approach could be to have totally separated NIB files for the searchon/! Searchon if(searchon){ static NSString *SearchOnCellIdentifier = @"SearchOnCell"; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier: SearchOnCellIdentifier; if (cell == nil){ //load cell from extra nib } } else { static NSString *SearchOFFCellIdentifier = @"SearchOFFCell"; UITableViewCell *cell = tableView dequeueReusableCellWithIdentifier: SearchOFFCellIdentifier; if (cell == nil){ //load cell from extra nib } } NOTE: I never did that and it is not tested.

Thanks viking..I took two different cell identifiers..so if the searchIsOn it points to one identifier else it points to another identifier..that solved the problem... – racharambola Aug 25 '10 at 20:48.

Contacts is a class which has the properties firstName,lastName and sugar id in it..I am assigning the properties of a contacts class to the variables in the database method and returning an array of contact objects. SearchResult is now an array of contact objects. The problem is when I logged the contents on the console the database gets everything in it and returns an array of contacts.

The contacts in the searchResult points to different memory locations but when I try to debug the cellForRowAtIndexPath method after it gets 6 contacts..the 7th contact points to the same memory location as the 1st and it repeats thus in the searchNameLabel. This happens only when I try to search for the contacts. It works fine when I try to load all the contacts onto the table..

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions