Method: Xcodeproj::Project::Object::AbstractObject#sort_recursively

Defined in:
lib/xcodeproj/project/object.rb

#sort_recursively(options = nil) ⇒ Object

Note:

Some objects may in turn refer back to objects higher in the object tree, which will lead to stack level deep errors. These objects should not try to perform a recursive sort, also because these objects would get sorted through other paths in the tree anyways.

At the time of writing the only known case is ‘PBXTargetDependency`.

Sorts the object and the objects that it references.

Parameters:

  • options (Hash) (defaults to: nil)

    the sorting options.

Options Hash (options):

  • :groups_position (Symbol)

    the position of the groups can be either ‘:above` or `:below`.



172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/xcodeproj/project/object.rb', line 172

def sort_recursively(options = nil)
  to_one_attributes.each do |attrb|
    value = attrb.get_value(self)
    value.sort_recursively(options) if value
  end

  to_many_attributes.each do |attrb|
    list = attrb.get_value(self)
    list.each { |entry| entry.sort_recursively(options) }
  end

  sort(options)
end