gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GDL2] commit and few points


From: David Ayers
Subject: Re: [GDL2] commit and few points
Date: Sun, 17 Apr 2005 16:09:36 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217

Manuel Guesdon wrote:
But doc: http://developer.apple.com/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Library/Frameworks/EOAccess.framework/ObjC_classic/Classes/EOAttribute.html#//apple_ref/occ/instm/EOAttribute/adaptorValueByConvertingAttributeValue:


says that - (id)adaptorValueByConvertingAttributeValue:(id)value Ensures that value is either an NSString, NSNumber, NSData, or
NSDate, ...

As far as I uderstand, it doesn't say that value should be of the
same type than declareted in EOAttribute.

But I may be wrong. How do you undestand it ?

Indeed the wording is not great but what is meant is that it will convert the value to the /corresponding/ class defined by the attribute type.

If you try to pass an NSNumber to an EOAttribute set to EOAdaptorCharacterType in WO45, you will get an exception saying: "... unable to convert value of class NSshortNumber for attribute in entity Book to adaptor type EOAdaptorCharactersType"

And this is what I would expect. It's there to avoid the the following scenario. Take a custom class that declares an NSString ivar. Then have KVC set the attribute to an NSNumber. Then call some method that uses the ivar and is expecting an NSString. You should expect undefined behavior. In fact if you attempt to sort the EO's according to this attribute with compare:, I'm almost certain you get a crash, as compare: is only safe for compatible objects (the implementations often access ivar's directly).

Cheers,
David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]