如何从方法返回多个值 [英] how to return multiple values from a method
本文介绍了如何从方法返回多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有 - (CLLocationCoordinate2D)方法,我想从该方法返回多个位置(这些位置在另一种方法中使用)
我的方法看起来像这样,
I have -(CLLocationCoordinate2D) method, I want to return multiple locations from that method (those locations are using in another method) my method looks like this,
-(CLLocationCoordinate2D) addressLocation{
- --------
----------
return location;
}
是否可以返回多个地点(我的意思是返回 location1,返回 location2 .. .. ?? ??请帮我
谢谢
is it possible to return multiple locations (I mean return location1 , return location2 . . ..) ?? please help me thanks
推荐答案
将您的位置对象添加到数组并返回数组。例如
Add your location objects to an array and return the array instead. e.g.
-(NSArray*) addressLocation{
... // Set your locations up
NSArray *array = [NSArray arrayWithObjects:location1, location2, nil];
... // Do any additional processing and return array.
}
这篇关于如何从方法返回多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文