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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:09:12+00:00 2026-06-16T00:09:12+00:00

Before anything else, my plist is working fine with the code below before I

  • 0

Before anything else, my plist is working fine with the code below before I added Item 1, and Item 2.

Then as the project progress, I have to add several items in my plist. Then an error occurs.

The problem is, I have a ‘Root’ plist that has Item 0, Item 1, and Item 2 as Dictionary as stated below:

The plists by the way have the same data except for the strings in Province.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>Province</key>
        <string>Metro Manila</string>
        <key>Cities</key>
        <array>
            <dict>
                <key>Places</key>
                <string>Chowking</string>
            </dict>
        </array>
    </dict>
    <dict>
        <key>Province</key>
        <string>Pampanga</string>
        <key>Cities</key>
        <array>
            <dict>
                <key>Places</key>
                <string>Jollibee</string>
            </dict>
            <dict>
                <key>Places</key>
                <string>McDonald's</string>
            </dict>
            <dict>
                <key>Places</key>
                <string>Pizza Hut</string>
            </dict>
        </array>
    </dict>
    <dict>
        <key>Province</key>
        <string>Pangasinan</string>
        <key>Cities</key>
        <array>
            <dict>
                <key>Places</key>
                <string>Jollibee</string>
            </dict>
            <dict>
                <key>Places</key>
                <string>McDonald's</string>
            </dict>
        </array>
    </dict>
</array>
</plist>

This is the code of my Controller.m

//
//  RootViewController.m
//  TableView
//
//  Created by OSX on 10/10/12.
//  Copyright (c) 2012 OSX. All rights reserved.
//

#import "RootViewController.h"
#import "CityViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController {
    NSArray * luzonRegion;
    NSArray * visayasRegion;
    NSArray * mindanaoRegion;
}

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title = @"Region";

    [self loadRegionPlist];
}

- (void)loadRegionPlist
{
    NSString *plistLuzon    = [[NSBundle mainBundle] pathForResource: @"luzonPlist" ofType: @"plist"];
    luzonRegion   = [[NSArray alloc] initWithContentsOfFile: plistLuzon];
    NSString *plistVisayas  = [[NSBundle mainBundle] pathForResource: @"visayasPlist" ofType: @"plist"];
    visayasRegion = [[NSArray alloc] initWithContentsOfFile: plistVisayas];
    NSString *plistMindanao = [[NSBundle mainBundle] pathForResource: @"mindanaoPlist" ofType: @"plist"];
    mindanaoRegion = [[NSArray alloc] initWithContentsOfFile: plistMindanao];

    NSLog(@"%@", luzonRegion);
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    switch (section) {
        case 0:
            return [luzonRegion count];
            break;

        case 1:
            return [visayasRegion count];
            break;

        case 2:
            return [mindanaoRegion count];
            break;

        default:
            break;
    }

    return section;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

    // Configure the cell...
    NSDictionary *luzonDictionary    = [luzonRegion    objectAtIndex:indexPath.row];
    NSDictionary *visayasDictionary  = [visayasRegion  objectAtIndex:indexPath.row];
    NSDictionary *mindanaoDictionary = [mindanaoRegion objectAtIndex:indexPath.row];

    switch (indexPath.section) {
        case 0:
            cell.textLabel.text = [luzonDictionary    objectForKey: @"Province"];
            break;

        case 1:
            cell.textLabel.text = [visayasDictionary  objectForKey: @"Province"];
            break;

        case 2:
            cell.textLabel.text = [mindanaoDictionary objectForKey: @"Province"];
            break;

        default:
            break;
    }

    [cell setAccessoryType: UITableViewCellAccessoryDisclosureIndicator];
    return cell;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    switch (section) {
        case 0:
            return @"Luzon";
            break;

        case 1:
            return @"Visayas";
            break;

        case 2:
            return @"Mindanao";
            break;

        default:
            break;
    }
    return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    CityViewController *cityViewController = [[CityViewController alloc] initWithStyle:UITableViewStylePlain];

    NSDictionary *luzonDictionary    = [luzonRegion    objectAtIndex:indexPath.row];
    NSDictionary *visayasDictionary  = [visayasRegion  objectAtIndex:indexPath.row];
    NSDictionary *mindanaoDictionary = [mindanaoRegion objectAtIndex:indexPath.row];
    switch (indexPath.section) {
        case 0:
            cityViewController.title  = [luzonDictionary   objectForKey: @"Province"];
            cityViewController.Cities = [luzonDictionary   objectForKey: @"Cities"];
            break;

        case 1:
            cityViewController.title  = [visayasDictionary  objectForKey: @"Province"];
            cityViewController.Cities = [visayasDictionary  objectForKey: @"Cities"];
            break;

        case 2:
            cityViewController.title  = [mindanaoDictionary objectForKey: @"Province"];
            cityViewController.Cities = [mindanaoDictionary objectForKey: @"Cities"];
            break;

        default:
            break;
    }

    [self.navigationController pushViewController:cityViewController animated:YES];
}

@end

NSLog and Debug Area output:

2012-12-17 11:24:21.023 TableViewPlist[24315:c07] (
        {
        Cities =         (
                        {
                Places = Chowking;
            }
        );
        Province = "Metro Manila";
    },
        {
        Cities =         (
                        {
                Places = Jollibee;
            },
                        {
                Places = "McDonald's";
            },
                        {
                Places = "Pizza Hut";
            }
        );
        Province = Pampanga;
    },
        {
        Cities =         (
                        {
                Places = Jollibee;
            },
                        {
                Places = "McDonald's";
            }
        );
        Province = Pangasinan;
    }
)

2012-12-17 11:24:21.043 TableViewPlist[24315:c07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (1) beyond bounds (1)'
*** First throw call stack:
(0x1c94012 0x10d1e7e 0x1c93deb 0x1c887e0 0x36aa 0xd3f4b 0xd401f 0xbc80b 0xcd19b 0x6992d 0x10e56b0 0x2290fc0 0x228533c 0x2290eaf 0x1088cd 0x511a6 0x4fcbf 0x4fbd9 0x4ee34 0x4ec6e 0x4fa29 0x52922 0xfcfec 0x49bc4 0x49dbf 0x49f55 0xc472d84 0x52f67 0x2cb2 0x167b7 0x16da7 0x17fab 0x29315 0x2a24b 0x1bcf8 0x1befdf9 0x1befad0 0x1c09bf5 0x1c09962 0x1c3abb6 0x1c39f44 0x1c39e1b 0x177da 0x1965c 0x293d 0x2865 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb) 
  • 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-16T00:09:13+00:00Added an answer on June 16, 2026 at 12:09 am

    The problem seems to be here:

    NSDictionary *luzonDictionary    = [luzonRegion    objectAtIndex:indexPath.row];
    NSDictionary *visayasDictionary  = [visayasRegion  objectAtIndex:indexPath.row];
    NSDictionary *mindanaoDictionary = [mindanaoRegion objectAtIndex:indexPath.row];
    

    If one of regions will not contain as many items as other regions, this will fail.

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

Sidebar

Related Questions

Is it possible to have Greasemonkey scripts run before anything else on the page?
I have sanitize class that I run before anything else on every page of
Before anything else, this is the offending bit of code: for (var i in
Before anything else, here is the simplified schema ( with dummy records ) of
Error that pops up even before anything else loads: Package Load Failure Package 'Microsoft.TeamFoundation.Client.ServicesHostPackage,
I need to launch an app I've made just after login, before anything else
Before saying anything I have to say that, albeit I'm an experienced programmer in
(Before anyone says anything Yes this was homework but i have already turned it
Is there anything special I have to do to a JSON object before I
Before anything, I have read both this and this questions to solve the problem

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.