Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- public struct User {
- let name: String
- let gender: String
- let email: String
- }
- public class UserManager {
- //set array of users (in reality this is usually from a network call
- public var users: [User] = [User(name: "Albert", gender: "Male", email: "albert@gmail.com"), User(name: "Bob", gender: "Male", email: "bob@gmail.com"), User(name: "Celine", gender: "Female", email: "celine@gmail.com"), User(name: "Derrick", gender: "Male", email: "derrick@gmail.com"), User(name: "Aldwin", gender: "Male", email: "aldwin@gmail.com")]
- //return total count
- public var userCount: Int {
- return users.count
- }
- //get user
- public func getUser(at index:Int) -> User {
- return users[index]
- }
- public func deleteUser(at index: Int) {
- users.remove(at: index)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement