views:

18

answers:

1

i have check by printing the value of the cell.textlable.text in each iteration of the loop each time the value of it is as i want, but as the time of output on the simulator the value is come same for each row of cell.

my code:
       for(i=0;i<[appDelegate.books count];i++)
    {

      Book *aBook= [appDelegate.books     
     objectAtIndex:i];

       NSString *string1 =aBook.Latitude;
        NSString *trimmedString = [string1     
          stringByTrimmingCharactersInSet:[NSCharacterSet    
          whitespaceAndNewlineCharacterSet]];   
     double myDouble = [trimmedString doubleValue];

     NSString *string2=aBook.Longitude;

     NSString *trimmedString1 = [string2 
          stringByTrimmingCharactersInSet:[NSCharacterSet 
       whitespaceAndNewlineCharacterSet]];  

   double mDouble = [trimmedString1 doubleValue];

    if((((myDouble<(a+5.021777))&&(myDouble>(a-  

            8)))||((mDouble<=(b+10))&&(mDouble>=(b-10)))))  
   {

     NSString *a1=aBook.AreaName;
       NSString *b1=[a1 stringByAppendingString:@","];
       NSString *s=aBook.STREET_NAME;
       NSString *c=[b1 stringByAppendingString:s];
     cell.textLabel.text = c ;

     }      
  }
    return cell; }
A: 

The problem is likely this line:

for(i=0;i<[appDelegate.books count];i++)

That's going to loop through every item in appDelegate.books. Assuming that that's an NSArray and that this code is inside your -tableView:cellForRowAtIndexPath: method, replace that line and the next with the following:

Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];

(This, of course, assumes that the row numbers match the index numbers in the array. If not, adjust to match.)

Jeff Kelley