• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSValueTransformer and context question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSValueTransformer and context question


  • Subject: NSValueTransformer and context question
  • From: Ken Victor <email@hidden>
  • Date: Sun, 4 Dec 2005 13:37:04 -0800

my environment:
multi doc, multi window core data app

several windows have an NSTableView bound to an NSArrayController

the NSArrayController gets it managedObjectContext from the file's owner (in the nib file) which is my subclass of NSPersistantDocument

what i'd like to do:
for some columns, i'd like to be able to use a subclass of NSValueTransformer to transform a value (an int) from my db into a date. the transformation requires access to the "owning" document.

what i tried:
in my nib file, i instantiated MyValueTransformer

MyValueTransformer has an outlet connected to the file's owner

in [MyValueTransformer awakeFromNib] i called [NSValueTransformer setValueTransformer: self forName: @"MyValueTransformer"]

in my nib, i set the value transformer for the appropriate columns to MyValueTransformer

the results:
this worked fine as long as only one document was open and i didn't close any windows that took advantage of this setup.

but, if i did close one of those windows, then my transformer associated with the closed window is deallocated, and since transformers are accessed via their registered names, things "broke down" :-)

(actually, i was a little surprised that it worked as well as it did!)

what i've done as a temporary(?) solution:
i've implemented another accessor in my subclass of NSManagedObject that actually does the transformation i want and bound the column to this key (instead of to the key for the value in the db). this works fine... but...

what i'd prefer to do / question
i'd prefer somehow to use a value transformer rather than having this extra code for my NSManagedObject subclass. is this possible? ie, can a subclass of NSValueTransformer somehow have a context that is the document?

thanx,
ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Prev by Date: Re: [Apology] Re: CoreData.
  • Next by Date: Memory "weight" of objects
  • Previous by thread: Re: Bindings / CoreData / two windows issue
  • Next by thread: Memory "weight" of objects
  • Index(es):
    • Date
    • Thread