Lord Vermillion
Lord Vermillion

Reputation: 5424

Swift how to make public variable in NSObject

This is my class:

public class NewsListItem: NSObject {
    var entries: [NewsListEntry]? = []
}

I can parse JSON string into this object using EVReflection:

let newsListItem = NewsListItem(json: responseObject)

But how do i make entries public? I Can't access newsListItem.entries

Upvotes: 0

Views: 852

Answers (1)

Pankaj Bhardwaj
Pankaj Bhardwaj

Reputation: 2131

You can declare and access class variable in a NSObject class like below.

public static var entries = ""

and can acess from class name

print(NewsListItem.entries)

Upvotes: 3

Related Questions