Core Data transformable: set default value for any given key

Discussion in 'iOS Programming' started by moonman239, Dec 28, 2015.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    I have a Transformable that is used as an NSDictionary, and what I want to do is configure my managed object so that in the absence of a value for a given key, any call to valueForKey:key will return a default value.
     
  2. Mascots macrumors 68000

    Mascots

    Joined:
    Sep 5, 2009
  3. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #3
    With an NS
    as Mascots suggests, if you are using an NSManagedObject subclass you can set default attribute values in the awakeFromInsert method.
     

Share This Page