Method with multiple input parameters

后端 未结 6 1869
萌比男神i
萌比男神i 2021-02-01 02:11

I understand how to create my own methods that accept input parameters in objective-c but I have never actually created a method with more than one input parameter!

From

6条回答
  •  生来不讨喜
    2021-02-01 02:44

    fullName:(NSString, NSString, NSString) fname, mname, lname;
    

    Yes, you can do something like that. It'd look like this instead:

    -(void)fullName:(NSString*)fname :(NSString*)mname :(NSString*)lname
    

    and you'd call it like this:

    [foo fullName:first :middle :last];
    

    That largely defeats the point of Objective-C's method names, though, and the main reason to do something like that is to register your dislike of the normal Objective-C convention, or perhaps to get yourself kicked off whatever project you're working on.

提交回复
热议问题