Re: getting the lastObject value from an NSArray - How to has escaped me
Re: getting the lastObject value from an NSArray - How to has escaped me
- Subject: Re: getting the lastObject value from an NSArray - How to has escaped me
- From: Geoff Hopson <email@hidden>
- Date: Wed, 29 Oct 2003 09:04:18 +0000
EOEditingContext ec = session().defaultEditingContext();
NSArray pictureList = EOUtilities.rawRowsForSQL(ec, "BTT","SELECT COUNT(*) AS COUNT FROM TB_JOB_PICTURE");
if (pictureList.count() > 0) {
// you will only get one record back for a count...
NSDictionary result = (NSDictionary)pictureList.objectAtIndex(0);
Integer picCount = (Integer)result.objectForKey("COUNT");
NSLog.out.appendln("===/r countOfPictureList = " + picCount);
}
You might need to debug around the NSDictionary, see what comes back, what class of object is stored in there, whether the key is uppercase etc., but that should help you.
Geoff
--
Objectology Ltd.
Maidenhead, UK
http://www.objectology.co.uk/
On Wednesday, October 29, 2003, at 07:25AM, Jonathan Fleming <email@hidden> wrote:
>I know this should be very simple but for the life of me I can figure what I
>should be doing.
>I want to get the value form this code please - anyone?
>
>
> EOEditingContext ec = session().defaultEditingContext();
> NSArray pictureList = EOUtilities.rawRowsForSQL(ec,
> "BTT",
> "SELECT COUNT(*)
>FROM TB_JOB_PICTURE");
> /*this statemnet is all wrong*/ int picCount = Integer.parseInt(
>pictureList.lastObject().toString() );
> NSLog.out.appendln("===\r countOfPictureList = " + picCount);
>
>_________________________________________________________________
>Tired of 56k? Get a FREE BT Broadband connection
>http://www.msn.co.uk/specials/btbroadband
>_______________________________________________
>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.
_______________________________________________
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.