|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
What is the logic of "no label" for 1st argument of a function
Curious to know, if there is any logic behind the syntactical structure, where 1st argument is not labelled, but following arguments only need labelling ?
Code:
[myObject myFunction:firstArgument theSecondArgument:secondArgument]; Or is it just how it is made. There is no logic. ? |
|
|
|
0
|
|
|
#2 |
|
Typically if you were to create a method signature it would be something that would label the first argument itself. This can be seen with almost any of apples method signatures.
Code:
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCELL_IDENTIFIER]; Another such example in MKMapKit, imagine _mapView is an MKMapView reference. Code:
[_mapView convertCoordinate:coordinate toPointToView:self.view]; The logic behind the naming is to be descriptive that is the nature of Objective-C.
__________________
2.4 MacBook Aluminum 480GB SSD/750GB Optibay 8GB RAM CE | MacBook 2.4 SR 4GB, 320GB HD | PB G4 1.67 | 15 TiBook-DVI 800 iPhone 4S 16GB | iPhone 5 32GB
|
|
|
|
1
|
|
|
#3 |
|
ok, thnx for explanation.
However, when i think something like this : Code:
[ mathObj addTheNumbers:number0 number1:number1 ]
|
|
|
|
0
|
|
|
#4 |
|
Wouldn't it be better to pass that in another way?
__________________
2012 11" MBA i7/8/256 2011 Mac Mini with 27" Thunderbolt Display Black iPad Mini 32GB Verizon Black iPhone 5 32GB ATT
|
|
|
|
0
|
|
|
#5 |
|
If I were writing that method I would most likely name it some to this affect.
Code:
[mathObj add:sumNumber to:sumNumber];
__________________
2.4 MacBook Aluminum 480GB SSD/750GB Optibay 8GB RAM CE | MacBook 2.4 SR 4GB, 320GB HD | PB G4 1.67 | 15 TiBook-DVI 800 iPhone 4S 16GB | iPhone 5 32GB
|
|
|
|
0
|
|
|
#6 |
|
Shouldn't that be a class method instead of an instance method?
|
|
|
|
0
|
|
|
#7 | |
|
Quote:
In that case it would be: Code:
int add(int x, int y)
{
return x + y;
}
Code:
int result; result = add(10, 20);
__________________
2.4 MacBook Aluminum 480GB SSD/750GB Optibay 8GB RAM CE | MacBook 2.4 SR 4GB, 320GB HD | PB G4 1.67 | 15 TiBook-DVI 800 iPhone 4S 16GB | iPhone 5 32GB
|
||
|
|
0
|
|
|
#8 |
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 12:21 AM.








2012 11" MBA i7/8/256
Linear Mode
