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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:57:04+00:00 2026-05-14T15:57:04+00:00

I’ve just written a piece of code to display a UIActionSheet within my app.

  • 0

I’ve just written a piece of code to display a UIActionSheet within my app. Whilst looking at the code to initialise my UIActionSheet something struck me as a little strange. The initialisation function has the following signature…

initWithTitle:(NSString *)title delegate:(id UIActionSheetDelegate)delegate cancelButtonTitle:(NSString *)cancelButtonTitle destructiveButtonTitle:(NSString *)destructiveButtonTitle otherButtonTitles:(NSString *)otherButtonTitles

As you can see the otherButtonTitles parameter is a pointer to a String. In my code I set it as follows…

otherButtonTitles: @"Title", @"Date", nil

Although this compiles fine I don’t really understand how it works. My reading of the statement is that I have created an inline array containing two elements (Title and Date). How come this then compiles? I’m passing a NSArray* in place of a NSString*. I know from a little of understanding of C++ that an array is really a pointer to the first element. So is this inline array that I’m creating a C array as opposed to a NSArray?

What I’m hoping to achieve is to be able to pass a static NSArray* used elsewhere in my class to the otherButtonTitles parameter. But passing the NSArray* object directly doesn’t work.

  • 1 1 Answer
  • 2 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-14T15:57:05+00:00Added an answer on May 14, 2026 at 3:57 pm

    There’s no NSArray involved, and the method signature you quoted is incomplete. The actual signature is

    … otherButtonTitles:(NSString *)otherButtonTitles, ...;
    //                                               ^^^^^
    

    The , ... indicates variadic function (varargs), which means arbitrarily many arguments may be supplied after otherButtonTitles.

    This is a C feature. The called function can receive the arguments using methods in stdarg.h. Since ObjC is a superset of C, varargs is supported for ObjC methods as well, using the , ... as shown.

    For example, varargs is also used in +[NSArray arrayWithObjects:] and +[NSString stringWithFormat:] (which may be your confusion that an “array” is passed).


    If you have an NSArray, you could insert the buttons after the action sheet is created using -addButtonWithTitle:.

    for (NSString* title in array)
       [actionSheet addButtonWithTitle:title];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.