I'm trying to declare a URL variable but it's giving me the error:
Cannot use instance member 'url' within property initializer; property initializers run before 'self' is available
I'm trying to create a hard coded data so it's fine to write is inside the array, is there a way to do so?
For example inside the array I have many strings "myString"
, can I do that with the URL?
This is my code:
class UserSalonViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
// This is the view to display all posts from all Authors
@IBOutlet var allPostsTableView: UITableView!
// var posts = [UserPosts]()
let url = URL(string: "https://duckduckgo.com/")!
var posts = [
UserPosts(author: "Arturo", postTitle: "Hello World", postDescription: "First Post", postUrl: url, postAddress: "1 NW 1 ave")
]
override func viewDidLoad() {
super.viewDidLoad()
...
What can I do?