Question

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"?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top