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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:43:13+00:00 2026-06-06T16:43:13+00:00

I started Objective-C programming about a week ago and am stuck on creating a

  • 0

I started Objective-C programming about a week ago and am stuck on creating a new string from an array of strings passed into the function. I’ve researched this thoroughly and can’t seem to figure out why I can use stringByAppendingString once (checked with NSLog) but not a second time without throwing this error:

Thanks for looking.

2012-06-29 20:46:35.761 Calculator[32883:f803] -[__NSCFNumber stringByAppendingString:]: unrecognized selector sent to instance 0x6e43d50

2012-06-29 20:46:35.763 Calculator[32883:f803] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFNumber stringByAppendingString:]: unrecognized selector sent to instance 0x6e43d50’

+ (NSString *)descriptionOfTopOfStack:(NSMutableArray *)stack
{
    NSString *result;
    NSString *displayString = [[NSString alloc]init];
    id topOfStack = [stack lastObject];
    if (topOfStack) [stack removeLastObject];

    if ([self isNoOperandOperation:topOfStack]) {
        displayString = [displayString stringByAppendingString:topOfStack];
        result = displayString;
        }
    else if ([self isOperation:topOfStack]){
        id nextInStack = [stack lastObject];
        if (topOfStack) [stack removeLastObject];
        displayString = [displayString stringByAppendingString:nextInStack];
        displayString = [displayString stringByAppendingString:topOfStack];
        result = displayString;
  • 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-06T16:43:14+00:00Added an answer on June 6, 2026 at 4:43 pm

    stringByAppendingString is a method of NSString, you have to return your displayString as NSString,

    + (NSString *)descriptionOfTopOfStack:(NSMutableArray *)stack
    {
    NSLog(@"stack array :: %@",stack);
    NSString *result;
    NSString *displayString = [[NSString alloc]init];
    id topOfStack = [stack lastObject];
    if (topOfStack) [stack removeLastObject];
    
    NSLog(@"topOfStack :: %@", (NSString*)topOfStack);
    
    if ([self isNoOperandOperation:topOfStack]) {
        displayString = [[(NSNumber*)displayString stringValue] 
                                    stringByAppendingString:(NSString*)topStack];
        result = displayString;
        }
    else if ([self isOperation:topOfStack]){
        id nextInStack = [stack lastObject];
        if (topOfStack) [stack removeLastObject];
        displayString = [[(NSNumber*)displayString stringValue] 
                                    stringByAppendingString:(NSString*)nextInStack];
        displayString = [[(NSNumber*) displayString stringValue] 
                                    stringByAppendingString:(NSString*)topStack];
        result = displayString;
    

    EDIT: stringByAppendingString method requires parameter type of NSString, your topOfStack is type ID, you need to type cast this to NSString assuming your topOfStack is string, same for nextInStack

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

Sidebar

Related Questions

First, I'm new to iOS and Objective-C programming (I started a month ago). I'm
I'm pretty new to objective C started a few days ago... I want to
Sorry for noobish question about iPhone and Quartz programming. Just started my conversion from
I have started learning Objective C with no prior programming experience from the 'Become
I am new here and just started learning about Objective C. I am having
I've started with objective-c/iphone programming a couple of days ago, and still having some
I just started studying programming about 6 months ago and I have really been
I've recently started down the road of programming in Objective-C, and I'm now looking
I am a C# developer getting started on Objective-C / Cocoa Touch programming. I
I have just started learning Objective-C, I am reading Programming in Objective-C 3rd Edition

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.