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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:41:34+00:00 2026-05-25T18:41:34+00:00

I would like to create a subclass of UIActionSheet that uses blocks instead of

  • 0

I would like to create a subclass of UIActionSheet that uses blocks instead of delegation. So I created the following class:

#import <UIKit/UIKit.h>

// Public Interface
typedef void (^FJActionSheetCompletion)(int buttonIndex);

@interface FJActionSheet : UIActionSheet

- (id)initWithTitle:(NSString *)title 
    completionBlock:(FJActionSheetCompletion)completionBlock
  cancelButtonTitle:(NSString *)cancelButtonTitle 
destructiveButtonTitle:(NSString *)destructiveButtonTitle 
  otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;

@end

// Private Interface
@interface FJActionSheet() <UIActionSheetDelegate>
{
    FJActionSheetCompletion _completionBlock;
}
@end

// Implementation
@implementation FJActionSheet

- (id)initWithTitle:(NSString *)title 
    completionBlock:(FJActionSheetCompletion)completionBlock
  cancelButtonTitle:(NSString *)cancelButtonTitle 
destructiveButtonTitle:(NSString *)destructiveButtonTitle 
  otherButtonTitles:(NSString *)otherButtonTitles, ...
{
    self = [super initWithTitle:title
                       delegate:self
              cancelButtonTitle:cancelButtonTitle
         destructiveButtonTitle:destructiveButtonTitle
              otherButtonTitles:otherButtonTitles];

    if (self)
    {
        _completionBlock = [completionBlock copy];
    }

    return self;
}

- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    _completionBlock(buttonIndex);
}

@end

This works except for one problem: I can not pass multiple strings for otherButtonTitles. If I do it as above, I (obviously) get a “Missing sentinel in method dispatch”.

My question is: How can I pass the otherButtonTitles argument to the initializer of UIActionSheet?

  • 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-25T18:41:35+00:00Added an answer on May 25, 2026 at 6:41 pm

    see this great blog post about variadic methods. Mainly how to access the variable arguments by using

    va_list args;
    va_start(args, firstArg);
    va_arg(args, NSString*)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a class that runs something (a runnable) at regular
i would like to create a custom View (subclass of the View class) and
I would like to create my own subclass of UIImage that would allow me
I would like to create a c++ type that mimic the build-in type exactly.
I would like to create a subclass of python's unittest.Testcase called BasicTest. I would
I am looking to create a Custom UIButton (not subclass) progrmatically, I would like
I have class Dad with subclass Son . I'd like to create a subclass
I would like to create a subclass of DispatcherObject to create my own thread-affined
I would like to create some instance variables for my model subclass, but when
So I have five different UIViewController that I would like to create. Each of

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.