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 6601541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:46:00+00:00 2026-05-25T18:46:00+00:00

Menu.h @interface Menu : UITableViewController { NSMutableArray *arrayCellCollectionOrder; NSMutableDictionary *dictCellCollection; NSMutableDictionary *dictCellIndividual; } @property

  • 0

Menu.h

@interface Menu : UITableViewController {    
    NSMutableArray *arrayCellCollectionOrder;
    NSMutableDictionary *dictCellCollection;
    NSMutableDictionary *dictCellIndividual;
}

@property (nonatomic, retain) NSMutableArray *arrayCellCollectionOrder;

@end

Menu.m

ViewDidLoad works as normal.

@synthesize arrayCellCollectionOrder;

- (void)viewDidLoad {

    // Codes to read in data from PLIST
    // This part works

    NSString *errorDesc = nil;
    NSPropertyListFormat format;
    NSString *plistPath;
    NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

    plistPath = [rootPath stringByAppendingPathComponent:@"InfoTableDict.plist"];
    if (![[NSFileManager defaultManager] fileExistsAtPath:plistPath]) {
        plistPath = [[NSBundle mainBundle] pathForResource:@"InfoTableDict" ofType:@"plist"];
    }

    NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
    NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization
                                        propertyListFromData:plistXML
                                        mutabilityOption:NSPropertyListMutableContainersAndLeaves
                                        format:&format
                                        errorDescription:&errorDesc];

    if (!temp) {
        NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
    }

    arrayCellCollectionOrder = [[[NSMutableArray alloc] init] retain];
    arrayCellCollectionOrder = [temp objectForKey:@"CellCollectionOrder"]; 

    // I can access `arrayCellCollectionOrder` here, it's working.

}

cellForRowAtIndexPath works as normal. I can access arrayCellCollectionOrder.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"PhotoCell";
    PhotoCell *cell = (PhotoCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"PhotoCell" owner:self options:nil];
        for (id currentObject in topLevelObjects) {
            if ([currentObject isKindOfClass:[PhotoCell class]]) {
                cell = (PhotoCell *) currentObject;
                break;
            }
        }
    }

    // Copy the specific dictionary from CellCollection to Cell Individual
    dictCellIndividual = [dictCellCollection objectForKey:[NSString stringWithFormat:@"%@", [arrayCellCollectionOrder objectAtIndex:indexPath.row]]];

    cell.photoCellTitle.text = [dictCellIndividual objectForKey:@"Title"];     // Load cell title
    cell.photoCellImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", [dictCellIndividual objectForKey:@"ThumbnailFilename"]]];        // Load cell image name

    return cell;

}

didSelectRowAtIndexPath NOT WORKING. I cannot access arrayCellCollectionOrder.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

// Browser
NSMutableArray *arrayPhotos = [[NSMutableArray alloc] init];

    NSLog(@"indexPath.row = %d", indexPath.row);        // Returns the row number i touched, works.

    NSLog(@"arrayCellCollectionOrder = %@", [NSString stringWithFormat:@"%@", [arrayCellCollectionOrder objectAtIndex:indexPath.row]]);        // DOES NOT WORK.

    // Copy the specific dictionary from CellCollection to Cell Individual
    dictCellIndividual = [dictCellCollection objectForKey:[NSString stringWithFormat:@"%@", [arrayCellCollectionOrder objectAtIndex:indexPath.row]]];        // This similar line gives error too.

    ...   ...
    ...   ...
    ...   ...
    ...   ...

}

Error is:
* Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘-[__NSCFArray objectAtIndex:]: index (1) beyond bounds (0)’

i.e.: I clicked on row 1, but arrayCellCollectionOrder is NULL.
There should have data in arrayCellCollectionOrder as it’s declared in ViewDidLoad.

Is there something that I missed out?
Thanks a lot 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-05-25T18:46:01+00:00Added an answer on May 25, 2026 at 6:46 pm
    arrayCellCollectionOrder = [[[NSMutableArray alloc] init] retain];
    arrayCellCollectionOrder = [temp objectForKey:@"CellCollectionOrder"]; 
    

    Do you see what you are doing to arrayCellCollectionOrder? You first assign it to a new NSMutableArray (and retain it needlessly), and then you immediately orphan the array and assign arrayCellCollectionOrder to another object that you are getting from the temp dictionary. In other words, that first line isn’t doing anything for you, other than create a leaked mutable array.

    If the second line is correct and you are getting a valid object and that is what you want, then the problem is that I don’t see where that object is getting retained. As long as it is in the dictionary, it is probably retained, but if temp is discarded, then its members are released. If you did a

    self.arrayCellCollectionOrder = [temp objectForKey:@"CellCollectionOrder"];
    

    then the setter would retain it.

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

Sidebar

Related Questions

I am going to write a full-screen menu interface to run on Linux and
I have a Drupal Menu which I created through the interface. I wish to
I have this view which generates interface language options menu def lang_menu(request,language): lang_choices =
I have an openGL GUI interface and I need to have a popup menu
I am using jQuery resizable from interface.eyecon.ro/docs/resizable for a menu on a page that
When I change some interface things in Java, like the contents of a menu
am a beginner, writing one interface to create a dynamic menu(cascading) using html, javascript
I disabled auto-enables menu items for my app's main menu in Interface Builder because
I have a menu with several items created in interface builder. It looks fine
I implemented the IDropTarget interface and the drag & drop (file from explorer) works

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.