Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8684991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:26:48+00:00 2026-06-12T22:26:48+00:00

I want to populate an array after I selected a row. Now I want

  • 0

I want to populate an array after I selected a row. Now I want to populate an array using a function. This is what the situation is. I have a tableview which displays albums titles. When you select a row you show all pictures using the FGallery library. Here is my function for populating my array.

- (NSMutableArray *)getAllPicturesOfAlbumId: (int)AlbumId
{
    NSLog(@"tot hier");
    _picturesForAlbum = [[NSMutableArray alloc]init];
    NSArray *results = [[NSArray alloc]init];
    //picture_Url = @"";
    NSLog(@"tot hier");
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"whichAlbum.album_id == %d", AlbumId];
    [request setEntity:[NSEntityDescription entityForName:@"Picture" inManagedObjectContext:self.genkDatabase.managedObjectContext]];
    [request setPredicate:predicate];
    NSError *error = nil;
    NSLog(@"tot hier");
    results = [self.genkDatabase.managedObjectContext executeFetchRequest:request error:&error];
    if (results == nil) {
        // handle errors
        NSLog(@"geen resultaten");
    } else if (results.count == 0) {
        // nothing found
        NSLog(@"0 resultaten");
    } else {
        for(int i = 0; i < results.count ; i++){
           // NSLog(@"%@",[results valueForKey:@"url"]);
            [_picturesForAlbum addObject: [results valueForKey:@"url"]];
        }
    }

    return _picturesForAlbum;
}

Here are my FGallery methods.

- (int)numberOfPhotosForPhotoGallery:(FGalleryViewController *)gallery
{
     return [networkImages count];

}


- (FGalleryPhotoSourceType)photoGallery:(FGalleryViewController *)gallery sourceTypeForPhotoAtIndex:(NSUInteger)index
{
     return FGalleryPhotoSourceTypeNetwork;
}


- (NSString*)photoGallery:(FGalleryViewController *)gallery urlForPhotoSize:(FGalleryPhotoSize)size atIndex:(NSUInteger)index {
    return [networkImages objectAtIndex:index];
}

And this is what I do in my didSelectRowAtIndexPath

networkImages = [[NSArray alloc] initWithArray:[self getAllPicturesOfAlbumId:indexPath.row]];
networkGallery = [[FGalleryViewController alloc] initWithPhotoSource:self];
[self.navigationController pushViewController:networkGallery animated:YES];

Put for some reason or another my networkImages is populated several times with the array it gets back from the method “getAllPicturesOfAlbumId”
Because of that I think I get the following error.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0xa15d090'

Anybody has an idea what the problem is?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:26:49+00:00Added an answer on June 12, 2026 at 10:26 pm

    Calling valueForKey on an array returns an array of all the value for that key. So, in the method getAllPicturesOfAlbumId, you shouldn’t loop through results, just return [results valueForKey:@”URL”] (so no need to even create the _picturesForAlbum array).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView which I want to populate with details from an array
I have a Sectioned Tableview sourced from a pList which I want to drill
I have an array ele , and I want to populate another array arr
Actually I want to populate an array to fill up my table view, but
I want to initialize an array of int and populate it with a range
I want to take an array and use that array's values to populate an
In this simple example, i want to create a String array populated with each
I want to populate a table form a MYSQL database. I have defined the
I want to re-populate (i.e refill) values posted from a select form field after
i'm using twitter bootstrap 2.0.4. i want to populate the dropdown using ajax. the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.