Elidotnet Elidotnet - 2 years ago 102
JSON Question

Create lists using swift2

i am programming with c# and i am trying to build some native app using swift 2. If i want to get JSON data from API (c#) i am creating some classes and inside the class i can create Lists. example:

public class ApiRoadsInfo


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


My question, how to create List<> like C# in swift2?

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