Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
December 17, 2017, 10:36:13 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register Chat  
Pages: [1]   Go Down
  Print  
Author Topic: 18.1  (Read 2123 times)
mdeh
Full Member
***
Posts: 166


« on: February 26, 2009, 01:54:27 PM »

Code: (Objective-C)
#import <Foundation/NSObject.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSString.h>
#import <Foundation/NSAutoreleasePool.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableArray *dataArray = [NSMutableArray arrayWithObjects:@"one", @"two", @"three", @"four", nil];
NSMutableArray *dataArray2;

// simple  assignment

dataArray2 = dataArray;
[dataArray2 removeObjectAtIndex: 0];
NSLog(@"dataArray:  ");
for (NSString *elem in dataArray)
NSLog(@"    %@", elem);


NSLog(@"dataArray2:  ");
for (NSString *elem in dataArray2)
NSLog(@"    %@", elem);

// try a copy, then remove the first element of the copy

dataArray2 = [dataArray mutableCopy];
[dataArray2 removeObjectAtIndex: 0];

NSLog(@"dataArray:  ");
for (NSString *elem in dataArray)
NSLog(@"    %@", elem);


NSLog(@"dataArray2:  ");
for (NSString *elem in dataArray2)
NSLog(@"    %@", elem);

[dataArray2 release];
   
    [pool drain];
    return 0;
}
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents ゥ 2009 classroomM.com. All rights reserved.