Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a limit to the amount of arguments I can pass to a method?

I am just wondering if there is a limit to the amount of arguments I can pass to a method in Objective-C using the following style:

- (void)example:(int)i forTime:(int)i forDate:(NSDate *)date etc etc

This is of course hypothetical, but I just find it interesting to know the reason behind such limitations (for example the character limit in URL's and such), and I love to see other people's opinions on questions like these on StackOverflow

And even with a limit on the number of arguments allowed to be passed, would it still be possible to pass NSArray's containing objects as arguments and then just call on these objects from the array in the method using objectAtIndex?

like image 520
Conor Taylor Avatar asked Sep 06 '12 08:09

Conor Taylor


1 Answers

I quickly wrote a short program in C to generate a test method and call based on the desired inputted number of arguments, as per Hot Licks suggestion. Just made a method that takes 1,000 NSNumber arguments and it worked fine. Took up two pages in Xcode on my monitor, but it ran with no warnings or anything. Might try 10,000 later, but it seems there are no limits other than any imposed by hardware capabilities, etc.

like image 119
Metabble Avatar answered Sep 28 '22 23:09

Metabble