Re: [F-Script-talk] Subclassing NSManagedObject
Brought to you by:
pmougin
From: Philippe M. <pm...@ac...> - 2007-01-05 21:07:56
|
You're right, F-Script check for the supported keys before generating =20= a valueForKey: message. This is done in the function =20 "sendMsgNoPattern", in file ExecEngine.m (search for NSManagedObject). Note that you may be able to have it work the way you want without =20 customizing F-Script: instead of relying on "valueForUndefinedKey:" =20 you could rely on the "forwardInvocation:" and =20 "methodSignatureForSelector:" methods (see the documentation for =20 NSObject). They act like "valueForUndefinedKey:" but on a more =20 general level (i.e., work for any message, not just for KVC =20 properties). At first glance the documentation for =20 "forwardInvocation:" can be somewhat misleading... In fact, you are =20 not restricted to forwarding messages. You can do whatever you want =20 and manipulate the passed in NSInvocation to return the result you want. Best, Philippe Le 5 janv. 07 =E0 14:50, Tim McDonald a =E9crit : > Happy New Year > > I'm playing around with an implementation of f-script which will make > use of a subclass of NSManagedObject. > > I'm writing a core data program contains an "Items" entity linked via > a one to many relationship to a "Characteristics" entity. The > "Characteristics" entity has two attributes name and value. Each > "Item" may contain a number of characteristics which I was planning > on accessing by subclassing NSManagedObject so I can make use of the > valueForUndefinedKey method to the correct value based upon if the > message matched the name attribute, i.e. > > > Characteristics test > > which would return something like: > > {100, 200} > > Unfortunately, after setting everything up all I got was: > > > Characteristics test > error: an instance of SDTManagedObject does not respond to = "test" > > After playing around with various bit and pieces I finally got it to > work using > > > Characteristics valueForKey: 'test' > {100, 200} > > However I'd prefer to use the more concise commands (ie. "> > Characteristics test"). I'm guessing that these don't work because F- > script first checks what keys an object support's before sending any > message. Could you give me any pointer on what this may be as I think > I'll have to customise this method as well? > > Best Regards > > Tim > > ----------------------------------------------------------------------=20= > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to =20 > share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?=20 > page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV > _______________________________________________ > F-Script-talk mailing list > F-S...@li... > https://lists.sourceforge.net/lists/listinfo/f-script-talk > |