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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:02:56+00:00 2026-05-30T19:02:56+00:00

I have a NSMutableArray allAnswers NSMutableArray *allAnswers = [[NSMutableArray alloc] init]; With the values

  • 0

I have a NSMutableArray allAnswers

NSMutableArray *allAnswers = [[NSMutableArray alloc] init];

With the values :

allAnswers --- (
        {
        PlayerName = Trfghuhhrf;
        Score = 1000;
    },
        {
        PlayerName = Test;
        Score = 333;
    },
        {
        PlayerName = DDDDDDDD;
        Score = 250;
    },
        {
        PlayerName = SSSSSSSSSSSSSSS;
        Score = 100;
    },
        {
        PlayerName = mn;
        Score = 100;
    }
)

This is how I am building dictionary.

    NSDictionary *answer = [NSDictionary dictionaryWithObjectsAndKeys:
                            name, PlayerKey,
                            [NSNumber numberWithInt:[score intValue]], ScoreKey,
                            nil];
    [allAnswers addObject:answer];


NSSortDescriptor *sortDesc = [NSSortDescriptor sortDescriptorWithKey:ScoreKey ascending:NO];

[allAnswers sortUsingDescriptors:[NSArray arrayWithObject:sortDesc]];

NSLog(@"allAnswers --- %@",allAnswers);

for (NSDictionary *answer in allAnswers)
{
    NSLog(@"%@, %@", [answer objectForKey:PlayerKey], [answer objectForKey:ScoreKey]);

    NSMutableString *mString = [[NSMutableString alloc]init];
    [mString appendString:[answer objectForKey:PlayerKey]];
    [mString appendString:@" - "];
    [mString appendString:[answer objectForKey:ScoreKey]];

    NSLog(@"mString --******-- %@",mString);
}

App is crahsing when I am trying to add [answer objectForKey:ScoreKey] to mutable string. I tried converting [answer objectForKey:ScoreKey] to (NSString) but that did’t help.

Please advise what I am doing wrong.

Sorry for long description.

Adding Crash logs :


2012-03-03 00:43:48.149 NumberTwins[38378:10703] -[__NSCFNumber length]: unrecognized selector sent to instance 0x9155400
2012-03-03 00:43:48.149 NumberTwins[38378:10703] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFNumber length]: unrecognized selector sent to instance 0x9155400’
*
First throw call stack:

  • 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-30T19:02:57+00:00Added an answer on May 30, 2026 at 7:02 pm

    You are storing an int as an NSNumber for the key ScoreKey but you can’t just append this to a string, because it is the wrong type. You need to convert it to an NSString.

    You can’t just cast the NSNumber to an NSString because its a different type altogether; you should use the correct method of NSNumber:

    [mString appendString:[[answer objectForKey:ScoreKey] stringValue]];
    

    The reason you are able to get a value logged is because putting a %@ in the log calls the object’s description method. This method is declared in NSObject, and the Framework classes implement it so that it returns a representation of the object as a string.

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

Sidebar

Related Questions

For example say I have: NSMutableArray *array = [[NSMutableArray alloc] init]; NSMutableArray *array2 =
I have a class that subclasses NSMutableArray. I init it using: MyClass class =
I have this code: tableList = [[NSMutableArray alloc] initWithObjects:@First View,@Second View,nil]; I have synthesized
Assuming I have an NSMutableArray which is loaded from file: searchTermsArray = [[NSMutableArray alloc]
I have a NSMutablearray wich contain NSArrays(each array contain int and String values). When
I have a NSMutableArray: NSMutableArray *temp = //get list from somewhere. Now there is
I have an NSMutableArray that is populated with objects of strings. For simplicity sake
I have a NSMutableArray that I need to search for a string and return
I have an NSMutableArray. It's members eventually become members of an array instance in
Newbie question. I have a NSMutableArray that holds multiple objects (objects that stores Bezier

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.