Compilation error in declaration of method which accepts input as block with variable number of arguments

Go To StackoverFlow.com

1

When I am declaring a method like this:

- (void)doAnythingWithThisBlock:(void(^)(NSString *, ... NS_REQUIRES_NIL_TERMINATION))AnythingBlock;

It is giving compilation error:

Expected ')'

but when I am declaring it like this:

- (void)doAnythingWithThisBlock:(void(^)(NSString *, ...))AnythingBlock;

It compiles fine and works as expected

Cannot we use - NS_REQUIRES_NIL_TERMINATION while declaring a method which accepts input as block with variable number of arguments?

I am trying it in XCode 4.2

2012-04-04 05:29
by Devarshi
+1 have u resolved this issue - Janak Nirmal 2013-09-06 07:26
hey.. I need to check back.. this I asked a long time back. - Devarshi 2013-09-06 14:04
anyways did you check .. NSString.h.. method declaration of - (instancetype)initWithFormat:(NSString *)format.. it uses NSFORMATFUNCTION(1,2); .. may be you want to have a look on it ; - Devarshi 2013-09-06 14:05


1

I guess NS_REQUIRES_NIL_TERMINATION is only for method declarations 1

However you can try to typedef your block to certain type and pass it as an argument: may be clang will eat it then?

2012-04-05 13:02
by MikeGer
Ads