-1

I have parsed complex JSON with the help of SO community, here's a reference Link

In the end, I got this type of data structure:

class Products {
    let id: String
    var quantities: [(sizeId: String, quantity: String)]?

    init(id: String, quantities: [(sizeId: String, quantity: String)]) {
        self.id = id
        self.quantities = quantities
    }
}

And it saves data fine.

This is new approach for me, as I used structs before, but right now I have class, my question is - How can I access this data later in my app and display it to users?

I have googled and tried standard methods for structs, but no luck. Would be grateful for code samples or any help on this issue. Thanks!

Taras Tomchuk
  • 331
  • 7
  • 19

1 Answers1

-1
var new_elements = Products()
then you can access your variables or you can try NSObject for 

class Offers: NSObject {

    var Offers_Festival_images:String=""
    var Offers_title:String=""
    var Offers_Slider_images=Array<String>()
    var Offers_inner_slider_images=Array<String>()
    var Offers_description:String=""
    var id:String=""
    var date:String = ""
}

for init Value:-
let result:Offers=Offers()
result.Offers_Festival_images=entry["offer_images"].string!
                            result.Offers_description=entry["Description"].string!

result.Offers_title=entry["Festival_name"].string!

result.date = entry["To_ios_date"].string!

How To access:-

for table view or you can use by using for loop

let offer: Offers = dataArray[indexPath.row] as! Offers