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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:08:29+00:00 2026-06-08T04:08:29+00:00

I want to do the following: [Hello <firstname> <middlename> <lastname>. replaceTokensWithStrings: @firstname, someFirstName, @middlename,

  • 0

I want to do the following:

["Hello <firstname> <middlename> <lastname>". replaceTokensWithStrings: 
  @"firstname", someFirstName, 
  @"middlename", middleNameMightBeNilObject,
  @"lastname", lastNameObject];

It looks like this is not possible because of the “nil as a terminator problem”.

However NSLog also takes multiple arguments and can handle nil as parameters too:

NSString *nilValue = nil;

NSLog(@"Value of nilValue=%@", nilValue);

output

Value of nilValue=(null)

So how can I achieve this in my replaceTokensWithStrings:... method?

Update: The signature of my method:

-(NSString *)replaceTokensWithStrings:(NSString *)input, ... NS_SOMETHING_SPECIAL_HERE{
  • 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-08T04:08:31+00:00Added an answer on June 8, 2026 at 4:08 am

    NSLog counts the number of format specifiers (%@, %i, etc.) in its format string (the first argument, the literal string) in order to know how many arguments it should pull off the call stack. This is why it can handle nil arguments — it is using the count to terminate its processing (and, incidentally, why it will often crash if you give it too few arguments).

    Since you have a format-type string, you can do the same thing — just whip up a helper method that counts the number of <something> elements in the string on which replaceTokensWithStrings: has been called, and use the results to limit your processing of the va_list.

    The NS_SOMETHING_SPECIAL in your method declaration would be NS_REQUIRES_NIL_TERMINATION for the case where you’re using nil as a sentinel. You don’t need anything special if you’re getting the count of arguments from somewhere.

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

Sidebar

Related Questions

I have following string hello[code:1], world [code:2], hello world I want to replace this
The following code does not output hello world I do not want to use
I want to do something like the following class A: def static_method_A(): print hello
Hello I want to do the following. I've got a list with checkboxes like
Take the following Java string: Hello, World I want to take that string and
I want to do the equivalent of the following VB in c# Function([class]) hello
Hello Sir i want send list of data to php server i use following
i want the following functionality. input : this is test <b> bold text </b>
Consider the following snippet: puts 'hello'.gsub(/.+/, '\0 \\0 \\\0 \\\\0') This prints ( as
I want to see, Hello {} in the output, but the following gives compiler

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.