First off its not good practice to define 191 variables. Use Dictionary instead where keys are: lat1, lat2 .... lat191.
After that you can loop over Dictionary values and manipulate with them.
But if you still want to aggregate all variables to Array you can use class_copyIvarList to fetch all variables start with lat and write as:
class Myclass : NSObject{
var lat1:CLLocationDegrees = 50.102760
var lat2:CLLocationDegrees = -26.135170
var lat3:CLLocationDegrees = 60.289139
var AirportLat:Array<CLLocationDegrees> = []
func fetchValues() -> Array<CLLocationDegrees>{
var aClass : AnyClass? = self.dynamicType
var propertiesCount : CUnsignedInt = 0
let propertiesInAClass : UnsafeMutablePointer<Ivar> = class_copyIvarList(aClass, &propertiesCount)
for var i = 0; i < Int(propertiesCount); i++ {
var propName:String = NSString(CString: ivar_getName(propertiesInAClass[Int(i)]), encoding: NSUTF8StringEncoding)
var propValue : AnyObject! = self.valueForKey(propName)
if propName.hasPrefix("lat") {
AirportLat.append(propValue as CLLocationDegrees)
}
}//for
return AirportLat
}
}
var cc = Myclass()
cc.fetchValues()
Output:
[50.10276, -26.13517, 60.289139]
Comment: the class must inherit NSObject
CLLocationCoordinate2D(latitude and longitude) structs instead of justCLLocationDegrees. Even better would be to create anAirportclass with aCLLocationCoordinate2Das one of the properties (as well as the airport name, airport code, etc).