Elidotnet Elidotnet - 5 months ago 17
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
List<>
like C# in Swift 2?

struct....{
var road_id:String
???????? how?

Answer
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.

Comments