Amazon.com Widgets 18.1
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 24, 2014, 04:47:56 PM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Program Examples
| | |-+ Chapter 18
| | | |-+ 18.1
Pages: [1] Go Down
Print
Author Topic: 18.1 (Read 1431 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:



Login with username, password and session length

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 (c) 2009 classroomM.com. All rights reserved.