0
        Match *aMatch = [appDelegate.matchScoresArray 
objectAtIndex:numMatchCounter];
        aMatch.teamName2 = TeamNameHolder;
        [appDelegate.matchScoresArray replaceObjectAtIndex:NumMatchCounter 
withObject:aMatch];
        numMatchCounter++;

Does this make sense or is the change i made to teamName2 already reflected in the array, since they are the same object?

Or am I right to copy the object over itself back into the array.

I'm really confused.

Thanks -Code

2 Answers 2

4

You should grab the object from the array and update it. There is no need to copy over it.

You can grab a reference to the object and update it. The variable aMatch points to the same memory location as the object referenced in your array.

The following should be fine:

Match *aMatch = [appDelegate.matchScoresArray 
objectAtIndex:numMatchCounter];
        aMatch.teamName2 = TeamNameHolder;
Sign up to request clarification or add additional context in comments.

Comments

0

You shouldn't need to copy the object back into the array. The array holds a refernece to the object. aA long as the object instnace remains the same there is no need to copy it back after changing it's properties.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.