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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:13:29+00:00 2026-05-13T15:13:29+00:00

I was following the example on Beginning iPhone 3 Development. On Chapter 8 I

  • 0

I was following the example on Beginning iPhone 3 Development. On Chapter 8 I made a mistake in code.

    - (NSMutableDictionary *)mutableDeepCopy
{
 NSMutableDictionary * ret = [[NSMutableDictionary alloc] initWithCapacity:[self count]];

 NSArray * keys = [self allKeys];
 for (id key in keys) {
  id oneValue = [self valueForKey:key];
  id oneCopy = nil;

  if ([oneValue respondsToSelector:@selector(mutableDeepCopy)])
   oneCopy = [oneValue mutableDeepCopy];
  else if ([oneValue respondsToSelector:@selector(mutableCopy)])
   oneCopy = [oneValue mutableCopy];
  if (oneCopy == nil)
   oneCopy = [oneValue copy];
  [ret setValue:oneCopy forKey: key];
 }
 return ret;
}

In the second responseToSelector, instead of the mutableCopy above, I have mistakenly written it as mutableDeepCopy. As a result my creation of mutable array from the regular one has failed to a simple copy.

As a result console will print error message like this:

2010-02-04 19:58:28.381 Sections[1806:20b] * WebKit discarded an uncaught exception in the webView:shouldInsertText:replacingDOMRange:givenAction: delegate: * -[NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object

Now my question is, this is really hard for me to debug if I’m writing my own code instead of just copying it from book. How do I know at which line this “mutating method sent to immutable object” occurs?

  • 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-13T15:13:29+00:00Added an answer on May 13, 2026 at 3:13 pm

    Step 1. Use the debugger.

    Run -> Debugger or Shift-Command-Y. When your program encounters an error like the one above, you can see where in the code it was stopped. You can see Apple’s instructions on using the debugger for details, but basic stuff is pretty easy to figure out. The most important part is the thread list panel in the upper-left quadrant of the debugger. It’ll allow you to move up and down through the stack to see where in your code the error occurred. Usually you’ll be able to use this to determine which one of your objects was declared as immutable and not mutable.

    Step 2. Use Instruments.

    Instruments is powerful and will allow you to do some pretty nifty stuff. In this situation, once you find out the memory address if your accidentally-immutable object, you can use Instruments to see the history of that object and hopefully trace it back to it’s origin. To use instruments to track an object, you’ll want to run Instruments with Object Allocation (Run -> Run with Performance Tool -> Object Allocations). If you know the address of the fouled-up object, you can search for it in the lower-right corner of Instruments, in the search box. Open the Extended Detail view (Command-E) to see where that object has been.

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

Sidebar

Ask A Question

Stats

  • Questions 456k
  • Answers 456k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's an old example from Rob for a SubSonic 3… May 15, 2026 at 10:28 pm
  • Editorial Team
    Editorial Team added an answer Are you sure you're fetching the Word objects correctly? The… May 15, 2026 at 10:28 pm
  • Editorial Team
    Editorial Team added an answer You should probably run .Less instead. If I understand correctly,… May 15, 2026 at 10:28 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.