I am trying to get the url of the first picture of an album. I am getting my data from a json webservice. This webservice looks like this.

```
  "albums": [

        {
            "name": "Club Brugge - KRC Genk",
            "date": "08.10.2012",
            "pic_album_id"  : 1
            "pictures": [
                {
                    "url": "http://www.krcgenk.be/images/gallery/album_199/800X600/1a06dc0e405fd0219e3d327f1eec7fbf.jpg",
"picture_id" : 1
                },
                {
                    "url": "http://www.krcgenk.be/images/gallery/album_199/800X600/e8e10c0664eb0533a0534ed69891b165.jpg"
"picture_id" : 2
                },
                {
                    "url": "http://www.krcgenk.be/images/gallery/album_199/800X600/750b55a87b8eae33b8f3278add9bec44.jpg"
"picture_id" : 3
                },
                {
                    "url": "http://www.krcgenk.be/images/gallery/album_199/800X600/5867e1dedd00d08d830fd7f098a0b747.jpg"
"picture_id" : 4
                }

```

I am trying to get only the first URL. I am trying to get this with the following function.

```
- (NSString *)getFirstPictureOfAlbumId: (int)AlbumId
{

    NSString *picture_Url = [[NSString alloc]init];
      NSLog(@"here1");
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
      NSLog(@"here2");
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(picture_id == 1) AND (pic_album_id == %@)",AlbumId];
      NSLog(@"here3");
    [request setEntity:[NSEntityDescription entityForName:@"Picture" inManagedObjectContext:self.genkDatabase.managedObjectContext]];
      NSLog(@"here4");
    [request setPredicate:predicate];
      NSLog(@"here5");
    NSError *error = nil;
    NSArray *results = [self.genkDatabase.managedObjectContext executeFetchRequest:request error:&error];
    if (error != nil)
    {
        //handle errors
    }
    NSLog(@"picture url is: %@",[results valueForKey:@"url"]);
    picture_Url = [results valueForKey@"url"];
    return picture_Url;
}

```

My logs only reaches to "here2" So I think there is something wrong with my predicate. Another problem I have is to store the url of the first picture.

Can anybody help me?

Thanks in advance

**EDIT**

This is what I do in my tableview

```
 NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[self getFirstPictureOfAlbumId:indexPath.row+1]]];
    NSLog(@"indexpatch is: %d",indexPath.row+1);
    NSLog(@"first picture is: %@",[self getFirstPictureOfAlbumId:indexPath.row+1]);

```

And then it logs it like this.

```
012-10-09 13:17:58.140 RacingGenk[6069:c07] album id is: 1
2012-10-09 13:17:58.311 RacingGenk[6069:c07] indexpatch is: 1
2012-10-09 13:17:58.311 RacingGenk[6069:c07] album id is: 1
2012-10-09 13:17:58.313 RacingGenk[6069:c07] first picture is: http://www.krcgenk.be/images/gallery/album_199/800X600/1a06dc0e405fd0219e3d327f1eec7fbf.jpg
2012-10-09 13:17:58.314 RacingGenk[6069:c07] album id is: 2
2012-10-09 13:17:58.445 RacingGenk[6069:c07] indexpatch is: 2
2012-10-09 13:17:58.445 RacingGenk[6069:c07] album id is: 2
2012-10-09 13:17:58.446 RacingGenk[6069:c07] first picture is: http://www.krcgenk.be/images/gallery/album_199/800X600/1a06dc0e405fd0219e3d327f1eec7fbf.jpg
2012-10-09 13:17:58.447 RacingGenk[6069:c07] album id is: 3
2012-10-09 13:17:58.577 RacingGenk[6069:c07] indexpatch is: 3
2012-10-09 13:17:58.577 RacingGenk[6069:c07] album id is: 3
2012-10-09 13:17:58.578 RacingGenk[6069:c07] first picture is: http://www.krcgenk.be/images/gallery/album_199/800X600/1a06dc0e405fd0219e3d327f1eec7fbf.jpg

```

**EDIT2**

LOG

```
RacingGenk[6605:c07] picture_id=1, album_id=1, url=http://www.krcgenk.be/images/gallery/album_199/800X600/1a06dc0e405fd0219e3d327f1eec7fbf.jpg
2012-10-09 13:57:40.361 RacingGenk[6605:c07] picture_id=1, album_id=2, url=http://www.krcgenk.be/images/gallery/album_199/800X600/1a06dc0e405fd0219e3d327f1eec7fbf.jpg
2012-10-09 13:57:40.525 RacingGenk[6605:c07] picture_id=1, album_id=3, url=http://www.krcgenk.be/images/gallery/album_199/800X600/1a06dc0e405fd0219e3d327f1eec7fbf.jpg

```