Re: Set String methods for Flattened Relationship Attributes
Re: Set String methods for Flattened Relationship Attributes
- Subject: Re: Set String methods for Flattened Relationship Attributes
- From: Lachlan Deck <email@hidden>
- Date: Thu, 20 Oct 2005 12:34:39 +1000
Hi there,
On 20/10/2005, at 12:16 PM, David LeBer wrote:
So. Here is some thoughts:
You are writing too much code. Learn NSDictionary, NSArray, and NSSet
[ insert ]
_and_ their mutable counterparts (NSMutable<...>)
you'll be glad you did.
After that, learn NSKeyValueCoding interface (implemented by various
NS/EO classes). You'll be doubly glad you did.
public String stringFromArray(NSArray array){
NSSet aSet = new NSSet(array);
return aSet.allObjects().componentsJoinedWithString(",");
}
That'd be componentsJoinedByString...
If you need to accept comma separated strings of your values to go
back to your database again (yuck, think really hard about why you
need this) you will need to write a method to turn the string back
into an array before moving forward.
Take a look at: NSArray.componentsSeparatedByString(String
components, String separator)
Or if the array is formatted such as '("item0", "item1", ..., "itemN")'
NSPropertyListSerialization.arrayForString( str )
But!
I think this is a really lousy idea. For you to be able to go from
a string back to your array of serverContracts (and then to their
contact.fullNames) you will need to guarantee that the order of the
serverContracts array has not changed. I cannot do that, can you?
Didn't you mention learning something about some class above? NSD... ;-)
Really. You should try to keep objects as objects for as long as
possible, when you reduce them to something flat you lose their
identity and then it become really hard to return.
Very true...
with regards,
--
Lachlan Deck
(formerly LD)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden