So I'm wondering what happens when I do it
NSMutableArray * Arr1 = [[NSMutableArray alloc] init]; NSMutableArray * arr2 = [[NSMutableArray alloc] init]; [AR1 adobect: OB1]; Arr2 = arr1; [Self change value: [AR2 object atindex: 2]]; // will modify the function that has been sent to it
1) Can I also = in the middle? = 2) If I was using Object in 1 and 1, will it be modified?
3) How deep is this? - If I want to access that object from some other place, will it be modified?
4) I'm using a mutual coop, which will completely return the new array.
5) Anyway add this deep / simulation to add? For example, if I want to give the same object to 2 different arrays, then if I have modified one, can it change that object in both arrays?
6) What does this mean? I do not think this is link / link.
Thanks a lot - Jamaica
I think that You are confused objects and variables you do not specify one object in another; You assign objects to the variable Variables is a way of looking at an object, which otherwise would float somewhere in your program memory space. Two variables can point to the same object, and when this happens, then yes, you can see the change in the object through both the variables, because this is the same object . When you do arr2 = arr1 , you're passing arr2 point to the same array array1, so if you change something in arr1, will you see it in AR2 ? Yes, because arr2 is arr1 . This is the same thing, which is also called two different names. Instead it was arr2 = [arr1 mutableCopy] , yes it would create a new array object, so two variables would be pointing to different objects If you add an object to an array, it is not magically added to the other but it raises the question: What if arr1 has a bunch of NSMutableStrings? Changing one of the strings in Arr1 will also change the same string in AR2? Yes, because although the array itself is a different object, it still has the same object as the original Aare. Therefore, the way to think about this is by connecting or connected in two ways. The only question you need to ask is, "Are these objects that I am talking in two places in the same thing or in different parts?"
No comments:
Post a Comment