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

  • Home
  • SEARCH
  • 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 721981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:56:10+00:00 2026-05-14T05:56:10+00:00

I have a UINavigationController consisting of a tableview I want to load some data

  • 0

I have a UINavigationController consisting of a tableview I want to load some data into.
I have a dictionary plist containing Dictionaries for each Train Line which in turn have dictionaries for each station with the relevant information along with one string lineName. I need to collect the station Names keys and add them to an array to populate my table (This is working).

The line names are stored as a string in my lines dictionary with the key being “lineName”

Root->|
      |
      |->TrainLine1(Dictionary)->|
      |                          |-> lineName (String)
      |                          |-> Station1 (Dictionary)
      |                          |-> Station2 (Dictionary)
      |
      |
      |->TrainLine2(Dictionary)->|
      |                          |-> lineName (String)
      |                          |-> Station1 (Dictionary)
      |                          |-> Station2 (Dictionary)

Am I going about this the wrong way? Should I reorganise my plist?
The code below crashes the app.

- (void)viewDidLoad {
     NSString *path = [[NSBundle mainBundle] pathForResource:@"lineDetails" ofType:@"plist"];
     NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:path];
     NSDictionary *lineDictionary = [[NSDictionary alloc] initWithDictionary:[dictionary objectForKey:stationNameKey]];
     NSMutableArray *stationsOnLine = [[NSArray alloc] init];

     NSString *key;

     for (key in lineDictionary) {

         NSLog(@"Adding this in array:%@", key);
         //NSString *key2;
         NSString *nameToTry = [NSString stringWithString:key];
         NSLog(@"nameToTry : %@", nameToTry);    
         //NSMutableDictionary *stationDictionary = [[NSDictionary alloc] init];
         if (![key isEqualToString: @"lineName"]) 
         {
             //NSMutableDictionary *stationDictionary = [[NSDictionary alloc] init];
            // NSLog(@"Yes");
             //NSMutableDictionary *tempDict = [[NSDictionary alloc] initWithDictionary:[lineDictionary objectForKey:key]];
             NSMutableDictionary *stationDictionary = [[NSDictionary alloc] initWithDictionary:[lineDictionary objectForKey:key]];
             //stationDictionary = tempDict;
             NSLog(@"Object for key--  %@",[stationDictionary objectForKey:kStationName]);
             [stationsOnLine addObject:[stationDictionary objectForKey:kStationName]];
             [stationDictionary release];
             //[tempDict release];
         }
         /*
         for (key2 in stationDictionary)
         {
             NSLog(@"Adding this in station array:%@", key);
         }
          */

     }
     stationNames = stationsOnLine;
     //[stationDictionary release];

     [stationsOnLine release];
     [lineDictionary release];
     [dictionary release];
 }

Debugger console output:

2010-03-31 00:42:39.842 AMT_Schedule[8395:207] did SelectRow Array contents:deux-montagnes
2010-03-31 00:42:39.844 AMT_Schedule[8395:207] Adding this in array:sunnybrooke
2010-03-31 00:42:39.844 AMT_Schedule[8395:207] nameToTry : sunnybrooke
2010-03-31 00:42:39.845 AMT_Schedule[8395:207] Object for key--  Sunnybrooke
2010-03-31 00:42:39.846 AMT_Schedule[8395:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[NSCFArray insertObject:atIndex:]: mutating method sent to immutable object'
2010-03-31 00:42:39.847 AMT_Schedule[8395:207] Stack: (
    29320283,
    2521638153,
    29404219,
    29404058,
    107345,
    107124,
    17393,
    3270466,
    3263806,
    3306080,
    3302106,
    3308563,
    3289798,
    3310951,
    3289447,
    15819,
    3066438,
    3049604,
    303530,
    29104832,
    29101128,
    37410325,
    37410522,
    2793391,
    8628,
    8482
)
  • 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-14T05:56:10+00:00Added an answer on May 14, 2026 at 5:56 am
     NSMutableArray *stationsOnLine = [[NSArray alloc] init];
    

    Should be

     NSMutableArray *stationsOnLine = [[NSMutableArray alloc] init];
    

    It compiles fine because the Obj-C compiler thinks this an NSMutableArray, but the pointer is actually to an NSArray instance, so at runtime that’s what the “mutating method sent to immutable type” error is all about. Normally this would show up as an “unrecognized selector” error, but I suppose the way that arrays are handled internally causes this other, more cryptic error message.

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

Sidebar

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.