0

Right now I am making a Facebook Application For iPad. I pulling the wall and putting it into a UITableView. The way I am putting photos into the tableview is like this:

In the requestDidLoad for querying for array of images.

-(void)request:(FBRequest *)request didLoad:(id)result {

 //Determine if result is a array of images
if ([result objectForKey:@"images"] != nil) {
    if ([request.url rangeOfString: @"=images"].location != NSNotFound) {
         realPicsonWall = result;
        NSLog(@"Result Object: %@", [result objectForKey:@"images"]);


    }      
} 

Then in cellForRowAtIndexPath:

  UITableViewCell *cell = [tableView 
                         dequeueReusableCellWithIdentifier:@"messageCell"];
imageCellData *imageCell = [tableView dequeueReusableCellWithIdentifier:@"imageCell"];
//imageCellData is custom cell.
if ([[objectTypes objectAtIndex:indexPath.row] isEqualToString:@"photo"]) {
    //this is a picture


     NSArray *imagesArray = [realPicsonWall objectForKey:@"images"];
    NSDictionary *imageProps = [imagesArray objectAtIndex:3];

    NSLog(@"imageprops source: %@", [imageProps objectForKey:@"source"]);
    [imageCell.imageview setImageWithURL:[NSURL URLWithString:[imageProps objectForKey:@"source"]]];


    [imageCell layoutSubviews];
    return imageCell;


}else if ([[objectTypes objectAtIndex:indexPath.row] isEqualToString:@"video"]) {
    //this is a video
    NSLog(@"Video Called");
     NSDictionary *fromDictionary = [globalWhoPosted objectAtIndex:indexPath.row];
    cell.textLabel.text = @"Videos Are Not Supported";
     cell.detailTextLabel.text = [NSString stringWithFormat:@"Video Posted By: %@", [fromDictionary objectForKey:@"name"]];
    NSLog(@"Video By: %@", [fromDictionary objectForKey:@"name"]);
    return cell;
} 
else {
    NSDictionary *fromDictionary = [globalWhoPosted objectAtIndex:indexPath.row];
    NSString *story = [messages objectAtIndex:indexPath.row];
    cell.textLabel.text = story;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"By: %@", [fromDictionary objectForKey:@"name"]];

    cell.alpha = 1;
    return cell;
}

return cell;
}

In numberOfRows:

{
   return [messages count];
}

There 2 different images in the wall I bring to pull, but It pulls 2 of the same images, so in the tableview I see the same image 2 times, while it is supposed to be 2 diff. images. Any help would very generous. Thanks.

virindh
  • 3,775
  • 3
  • 24
  • 49

1 Answers1

0

Do you have an example of a graphapi url for which this is the case? Probably what I would do is look for the all the images with the same dimensions. This would then lead to the assumption that if more than one image is in the json, rather than just different resolutions, if you grab those with the same resolutions, then you'll be guaranteed to grab those that are unique.

Andy Obusek
  • 12,614
  • 4
  • 41
  • 62
  • That didn't work, because as it says above, index at 3 is just it returning the dimensions of the image. – virindh May 30 '12 at 01:20
  • I have added the noumberofrowsCode – virindh May 30 '12 at 01:36
  • The json schema indicates my response is accurate – Andy Obusek May 30 '12 at 01:36
  • the json schema shows that [realPicsonWall objectForKey:@"images"] returns an array of image objects. Each object represents a different image. If this is not the case, please paste a copy of the sample json – Andy Obusek May 30 '12 at 01:38
  • It returns multiple sizes of the SAME image. – virindh May 30 '12 at 01:39
  • See [here](http://developers.facebook.com/tools/explorer/?method=GET&path=10150369820292147%3Ffields%3Dimages) for a sample JSON Response – virindh May 30 '12 at 01:40
  • Ohhh sorry! I finally understand your original the real issue here, well, the code is doing what it is documented to do, returns the user's single and only wall image. What else are you looking for? – Andy Obusek May 30 '12 at 01:42
  • What I need it to do is when there are multiple images on the wall, 2 of the tableView cells are these same image not 2 diff. image. – virindh May 30 '12 at 01:44
  • Is there any sample code for that??? That would be greatly helpful. I have stick on this issue for a week now, And unfortunately i don't have a sample graph API url. – virindh May 30 '12 at 01:48
  • The problem is that I have it so that it goes through a loop for which type of object each post is, then if it is an image I re-query graph for the images resolutions. – virindh May 30 '12 at 01:51