-1

I am newbie in the driver development so I want to know exactly what does the following line mean in Objective-C

[self sendMsg:[NSData msgWithID:kReqConfiguration subID:0 dest:kAddrThisPanelServer] :YES]; 
zaph
  • 108,117
  • 19
  • 176
  • 215
  • 6
    Can you take a stab at what it means... – Wain Nov 14 '13 at 14:12
  • Take a look: [How can I call a method in Objective-C?](http://stackoverflow.com/questions/591969/how-can-i-call-a-method-in-objective-c) – Amar Nov 14 '13 at 14:17
  • Basic syntactic questions are to be learnt from a book or tutorial, and not asked on Stack Overflow. –  Nov 14 '13 at 15:21

2 Answers2

3

It is a compound statement that can be broken into two statements

[self sendMsg:[NSData msgWithID:kReqConfiguration subID:0 dest:kAddrThisPanelServer] :YES];

becomes:

NSData *message = [NSData msgWithID:kReqConfiguration subID:0 dest:kAddrThisPanelServer];
[self sendMsg:message :YES];

But there is a convention problem with this code. While the method name does not have to be interspersed with arguments it is best practice to do so. In this case there is no method name part prior to the last ":", the method selector (signature) is:

sendMsg::

It would be better declared as:

- (void)sendMsg:(NSData *)msg option:(BOOL)option;

which would have the selector (signature):

sendMsg:option:

and the resulting call would be more understandable as:

NSData *message = [NSData msgWithID:kReqConfiguration subID:0 dest:kAddrThisPanelServer];
[self sendMsg:message option:YES];

What this means is that the method with the selector sendMsg:option: of the same class instance is being called (sent the message) with the arguments message and YES.

zaph
  • 108,117
  • 19
  • 176
  • 215
0

[self sendMsg] .It is a way of calling a method in ios. With sendMsg specifying the name of the method to be called and self is the entity to call the method.

stock
  • 1