Sha256: ec25eff06b848aa3ec99bc8ac3af07c712707bf23ea1e5ce8199f80395b0ba0a

Contents?: true

Size: 859 Bytes

Versions: 74

Compression:

Stored size: 859 Bytes

Contents

class NSArray

  # Creates an NSIndexPath object using the items in `self` as the indices
  # @return [NSIndexPath]
  def nsindexpath
    if self.length == 0
      raise "An index path must have at least one index"
    end

    path = nil
    self.each do |val|
      if path
        path = path.indexPathByAddingIndex(val)
      else
        path = NSIndexPath.indexPathWithIndex(val)
      end
    end
    return path
  end

  # Creates an NSIndexSet object using the items in `self` as the indices
  # @return [NSIndexSet]
  def nsindexset
    if self.length == 0
      raise "An index set must have at least one index"
    end

    set = NSMutableIndexSet.indexSet
    self.each do |val|
      set.addIndex val
    end
    set
  end

  def nsset
    NSSet.setWithArray self
  end
  
  def nsorderedset
    NSOrderedSet.orderedSetWithArray self
  end

end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
sugarcube-1.5.8 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.5.7 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.5.6 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.5.5 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.5.4 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.5.3 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.5.2 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.5.1 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.5.0 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.4.6 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.4.5 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.4.4 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.4.3 lib/sugarcube-foundation/nsarray.rb
sugarcube-1.4.2 lib/sugarcube-foundation/nsarray.rb