0

I have a class that allows the user to enter a website name, their account, and password. So this class holds three variables.

The user is going to use this class several times so I want to make an array that holds the information for each time they use the class. I am a beginner student programmer and need help in doing this. If anyone can guide me that would be appreciated!

0

1 Answer 1

0

you can do it like this:

class User
{
    var websiteName: String
    var account: String
    var password: String
    init(websiteName: String, account: String, password: password)
    {
        self. websiteName = websiteName
        self. account = account
        self. password = password
    }
}

And Then for using it on your code:

var users: [User] = []
var maria = User(websiteName: "http://www.stackoverflow.com", account: "User Account", password: "User Password")
users.append(maria)

Array initialization is var users: [User] and as an example I have appended one user for you to see how its done.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.