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-4.0.0 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.5.0 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.4.2 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.4.1 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.4.0 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.3.7 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.3.6 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.3.5 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.3.4 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.3.3 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.3.2 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.3.1 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.3.0 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.2.0 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.1.1 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.1.0 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.0.8 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.0.7 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.0.6 lib/cocoa/sugarcube-foundation/nsarray.rb
sugarcube-3.0.5 lib/cocoa/sugarcube-foundation/nsarray.rb