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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:11:47+00:00 2026-06-09T12:11:47+00:00

I am using the included method to return a pointer to a NSMutableDictionary, that

  • 0

I am using the included method to return a pointer to a NSMutableDictionary, that is contained in an NSArray. However, the NSMutableArray (theOne) is being created as a non-mutuable NSDictionary. This is a problem because I want to modify the dictionary after retrieving it with this method.

- (NSMutableDictionary*)getMatFromBoutKey:(NSString*) boutKey
{   
    /*
     * Returns the mat object with the provided boutKey.
     * Returns nil if no mat has that boutKey.
     */

    NSUInteger idx = [[event objectForKey:@"mats"] indexOfObjectPassingTest:
                      ^ BOOL (NSMutableDictionary* obj, NSUInteger idx, BOOL *stop)
                      {
                          return [[obj objectForKey:@"boutKey"] isEqualToString:boutKey];
                      }];

    if (idx == NSNotFound)
        return nil;
    else {
        NSMutableDictionary* theOne = [[event objectForKey:@"mats"] objectAtIndex: idx];
        return theOne;
    }
}

Here’s an image of the debugger stopped on a breakpoint right after the theOne is first referenced.

Image of the debugger showing that theOne is not mutable

Why isn’t theOne mutable? How can I return a pointer to the NSMutableDictionary so that I can modify it after I get the value returned to me?

Thanks!

  • 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-09T12:11:48+00:00Added an answer on June 9, 2026 at 12:11 pm

    I’m going to assume that you have a dictionary of arrays. Then that array contains a bunch of regular dictionaries. So when you pull it out of the array it is still a regular dictionary regardless of what you assign it to.

    For instance, take the following code for example

    NSDictionary *dict = [[NSDictionary alloc] init];
    NSMutableDictionary *mutDict = dict;
    

    mutDict will contain a regular dictionary because it has not properly been casted to a mutable dictionary.

    either make sure when you create the array that is at [event objectForKey:@”mats”] that you put NSMutable dictionaries inside of it OR

    use

    NSMutableDictionary* theOne = [[[event objectForKey:@"mats"] objectAtIndex: idx] mutableCopy];
    

    When taking the data out

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

Sidebar

Related Questions

I have a rails module included for reference below that I have included using
Possible Duplicate: Calling class method through NULL class pointer #include <iostream> using namespace std;
I am using entity framework and I can't find include method like in this
I'm trying to add jQuery using Greasemonkey's @require / @include method, but it doesn't
Using the example code included in the man page for DateTime::Astro::Sunrise , I'm getting
Using jQuery timepickr: http://archive.plugins.jquery.com/project/jquery-timepickr Having included these files: jquery-1.7.1.min.js jquery-ui-1.8.21.custom.min.js ui.timepickr.js And getting this
Images can be included in TextArea controls using the htmlText property: ta.htmlText = '<img
I am using the HtmlEditor Control included in the AjaxControlToolkit (patched version v62210 because
I'm using the post-receive-email script included with git. (Source is here .) It works
I have included numerous coldfusion and html files in CFM pages using the <cfinclude>

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.