New Objective C Developer Question

I have searched everywhere to answer this question - perhaps I am looking in the wrong direction. Also, I am new to Objective-C, although I have 10 years experience working as a developer.

for this code:

[receiver makeGroup:group, memberOne, memberTwo, memberThree];

What will the method definition look like?

- (void)makeGroup:(Group *)g, (NSString *)memberOne, ...?

Thanks for any help you can provide. I know that this is probably very simple ...

Thanks R

+3
source share
5 answers

It looks like you have a method that can take a variable number of arguments. If this happens, the definition will look something like this:

- (void)makeGroup:(Group *)g, ...;

See examples of NSString stringWithFormat:or methods NSArray arrayWithObjects:.

: , , Objective-C 2.0 . , , 36.

+4

(...). , , :

+1

, -(void)makeGroup:(Group *)g members:(NSArray *)members. varargs ( ), -(void)makeGroup:(Group *)g members:(NSString *)firstMember, ....

, , :

- (void)makeGroup:(id)group, ...

varags group .

+1

MrHen, , , :

-(void)makeGroup:(Group *)g;
-(NSString *)memberOne;
0
source

EDIT: I answered the wrong question. Ignore this.

The correct way to do this is:

-(void)makeGroup:(Group *)g memberOne:(NSString *)memberOne memberTwo:(NSString *)memberTwo memberThree:(NSString *)memberThree {
    ...
}

The call will look like this:

[receiver makeGroup:group memberOne:memberOne memberTwo:memberTwo memberThree:memberThree];
-1
source

Source: https://habr.com/ru/post/1745849/


All Articles