An array exists (named visits) which stores instances of Visit.
Scenario: A user click a button, enters a number, and that number is stored as a property on a newly created visit as a member of visits.
This is my code:
[visits addObject: [visits lastObject]];
Visit * lastVisit = [visits lastObject];
lastVisit.examDate = [NSLocale currentLocale];
lastVisit.edss_numeric = 5.5;
On inspection, I expected to have added a new visit to the end of my visits array (which it did) but the original last visit was then updated with the information I wanted to be set for the true last visit. In short, the last two visits are now identical and the originally copied visit changed (when it should not have).
What fundamentals of objective C am I not understanding and how can I fix this to achieve my desired results?
examDatedefined with a type ofNSLocale? Date and locale are two completely different things.