That worked! Thanks for the help. Was stuck on this for a while!
Post
Replies
Boosts
Views
Activity
I got two errors. Both on the guard let line.
First error was "Cannot convert value of type 'String' to expected argument type 'Plan'". I fixed this by changing the type of plan name from String to Plan.
The second error was "Referencing instance method 'firstIndex(of:)' on 'Collection' requires that 'Plan' conform to 'Equatable'". I added Equatable to the Plan Model but wasn't sure what protocol stubs should be.
The function looks good but since I'm using a UUID for the plan id instead of an Int, I am unable to give it a value when I call it in my view. Is it possible to have planIndex take a UUID instead of an Int? I tried switching the plan id to and Int but would just cause different errors.
I did try that initially but got an error: "Cannot use mutating member on immutable value: 'forPlan' is a 'let' constant".
Got the error "Value of type 'Plan' has no member 'insert'".
It looks like that will add an element to Plan but I want to add an element to exercise which is an array in Plan