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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:18:44+00:00 2026-06-09T01:18:44+00:00

I am having problem with the following code, I need to do some modification

  • 0

I am having problem with the following code, I need to do some modification on each array within a NSMutableDictionary. When I first added those array into the dictionary, they are “MutableArray”, but when I try to do something with them, they become a “NSArray”.

here is my code:

UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *cellText = selectedCell.textLabel.text;
    NSLog(@"cell: %@", cellText);

    Boolean flag = false;
    NSMutableDictionary *myTempDict = [[NSMutableDictionary alloc] initWithDictionary:self.tableContents copyItems:YES];

    for (NSString *key in myTempDict) 
    {
        NSLog(@"1st for");
        for(NSString *myString in [myTempDict objectForKey:key])
        {
            NSLog(@"2nd for");
            if([myString isEqualToString:cellText])
            {
                if([[myTempDict objectForKey:key] isKindOfClass:[NSMutableArray class]])
                {
                    NSLog(@"mutable");
                }
                else if([[myTempDict objectForKey:key] isKindOfClass:[NSArray class]])
                {
                    NSLog(@"not mutable");
                }
                [[myTempDict objectForKey:key] removeObject:myString];
                break;
                NSLog(@"break1");
            }
            NSLog(@"2nd for end");
        }
        if(flag)
        {
            break;
            NSLog(@"break2");
        }
    }
    self.tableContents = myTempDict;
    [tableView reloadData];

now when I run it, it generate the following error:

  • cell: 12-01244476
  • 1st for
  • 2nd for
  • not mutable
  • -[__NSArrayI removeObject:]: unrecognized selector sent to instance 0x7c02580
  • Current language: auto; currently objective-c

on my viewdidLoad I created those Array to be NSMutableArray, but now its back to NSArray, why?
and any idea on how to tackle this problem?

really need help on this.

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-09T01:18:45+00:00Added an answer on June 9, 2026 at 1:18 am

    Acording to the documentation of NSDictionary

    The copyWithZone: method performs a shallow copy. If you have a collection of arbitrary depth, passing YES for the flag parameter will perform an immutable copy of the first level below the surface. If you pass NO the mutability of the first level is unaffected. In either case, the mutability of all deeper levels is unaffected.

    Why don’t you try:

    NSMutableDictionary *myTempDict = [self.tableContents mutableCopy];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code is having some problem with the jQuery. <script type="text/javascript"> $(window).load(function() {
I'm having a problem with the following code foreach ($ex in (foo, bar, baz))
I'm having a problem with the following code snippet: <!DOCTYPE html> <html> <head> <title>Hangman</title>
I'm having a problem getting a change event to register with the following code:
I'm having a problem with TRY...CATCH blocks. Can someone explain why the following code
I'm having a problem with image scaling. When I use the following code to
im having some trouble with the following code: Ext.define('...controller...', { extend: 'Ext.app.Controller', init: function()
I am having a problem converting an int from a byte array first encoded
I'm having problems the following code gives me no results. however if I uncomment
I'm having problems with the following code (I am a beginner in most things

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.