Hi, I have two classes, classA and classB. I have objectC in classA that i want to pass to classB. classB will take a copy of the objectC, make some changes then give the object back so classA can use objectC with the new changes. Here is what i do :
1. Create objectC by doing this : classC *objectC = [self.rows objectAtIndex:0]
2. Create an object of classB : classB *objectB = [[classB alloc] init];
3. Now i give objectB an reference to objectC by setting an property of type classC in classB in this way : objectB.objectC = objectC (i called the name same in both classes).
4. Now that classB has an reference to objectC which came from classA i make a copy of this object by doing this : [self setCopyObjectC:[objectC copy]]. (copyObjectC is an property of type classC just as objectC is).
5. Now i have a copy of the objectC in copyObjectC. I now make some changes to copyObjectC and when i am done i want to give the changes back to the original object which came from classA and that was objectC so i do this : [self setObjectC: copyObjectC].
Now comes the problem. I have studied the console and i see the memory addresses that are used. I see that i actually give objectC a new pointer to some new memory address which i suppose is correct because i have changed the object but when i debug in classA and i look at the objectC from there it still points to a wrong memory address. Why is that ? What am i misunderstanding ? My problem is that i can't see the changes that i made to objectC. It's still the old object.
donnib
1. Create objectC by doing this : classC *objectC = [self.rows objectAtIndex:0]
2. Create an object of classB : classB *objectB = [[classB alloc] init];
3. Now i give objectB an reference to objectC by setting an property of type classC in classB in this way : objectB.objectC = objectC (i called the name same in both classes).
4. Now that classB has an reference to objectC which came from classA i make a copy of this object by doing this : [self setCopyObjectC:[objectC copy]]. (copyObjectC is an property of type classC just as objectC is).
5. Now i have a copy of the objectC in copyObjectC. I now make some changes to copyObjectC and when i am done i want to give the changes back to the original object which came from classA and that was objectC so i do this : [self setObjectC: copyObjectC].
Now comes the problem. I have studied the console and i see the memory addresses that are used. I see that i actually give objectC a new pointer to some new memory address which i suppose is correct because i have changed the object but when i debug in classA and i look at the objectC from there it still points to a wrong memory address. Why is that ? What am i misunderstanding ? My problem is that i can't see the changes that i made to objectC. It's still the old object.
donnib