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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:05:28+00:00 2026-06-15T08:05:28+00:00

(I cant find this on the Net) All code is within one object. In

  • 0

(I cant find this on the Net)

All code is within one object. In the .h file I define a NSMutableArray. And I alloc it
in an init.

-(id)init{
    self = [super init];
    if(self) {
        definitionArray=[[NSMutableArray alloc] init];
        [self initialLoadDefinitionData];

        if([definitionArray isKindOfClass:[NSMutableArray class]]) {
           NSLog(@"Array is Mutable");
        } else {
           NSLog(@"Array is Not Mutable");
        }

    }
    return self;
}

I want to initialize based on NSUserDefaults values, so I call another function from the
init. This called initialLoadDefinitionData:theCollection is very basic.

-(void)loadDefinitionData{
    definitionArray=[[[NSUserDefaults standardUserDefaults] objectForKey:@"SOMEKEY"] mutableCopy];
}

I have added the isKindOfClass in the init function just for debug purposes. The fun part
in this is that this IF statement returns MUTABLE when data could be fetched from the
NSUserDefaults. However if the @”SOMEKEY” was not available, the objectForKey returns a
nil and the definitionArray suddenly is IMMUTABLE. Even if the mutableCopy is specified.

So my conclusion is that if a objectForKey cannot find an object, the return value is
NOT MUTABLE. Is this conclusion correct?
Or can’t MutableCopy not address an object as mutable with it is Nil?

  • 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-15T08:05:31+00:00Added an answer on June 15, 2026 at 8:05 am

    No your conclusion is not right. If the objectForKey returns nil then you ‘re sending a mutableCopy message to nil which returns of course nil (every message sent to nil in ObjC returns nil) and that’s why you’ re seeing the else part. (The Array is Not Mutable message is misleading since you do not even have an NSArray instance at this point).

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

Sidebar

Related Questions

I cant find one way to get this value (comment) into json using javascript.
Been searching all over for this but cant find an answer so thought I
Ive been searching for an answer for this and cant find one, although I
All over the net i cant find a good tutorial for mongodb basics with
I'm trying to find a .Net equivalent of the java code in this question:
There's loads of posts on this subject on the net, but I cant find
I can't seem to find any help on this but under the Net tab
I cant find an answer already on stackoverlow for this. This is the simplest
I know this is really simple but I cant find the docs for this
I am new to this technology. I searched a lot but cant find any

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.