Hi,
I was building a personal project then I hit this rock. I tried to change constraints of top anchor and height of a view to fix in iPhone SE but it is not working. I am doing it programmatically
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am having problem displaying data on the table view cell
These are my code:
struct Person: Codable {
var firstName: String
var lastName: String
}
class viewController: UIViewController {
var newPerson = [Person]()
override func viewDidLoad() {
let person = [Person(firstName: "Peterson", lastName: "Jota") , Person(firstName: "John", lastName: "Paul")]
let encoder = JSONEncoder()
if let encoded = try? encoder.encode(person) {
UserDefaults.standard.set(encoded, forKey: "savedPerson")
}
}
}
var person = [Person]()
func tableView( tableView: UITableView, numberOfRowsInSection section: Int) - Int {
return person.count
}
func tableView( tableView: UITableView, cellForRowAt indexPath: IndexPath) - UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath) as! UITableViewCell
cell.textLabel?.text = person[indexPath.row]
return cell
}