Elidotnet Elidotnet - 1 year ago 79
JSON Question

Swift equivalent to C# List

I am a c# programmer and I am trying to build a native app using Swift 2.

public class ApiRoadsInfo

public string road_id { get; set; }
public List<RoadInfo> road_info { get; set; }
public List<Comment> comments { get; set; }


My question is: how do I create
like C# in Swift 2?

var road_id:String
???????? how?

Answer Source
let road_info : Array<RoadInfo> = Array<RoadInfo>()

or with the Swift shorthand:

let road_info = [RoadInfo]()

Please read the language guide. It's quite concise and very well written. It'll introduce you to most of the basics you'll need to get started with Swift.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download