class Xcodeproj::Project::ObjectDictionary


don’t notify the objects.
inheriting from it. This would prevent the usage of methods which
@todo This class should use a {Hash} as a backing store instead of
usually are implemented in C.
Moreover it is a moving target because the methods of array
the hash methods should be covered, but this is not done yet.
which are overridden to inform objects reference count. Ideally all
@note Concerning the mutations methods it is safe to call only those
{AbstractObjectAttribute} and the {ObjectList}.
Also the interface is a dirty hybrid between the
I.e. generate setters and getters from the specification hash.
root_object.project_references.product_group = file
#=> This should raise:
root_object.project_references.project_ref = file
#=> Note the API:
This should be possible:
}
:product_group => PBXGroup
:project_ref => PBXFileReference,
has_many_references_by_keys :project_references, {
Give the following attribute:
@note To provide full support as the other classes the dictionary should:
with reference count on modifications.
the project is not serialized with unreachable objects by updating the
It works in conjunction with the {AbstractObject} class to ensure that
Dictionary.
This class represents relationships to other objects stored in a

def []=(key, object)

Returns:
  • (AbstractObject) - The given object.

Parameters:
  • object (AbstractObject) --
  • key (String) --
def []=(key, object)
  key = normalize_key(key)
  if object
    perform_additions_operations(object, key)
  else
    perform_deletion_operations(self[key])
  end
  super(key, object)
end

def add_referrer(referrer)


referencing them.
Informs the objects contained in the dictionary that another object is
def add_referrer(referrer)
  values.each { |obj| obj.add_referrer(referrer) }
end

def allowed_keys

Returns:
  • (Array) - The list of the allowed keys.
def allowed_keys
  attribute.classes_by_key.keys
end

def delete(key)

Parameters:
  • key (String) --
def delete(key)
  key = normalize_key(key)
  object = self[key]
  perform_deletion_operations(object)
  super
end

def initialize(attribute, owner)

Parameters:
  • owner (Object) -- @see #owner
  • attribute (Object::AbstractObjectAttribute) -- @see #attribute
def initialize(attribute, owner)
  @attribute = attribute
  @owner = owner
end

def inspect

Returns:
  • (String) - A string suitable for debugging.
def inspect
  "<ObjectDictionary attribute:`#{@attribute.name}` " \
    "owner:`#{@owner.display_name}` values:#{super.inspect}>"
end

def normalize_key(key)

Parameters:
  • key (String, Symbol) --

Returns:
  • (Symbol) - Normalizes a key to a symbol converting the camel case
def normalize_key(key)
  if key.is_a?(String)
    key = Object::CaseConverter.convert_to_ruby(key)
  end
  unless allowed_keys.include?(key)
    raise "[Xcodeproj] Unsupported key `#{key}` (allowed " \
      "`#{allowed_keys}`) for `#{inspect}`"
  end
  key
end

def perform_additions_operations(object, key)

Returns:
  • (void) -
def perform_additions_operations(object, key)
  owner.mark_project_as_dirty!
  object.add_referrer(owner)
  attribute.validate_value_for_key(object, key)
end

def perform_deletion_operations(objects)

Returns:
  • (void) -
def perform_deletion_operations(objects)
  owner.mark_project_as_dirty!
  objects.remove_referrer(owner)
end

def remove_reference(object)


Removes all the references to a given object.
def remove_reference(object)
  each { |key, obj| self[key] = nil if obj == object }
end

def remove_referrer(referrer)


stopped referencing them.
Informs the objects contained in the dictionary that another object
def remove_referrer(referrer)
  values.each { |obj| obj.remove_referrer(referrer) }
end

def to_ascii_plist

def to_ascii_plist
  to_hash
end

def to_hash

Returns:
  • (Hash String>) - The plist representation of the
def to_hash
  result = {}
  each do |key, obj|
    if obj
      plist_key = Object::CaseConverter.convert_to_plist(key, nil)
      result[plist_key] = Nanaimo::String.new(obj.uuid, obj.ascii_plist_annotation)
    end
  end
  result
end

def to_tree_hash

Returns:
  • (Hash String>) - Returns a cascade representation of
def to_tree_hash
  result = {}
  each do |key, obj|
    if obj
      plist_key = Object::CaseConverter.convert_to_plist(key, nil)
      result[plist_key] = obj.to_tree_hash
    end
  end
  result
end