Tom G Tom G - 1 year ago 91
iOS Question

Insert NSMutableArray data into Dictionary with one key and multiple types of values

I have my database stored in NSMutableArray and I want to insert it into Dictionary.

My database have three columns (name, detail, time) and I want it in Dictionary of type:

[String: ([String],[String],[String])]


[firstLetterOfName: ([name],[detail],[time])]

I need the Dictionary to add alphabetic sections into my TableView.

Can it be done? and how?
If I use struct how can I insert my data into the struct?

Answer Source

You can create a struct and then create a dictionary using it.

struct Name {
    var name: String?
    var detail: String?
    var timestamp: Double?

let dictionary = ["summer": Name(name: "Summer", detail: "of", timestamp: 69)]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download