iphone - Test to Understand Objective-C Vs Pointers -


i have wrote test code understand objective c vs c pointers. here code..

eg:

    nsmutablearray *array = [[nsmutablearray alloc] init];     nsmutablearray *sec_mut;     if (array) {         [array addobject:@"my"];          [array addobject:@"name"];          [array addobject:@"is"];          [array addobject:@"bob"];              sec_mut = [[nsmutablearray alloc] init];              if (sec_mut) {                 (id obj in array) { // allocating new object , adding or points existing memory (just adding address)?                     [sec_mut addobject:obj];                  }             }     }      [array removeobjectatindex:0];      (id obj in sec_mut) {         nslog(@"str %@\n",obj);     } 

output: str str name str is str bob

even though i've deleted object @ index 0 4 object displaying in new array, not pointing , having own object, right? or dangling pointer?

thanx

when inserting objects cocoa collections, objects not copied, retained. (i. e., yes, pointers used reference objects.)


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -