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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:15:35+00:00 2026-05-24T23:15:35+00:00

I have an object defined like this: Scores.h: @interface Scores : NSObject { NSString

  • 0

I have an object defined like this:
Scores.h:

@interface Scores : NSObject {
NSString *sentenceKey;
    NSMutableArray *scorrectAnswers;
}
@property (nonatomic, copy) NSString *sentenceKey;
@property (nonatomic, copy) NSMutableArray *scorrectAnswers;
+ (id)addScore:(NSString *)senKey;

- (id)initWithSentenceKey:(NSString *)sKey  
    scorrectAnswers:(NSMutableArray *)scorrectAs;

- (id)initWithSentenceKey:(NSString *)sKey;
- (void)removeArrayObjects;

Score.m:

#import "Scores.h"
@implementation Scores

@synthesize sentenceKey, scorrectAnswers;

+ (id)addScore:(NSString *)senKey
{
Scores *newScore = [[self alloc] initWithSentenceKey:senKey
                    scorrectAnswers:[NSMutableArray new]];
return [newScore autorelease];}

I’m trying to removeAllObjects on my mutable array with this method:

- (void)removeArrayObjects;{
   [scorrectAnswers removeAllObjects];}

…which I call from another program like this:

for (Scores *sScore in scores)
{   
    [sScore removeArrayObjects];
}

… and I get this error when I run it:

-[__NSArrayI removeAllObjects]: unrecognized selector sent to instance 0x53412d0

Can anyone tell me what I’m doing wrong here? 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-05-24T23:15:36+00:00Added an answer on May 24, 2026 at 11:15 pm

    You are not dealing with an NSMutableArray as the error indicates you have an immutable NSArray.

    This question may be your answer NSMutableArray addObject: -[__NSArrayI addObject:]: unrecognized selector sent to instance

    Basically the copy you used when defining your @property will cause the setter to be generated using

    scorrectAnswers = [newMutableArray copy];
    

    which returns an immutable NSArray.

    You can re-implement this method and change the previous line for:

    scorrectAnswers = [newMutableArray mutableCopy];
    

    or use retain instead of copy

    This can also occur when getting data from a plist

    If you are using a plist it will return an NSArray even if you save an NSMutableArray it will be cast. So when retrieving you will need to do something like:

    scorrectAnswers = [[NSMutableArray alloc] initWithArray:[userDefault objectForKey:@"my_array_key"]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script which creates a user-defined object like this: obj = new
I have a 3D vector defined like this... std::vector<std::vector<std::list<Object*> > > m_objectTiles; I have
I have an object defined like this: Blah = { hideTimer:null, setTimer: function() {
I have a YAHOO Panel object defined like this: profilesDialog = new YAHOO.widget.Panel(profiles_dialog, {
I have javascript object defined like this: function SocialMiner() { var verbose=true; var profileArray=new
I have an object which has inner objects and properties defined like this: var
If I have a javascript object/assoc. array defined like this: function somefunction(options) { var
I have a json object defined like this - Content : [ Value1, Value2,
I have a struct defined like follows as part of an object. I'm trying
I have a web page with swf file defined this way <object width=600 height=400

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.