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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top