Hi all,
I'm new to this objective C and I thought I understood what I was doing, but apparently not. here is a simplified sample of my problem:
I have two objects:
MyObj* obj1 = [[MyObj alloc] initWithMyData:X];
MyObj* obj2 = [[MyObj alloc] initWithMyData:Y];
I wanted to switch the content of the two items with the following simple code:
MyObj* temp = obj1;
obj1 = obj2;
obj2 = temp;
so when I look at the address, obj1 now hold the address of what was previously obj2 and obj2 hold the address of obj1
looks like what I wanted right? NO
the data inside obj1 is the same data as before. and same for obj2:
obj1.data is still X as initilized with but address of what was obj2
obj2.data is still Y as initilized with but address of what was obj1
so how come when I replaced the pointers the data stayed the same?
Thank you in advance for any help
I'm new to this objective C and I thought I understood what I was doing, but apparently not. here is a simplified sample of my problem:
I have two objects:
MyObj* obj1 = [[MyObj alloc] initWithMyData:X];
MyObj* obj2 = [[MyObj alloc] initWithMyData:Y];
I wanted to switch the content of the two items with the following simple code:
MyObj* temp = obj1;
obj1 = obj2;
obj2 = temp;
so when I look at the address, obj1 now hold the address of what was previously obj2 and obj2 hold the address of obj1
looks like what I wanted right? NO
the data inside obj1 is the same data as before. and same for obj2:
obj1.data is still X as initilized with but address of what was obj2
obj2.data is still Y as initilized with but address of what was obj1
so how come when I replaced the pointers the data stayed the same?
Thank you in advance for any help