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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:20:09+00:00 2026-06-15T11:20:09+00:00

The following code gets me the result I want in the NSLog but there

  • 0

The following code gets me the result I want in the NSLog but there must be an easier way to do this? I’m also getting a ‘format string is not a string literal’ error, which still builds okay.

NSString *levelstring1 = @"Level ";
NSString *levelstring2 = [NSString stringWithFormat:@"%d", levelscore];
NSString *levelstring3 = @" (";
NSString *levelstring4 = [NSString stringWithFormat:@"%d", xpscore];
NSString *levelstring5 = @"/";
NSString *levelstring6 = [NSString stringWithFormat:@"%d", (levelscore*(levelscore+1)*100)];
NSString *levelstring7 = @")";

NSString *levelstringfinal = [[[[[[levelstring1 stringByAppendingFormat:levelstring2]stringByAppendingFormat:levelstring3]stringByAppendingFormat:levelstring4]stringByAppendingFormat:levelstring5]stringByAppendingFormat:levelstring6]stringByAppendingFormat:levelstring7];

NSLog(@"Level is %@",levelstringfinal);

The end result looks something like this: Level 1 (50/100).

  • 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-15T11:20:11+00:00Added an answer on June 15, 2026 at 11:20 am

    You can combine them into something like:

    NSString *levelstringfinal = [NSString stringWithFormat:@"Level %d (%d/%d)", levelscore, xpscore, (levelscore*(levelscore+1)*100)];
    

    The warning you’re getting is because the compiler can’t check a variable’s content, whereas with a string literal it can match placeholders and variables for some degree of consistency.

    (Even if you had to build the string in pieces, the last line would be better using stringByAppendingString rather than stringByAppendingFormat because those are no longer format specifiers.)

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

Sidebar

Related Questions

Following code gets executed whenever I want to persist any entity. Things seems to
Hi I have the following code, the filter call back gets called but the
Given the following code: QList<Vertex*> _vertices; //this gets filled //at some other point i
The following code gets a 'report line' as an array and uses fputcsv to
The following code gets a JSON object and then spits its contents out into
I have just started using jQuery and although following code gets the job done,
I have the following code that gets the MAC address of an interface: static
In PHP I have the following code that gets a file submitted through CGI:
I have the following php code that gets a serialized array from a mysql
I have the following code in a Runnable that gets passed to a thread

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.