RE: Integers in an NSArray
RE: Integers in an NSArray
- Subject: RE: Integers in an NSArray
- From: "Pierre Bernard" <email@hidden>
- Date: Thu, 27 Feb 2003 14:37:26 +0100
- Thread-topic: Integers in an NSArray
Hi!
Integer is an object, a subclass of number and ultimately a subclass of Object.
int on the other hand is a primitive type like char, long, boolean ...
Integer happens to be a wrapper class for the primitive type int. These wrapper classes are immutable and can thus be used to represent the primitive type where an object is needed. Additionally the object of course also provides a set of convenience methods manipulating their primitive type.
NSArray as well as NSDictionary, Java collections ... work only with objects or arry of objects.
The constructor for NSArray is NSArray(Object[]). It thus works only with an array (data structure) of subclasses of Object.
Thus:
NSArray values = new NSArray(new Integer[]{ new Integer(1), new Integer(0) });
int firstValue = ((Integer) values.objectAtIndex(0)).intValue();
Pierre.
-----Original Message-----
From: Paul Stringer [mailto:email@hidden]
Sent: Thursday, February 27, 2003 2:11 PM
To: email@hidden
Subject: Integers in an NSArray
Hi.... Anyone point me in the right way for creating an NSArray with
Integer values, im fine doing it with Strings but using for example this
which is the closest I can get...
NSArray values = new NSArray(new int[]{1,0});
seems to nest the array object within a single object in the array, a string
doesn9t do this...
Out of interest I cant quite get my head around int and Integer why does
using Integer in this instance create incompatible types..
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.