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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:51:19+00:00 2026-06-14T19:51:19+00:00

[NSString stringWithFormat:@%@ \n%@ \n%@, self.message1,self.message2,self.message3]; There’s a way to pass only message1 ..2 ..3

  • 0
[NSString stringWithFormat:@"%@ \n%@ \n%@",
 self.message1,self.message2,self.message3];

There’s a way to pass only message1 ..2 ..3 only if not == “” ?

  • 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-14T19:51:20+00:00Added an answer on June 14, 2026 at 7:51 pm

    Just to suggest an alternative and more compact solution:

    [[@[self.message1, self.message2, self.message3]
        filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"length > 0"]]
                componentsJoinedByString:@" \n"];
    

    So unlike Mundi’s solution that:

    1. creates an array of all strings that may be used;
    2. creates a predicate that differentiates between strings you want and strings you don’t want;
    3. creates a second array by filtering the first using the predicate;
    4. asks for all items in the second array to be glued together with a string and a newline in between.

    There are obviously more steps in there so it’ll cost a bit more but for most purposes you really don’t need to care about that nickel and dime stuff.

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

Sidebar

Related Questions

NSString *temp = [self randomBallPick:temp]; the following error: Pass-by-value argument in message expression is
My code is like this : NSString *urlStr = [NSString stringWithFormat:@https://xxx.xxx.xx.xx/Pages/Service/FMService.svc/FileAudit?user=%@&pass=%@&fileId=%d&isAudited=1&opinion=%@,appDelegate.user.userName,appDelegate.user.password,self.todo.fileId,self.opinion]; NSLog(@URL=%@,urlStr); NSURL *url
I have this code: NSString *path = [NSString stringWithFormat:@%@/%@, [[NSBundle mainBundle] resourcePath], @change.mp3]; NSURL
If I create a String with [NSString StringWithFormat], do I have to [retain] it?
Im opening a map like this: NSString *urlString = [NSString stringWithFormat:@http://maps.google.com/maps?q=%@,%@, destLat, destLong]; [[UIApplication
why are we using here 5 parameters for stringWithFormat : return [NSString stringWithFormat:NSLocalizedString(@LatLongFormat, @LatLongFormat),
I currently have this piece of code: NSString *strURL = [NSString stringWithFormat:@http://www.sample.com /phpFile.php?firstname=%@,txtfirstName.text]; NSString
How do I use the % character literal in an NSString stringWithFormat ? I
I'm having a really basic problem with NSString stringWithFormat. I want to take the
When I run the code below NSString *chemin; chemin = [NSString stringWithFormat:@chapitre0%d, [sender tag]];

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.