Re: Parts of a Method
Re: Parts of a Method
- Subject: Re: Parts of a Method
- From: Isaac Sherman <email@hidden>
- Date: Tue, 13 Aug 2002 02:51:43 -0400
on 8/13/02 1:34 AM, the method -(id)email@hidden:(id)
sender:@"Brendon Bruns"; returned:
>
- (float)convertAmount:(float)amt atRate:(float)rate;
>
>
Now, why would there be three "(floats)" in this method? I can see that
>
(float)amt and (float)rate are both arguments that would hold a number (I
>
believe argument is the correct word.) Is the first (float) referring to
>
the type of value that is returned from the method? And is convertAmount:
>
atRate: just referring to the name of the method that is called by a
>
message?
I think I understand your questions. Yes. The first part -(float) refers
to the return value. So, when you multiply amt by rate, you still have a
float.
As for the second, I think the answer is another yes. But more
specifically, it refers to the signature of the method; you could have
multiple methods with the name convertAmount, but different arguments (for
instance, :(int) amount atRate:(float) rate; or :(NSNumber *) amount...
etc.,). This is name mangling, which is the heart and soul of OOP! Not
really, just a useful throw off, but still, at the least, a principle of
OOP.
I hope this helps somewhat, and I would recommend getting yourself a good
book on C programming. I learned from the C Primer Plus, but that's
probably not the best choice.
Take care,
--
Isaac Sherman
MotaSoft Software
http://homepage.mac.com/huperzoevs/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.