After all the talk about the best way to learn Cocoa I thought I'd
better brush up on my obj-c. I've been able to get an amazing
distance without really understanding a lot as I am mainly using
Cocoa as a gui around some C++ code and have been able to get a
long way just by wiring things up in IB and reusing some example
code. However when messaging an object with multiple parameters I
have never been able to use labeled arguments - only unlabeled.
However on a hunch I removed the first label and it worked.
Brush up on your syntax a bit. You seem to misunderstand how ObjC
method calls work.
They shouldn't - that's invalid. Every "label" is a component of the
method name - [myRect setWidth:10.0 height:15.0] is calling a
completely separate method from [myRect setWidth:10.0 somethingElse:
15.0].
Well that example is straight out of the manual:
"Methods can also take arguments. The imaginary message below tells
myRect to set its location within
the window to coordinates (30.0, 50.0):
[myRect setOrigin:30.0 :50.0];
Here the method name, setOrigin::, has two colons, one for each of its
arguments. The arguments
are inserted after the colons. This method name uses unlabeled
arguments. Unlabeled arguments
make it difficult to determine the kind and purpose of a method’s
arguments. Instead, method names
should include labels describing each of their arguments. Argument
labels precede each colon in the
method name. The setWidth:height: method, for example, makes the
purpose of its two arguments
clear:
[myRect setWidth:10.0 height:15.0]; "
regards,
Peter
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com