| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
I have just been following the tutorial in the "Learning Cocoa" book and had problems with the follow code:
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableArray *myArray = [[NSMutableArray alloc] init];
[myArray addObject: @"Here's a string"];
int itemCount;
itemCount = [myArray count];
NSString * myString;
myString = [myArray objectAtIndex: 0];
[myArray insertObject: @"Hello2" atIndex: 0];
[myArray exchangeObjectAtIndex: 0 withObjectAtIndex: 1];
// insert code here...
NSLog(@"Hello, World!");
NSLog(@"Array description: %@ items.\n", myArray);
[myArray release];
[pool release];
return 0;
}
which gives me the following result:
main.m:10: illegal expression, found `int'
cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
main.m: In function `main':
main.m:10: parse error before `int'
main.m:11: `itemCount' undeclared (first use in this function)
main.m:11: (Each undeclared identifier is reported only once
main.m:11: for each function it appears in.)
main.m:13: parse error before `*'
main.m:14: `myString' undeclared (first use in this function)
the gcc version as provided by "cc -v" is: "Apple Computer, Inc. version gcc-926, based on gcc version 2.95.2 19991024 (release)".
Who is right, the book or the compiler?
Andre
--
mailto:email@hidden
_______________________________________________
darwinos-users mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/darwinos-users
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.