MikeS
MikeS

Reputation: 3921

Objective-C Strange Method Declaration

I was recently looking at some old source code from another company's project and came across the following method definition:

-(double)getDistance :Latitude :Longitude

I understand what the method does, but I've never seen an Objective-C method declared like that... Even if the incoming object's type was unknown, I would expect something more along these lines:

- (double)getDistanceWithLatitude:(id)latitude longitude:(id)longitude

Could somebody give me the nitty gritty details on exactly how -(double)getDistance :Latitude :Longitude "works"?

Upvotes: 2

Views: 86

Answers (1)

user529758
user529758

Reputation:

If omitted, the type defaults to id. You can do this with the return type as well. It looks horrible in my opinion, and it's not the clearest notation - you should typically avoid using it. It's an ancient, obsolescent heritage.

Upvotes: 4

Related Questions