First, I'm going to assume you didn't want 2d arrays. If you did, I'll answer your question from that perspective below.
var foundation = [baseMakeUp]()
Creates an empty array of baseMakeUp called foundation. You can't use subscripting to add elements to an array, you can only use it to change existing elements. Since your array is empty you add elements with append.
foundation.append(baseMakeUp(Brand: "Brand", Color: "Color"))
Since you don't have a baseMakeUp initializer that allows you to pass a rating that element's rating is 0. However since you appended it to your array you can now use subscripting to change it's Rating variable like this:
foundation[0].Rating = 3
If you did intend for 2d arrays.
var foundation = [[baseMakeUp]]()
To create the array
foundation.append([])
foundation[0].append(baseMakeUp(Brand: "Brand", Color: "Color"))
foundation[0][0].Rating = 3
The first line appends an empty array to your top level array. The second line appends a baseMakeUp to the array added in the first line. The third line uses subscripting to change the Rating of the first element in the first array of your 2d array.
Hopefully that helps with your problem.
Additionally
I was going to add points 1 and 2 from jday001s answer here, but you should check out their answer as well.
Edit
I just realized that you're trying to add elements to your arrays in the wrong scope.
You'll have to move your
foundation.append(baseMakeUp(Brand: "Brand", Color: "Color")
inside a function and call it yourself or place them inside something like viewDidLoad
eg:
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
var foundation = [baseMakeUp]()
override func viewDidLoad() {
super.viewDidLoad()
foundation.append(baseMakeUp(Brand: "Brand", Color: "Color")
foundation[0].Rating = 3
}
}
Hopefully that's helpful.