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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:49:26+00:00 2026-05-22T22:49:26+00:00

This doesn’t seem to work: NSString *string = [[NSString alloc] init]; string = @%@M,

  • 0

This doesn’t seem to work:

NSString *string = [[NSString alloc] init];
string = @"%@M", anotherstring;

I expect this to make “string” equal to “5M” if “anotherstring” is “5”.

Is this not the right syntax? Now, I could use initWithFormat and it would work, but how can you separate it into two different lines and also work?

  • 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-22T22:49:27+00:00Added an answer on May 22, 2026 at 10:49 pm

    There are two mistakes in your code. Firstly, NSStrings are immutable, and once you allocate and initialize them, they’re set, and there’s no way to change them. For that, you’d have to look into NSMutableString.

    Secondly, the syntax of your code makes no sense. @"%@M", anotherString is not a valid Objective-C method call. You are indeed looking for -initWithFormat: to perform the operation you want. The code should look like this:

    NSString *string = [[NSString alloc] initWithFormat:@"%@M", anotherString];
    

    Read more about NSString and how to use it in the NSString Programming Reference document, and the String Programming Guide to get a sense of how to work with strings in Cocoa and Objective-C.

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

Sidebar

Related Questions

I'm not sure why this doesn't work: scala> case class Loader(n: String, x: String,
This doesn't work. I've got an exception from SQL databse that column does not
This doesn't seem to work: func = getProductListings; params = {'user_id':1234,'short':true}; window.opener[func](params); can someone
This doesn't work. var result = from row in grid.Rows where (string) row.Cells[COLUMN_1].Value ==
Ok this is a little weird and it doesn't seem to should work this
Where am I going wrong? This doesn't seem to work. I'm trying to specify
How come this doesn't work (operating on an empty select list <select id=requestTypes></select> $(function()
Can anybody tell my why this doesn't work in the Android emulator? From the
First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS
I'm trying to hide the Title field in a list. This doesn't seem to

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.