Re: ObjC Question - labeled arguments
Re: ObjC Question - labeled arguments
- Subject: Re: ObjC Question - labeled arguments
- From: Andrew Farmer <email@hidden>
- Date: Wed, 21 May 2008 22:09:02 -0700
On 21 May 08, at 21:48, Peter Zegelin wrote:
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.
- (void)reset:(RulerStyle*)newStyle:(int)newSide:(int)textLoc:
(double)newScale;
That syntax is pretty obscure. Try reading it as
- (void)reset:(RulerStyle*)style
newStyle:(int)newStyle
newSide:(int)newSide
textLoc:(double)newScale;
and see if that makes any more sense. (Some of the types seem a little
odd for the argument names, but that's what the method signature reads
as.)
If this still doesn't make sense, check the header file for the code
you're interfacing with.
So my question is - is there a way to include the first label? I
note that the examples in the ObjectiveC manual seem to leave the
first one out also:
[myRect setWidth:10.0 :15.0]; ---> [myRect setWidth:10.0 height:
15.0];
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].
_______________________________________________
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
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden