Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray and Objects



malcom <email@hidden> wrote:

>I have created an NSArray with NSColor objects.
>Now i would to set a color with an element of this array, but the
>compiler said to me:
>"incompatible types" (method ObjectAtIndex -> return an Object).

The method NSArray.objectAtIndex(int) returns the type Object. If you know
it's an NSColor, then cast it to an NSColor:
NSColor color = (NSColor) someNSArray.objectAtIndex( i );

Also note that the method-name is objectAtIndex, not ObjectAtIndex. Case
is important.

These are such basic questions you should probably review the basics of the
Java language, or go through a tutorial, such as:
<http://java.sun.com/docs/books/tutorial/>


I also strongly recommend looking at Apple's sample code:
<http://developer.apple.com/samplecode/Sample_Code/Cocoa.htm>
<http://developer.apple.com/samplecode/Sample_Code/Java.htm>

Or just start with the Developer Technical Resources page and go exploring:
<http://developer.apple.com/technical/>

You may also find the Cocoa-dev mailing-list useful:
<http://www.lists.apple.com/mailman/listinfo/cocoa-dev>

Or any of Apple's other mailing-lists:
<http://www.lists.apple.com/mailman/listinfo/>

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



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.