Class: NSArray
- Defined in:
- lib/sugarcube/nsarray.rb,
lib/sugarcube/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. - #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
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sugarcube/nsarray.rb', line 15 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
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sugarcube/nsarray.rb', line 33 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 |
#to_nsuserdefaults ⇒ Object
43 44 45 |
# File 'lib/sugarcube/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/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 |