Declare URL in Swift : <p>I'm trying to declare a URL variable but it's giving me the error:</p>

<p><code>Cannot use instance member 'url' within property initializer; property initializers run before 'self' is available</code></p>

<p>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?</p>

<p>For example inside the array I have many strings <code>"myString"</code>, can I do that with the URL?</p>

<p>This is my code:</p>

<pre><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()

...
</code></pre>

<p>What can I do?</p>
