Class: NSArray
- Defined in:
- lib/sugarcube-color/nsarray.rb,
lib/sugarcube-pointer/nsarray.rb,
lib/sugarcube-foundation/nsarray.rb,
lib/sugarcube-nsuserdefaults/nsuserdefaults.rb
Instance Method Summary collapse
-
#nsindexpath ⇒ NSIndexPath
Creates an NSIndexPath object using the items in
self
as the indices. -
#nsindexset ⇒ NSIndexSet
Creates an NSIndexSet object using the items in
self
as the indices. - #nsset ⇒ Object
- #to_nsuserdefaults ⇒ Object
-
#to_pointer(type) ⇒ Pointer
A pointer to the array, of the specified type.
-
#uicolor(alpha = 1.0) ⇒ Object
[160, 210, 242].uicolor => 0xA0D2F2.uicolor.
Instance Method Details
#nsindexpath ⇒ NSIndexPath
Creates an NSIndexPath object using the items in self
as the indices
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sugarcube-foundation/nsarray.rb', line 5 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 |
#nsindexset ⇒ NSIndexSet
Creates an NSIndexSet object using the items in self
as the indices
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sugarcube-foundation/nsarray.rb', line 23 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 |
#nsset ⇒ Object
35 36 37 |
# File 'lib/sugarcube-foundation/nsarray.rb', line 35 def nsset NSSet.setWithArray self end |
#to_nsuserdefaults ⇒ Object
43 44 45 |
# File 'lib/sugarcube-nsuserdefaults/nsuserdefaults.rb', line 43 def to_nsuserdefaults self.map { |val| val.to_nsuserdefaults } end |
#to_pointer(type) ⇒ Pointer
Returns A pointer to the array, of the specified type.
5 6 7 8 9 10 11 |
# File 'lib/sugarcube-pointer/nsarray.rb', line 5 def to_pointer(type) ret = Pointer.new(type, self.length) self.each_index do |i| ret[i] = self[i] end ret end |