Getting A Value From An NSArray
Getting A Value From An NSArray
- Subject: Getting A Value From An NSArray
- From: "Jonathan Fleming" <email@hidden>
- Date: Tue, 06 Jan 2004 08:19:58 +0000
I've build a fetchSpec which returns several rawRow elements in the NSArray,
however, if I try to get those individual values out of the array I run into
these errors:
*** this is the value of the NSArray named queryResults:
({tbNavPage.tbAdminUserID = 6; tbNavPage.tbAdminUser.firstName = "Jessica";
tbNavPage.tbAdminUser.lastName = "Stanley";
tbNavPage.tbAdminUser.companyName =
<com.webobjects.foundation.NSKeyValueCoding$Null>; tbNavPageID = 33;
tbNavPageContentID = 18; tbNavPage.tbAdminUser.tradeStatus = "Tradesmen";
tbNavPage.tbAdminUser.tbAdminUserID = 6; })
/*------------------*/
// if I run this code I get the error below it
String _lastName = String.valueOf(
((NSDictionary)queryResults.valueForKeyPath(
"tbNavPage.tbAdminUser.lastName" )).toString() );
/*
com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException:
valueForKey(): lookup of unknown key: 'tbAdminUser', yet the key path is in
the array
*/
/*------------------*/
// if I run this code I get the result below it (this is the only one I can
get a result from)
String _companyName = String.valueOf(
((NSDictionary)queryResults.objectAtIndex( 0
)).allValues().lastObject().toString() );
/*
the result produced: 6
*/
/*------------------*/
// if I run this code (trying to get lastName) I get the error below it
String _lastName = String.valueOf(
((NSDictionary)queryResults.objectAtIndex( 2
)).allValues().lastObject().toString() );
/*
Error: java.lang.IllegalArgumentException: Index (1) out of bounds [0, 0]
Reason: Index (1) out of bounds [0, 0]
*/
/*------------------*/
What's the correct way to get the value's directly from an NSArray without
using a WORepition and it's index binding
Kind regards
Jonathan :^)
_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
_______________________________________________
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.