sugarcube 0.10 → 0.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -86,6 +86,41 @@ Examples
86
86
  # convert multiples of pi
87
87
  2.pi # => 2 * Math::PI
88
88
  0.5.pi # => 0.5 * Math::PI
89
+ ```
90
+
91
+ NSCoder
92
+ ---------
93
+
94
+ Shorthands and hash-like access to the coder/decoder objects.
95
+
96
+ ```ruby
97
+ # hash access is the handiest
98
+ coder['key'] = self.value
99
+ self.value = decoder['key']
100
+
101
+ # but if you want to store booleans and such in the MOST compact way:
102
+ coder.set('sugarcube_is_neat', toBool:self.is_sugarcube_neat?)
103
+ self.sugarcube_is_neat = decoder.bool('sugarcube_is_neat')
104
+
105
+ coder.set('number_of_things', toInt:self.number_of_things)
106
+ self.number_of_things = decoder.int('number_of_things')
107
+
108
+ # the entire list:
109
+ coder.set(key, toBool:value)
110
+ coder.set(key, toDouble:value)
111
+ coder.set(key, toFloat:value)
112
+ coder.set(key, toInt:value)
113
+ coder.set(key, toPoint:value)
114
+ coder.set(key, toRect:value)
115
+ coder.set(key, toSize:value)
116
+
117
+ decoder.bool(key)
118
+ decoder.double(key)
119
+ decoder.float(key)
120
+ decoder.int(key)
121
+ decoder.point(key)
122
+ decoder.rect(key)
123
+ decoder.size(key)
89
124
  ```
90
125
 
91
126
  NSDate
@@ -332,6 +367,14 @@ This is the "big daddy". Lots of sugar here...
332
367
  ```ruby
333
368
  image = "my_image".uiimage
334
369
  image.uicolor # => UIColor.colorWithPatternImage(image)
370
+ ```
371
+
372
+ ###### Image Manipulation
373
+
374
+ ```ruby
375
+ image.scale_to [37, 37]
376
+ image.rounded # default: 5 pt radius
377
+ image.rounded(10)
335
378
  ```
336
379
 
337
380
  UIAlertView
@@ -810,15 +853,18 @@ Assume I ran `include SugarCube::Adjust` in these examples.
810
853
  > adjust superview.subviews[4].subviews[1]
811
854
  > up 1
812
855
  > down 1 # same as up -1, obviously
856
+ > down # defaults to 1 anyway
813
857
  > left 1
814
858
  > right 1 # same as up -1, obviously
859
+ > left # => left 1
815
860
  > origin 10, 12 # move to x:10, y:12
816
861
  > wider 1
817
862
  > thinner 1
818
- > taller 1
819
- > shorter 1
863
+ > taller # => taller 1
864
+ > shorter # => shorter 1
820
865
  > size 100, 10 # set size to width:100, height: 10
821
866
  > shadow(opacity: 0.5, offset: [0, 0], color: :black, radius: 1) # and path, which is a CGPath object.
867
+ > center # See `Centering` section below
822
868
  > restore # original frame and shadow is saved when you call `adjust`
823
869
  ```
824
870
 
@@ -907,6 +953,78 @@ This better facilitates copy/paste of the values. Currently supported is:
907
953
 
908
954
  Note: The `format` parameter can be passed as either a symbol or a string
909
955
 
956
+ ### CENTER (in parent frame)
957
+ It is called as `center(which_element, of_total_number, horizontal_or_vertical, verbose_output)`
958
+ #### you can set 'direction' with any number of forms: 'horiz', 'vert', 'x', 'x and y'
959
+
960
+ Here are a few examples:
961
+
962
+ The default is to center the current element _horizontally_
963
+
964
+ ```
965
+ (main)> center
966
+ [[145.0, 30.0], [30.0, 200.0]]
967
+ UIRoundedRectButton.origin = [145.0, 30.0]
968
+ => "[[145.0, 30.0], [30.0, 200.0]]"
969
+ ```
970
+
971
+ In order to place that same button in the CENTER of the screen, you can use this shorthand syntax:
972
+ `center 1,1,"xy"` or `center 1,1,:xy`
973
+
974
+ For the `horizontal_or_vertical` parameter, strings and symbols are interchangable
975
+
976
+ If you have three buttons and want them spaced evenly (vertically) across their parent frame, you can call it this way:
977
+ ```
978
+ (main)> tree
979
+ 0: . UIWindow(#6e1f950: [[0.0, 0.0], [320.0, 480.0]])
980
+ 1: `-- UIView(#8b203b0: [[0.0, 20.0], [320.0, 460.0]])
981
+ 2: +-- UIButton(#d028de0: [[10.0, 10.0], [320.0, 463.400512695312]])
982
+ 3: | `-- UIImageView(#d02aaa0: [[0.0, 0.0], [320.0, 463.400512695312]])
983
+ 4: +-- UIRoundedRectButton(#d02adb0: [[55.0, 110.0], [210.0, 20.0]])
984
+ 5: | `-- UIButtonLabel(#d02af00: [[73.0, 0.0], [63.0, 19.0]])
985
+ 6: +-- UIRoundedRectButton(#d028550: [[60.0, 30.0], [200.0, 20.0]])
986
+ 7: | `-- UIButtonLabel(#d02afb0: [[68.0, 0.0], [63.0, 19.0]])
987
+ 8: `-- UIRoundedRectButton(#d02b220: [[70.0, 30.0], [300.0, 20.0]])
988
+ 9: `-- UIButtonLabel(#d02b300: [[118.0, 0.0], [63.0, 19.0]])
989
+ => UIWindow(#6e1f950, [[0.0, 0.0], [320.0, 480.0]])
990
+ (main)> a 4; center 1, 3, :vert, false; center
991
+ [[55.0, 110.0], [210.0, 20.0]]
992
+ [[55.0, 110.0], [210.0, 20.0]]
993
+ UIRoundedRectButton.origin = [55.0, 110.0]
994
+ => "[[55.0, 110.0], [210.0, 20.0]]"
995
+ (main)> a 6; center 2, 3, :vert, false; center
996
+ [[60.0, 220.0], [200.0, 20.0]]
997
+ [[60.0, 220.0], [200.0, 20.0]]
998
+ UIRoundedRectButton.origin = [60.0, 220.0]
999
+ => "[[60.0, 220.0], [200.0, 20.0]]"
1000
+ (main)> a 8; center 3, 3, :vert, false; center
1001
+ [[70.0, 330.0], [300.0, 20.0]]
1002
+ [[10.0, 330.0], [300.0, 20.0]]
1003
+ UIRoundedRectButton.origin = [10.0, 330.0]
1004
+ => "[[10.0, 330.0], [300.0, 20.0]]"
1005
+ ```
1006
+ The calculated positions (x,y) are in the REPL output
1007
+
1008
+
1009
+ **Don't stop there!**
1010
+
1011
+ You can analyze `UIViewController` hierarchies, too. There's even a handy
1012
+ `root` method to grab the `rootViewController`:
1013
+
1014
+ ```ruby
1015
+ (main)> tree root
1016
+ 0: . #<MainScreenController:0xac23b80>
1017
+ 1: +-- #<ScheduleViewController:0x13185d00>
1018
+ 2: | +-- #<ScheduleTableController:0x131862f0>
1019
+ 3: | `-- #<ScheduleCalendarController:0x131bba90>
1020
+ 4: +-- #<CameraViewController:0x13191380>
1021
+ 5: +-- #<UINavigationController:0xac01ea0>
1022
+ 6: | `-- #<UITableController:0xac04e30>
1023
+ 7: +-- #<PicturesViewController:0x1403ede0>
1024
+ 8: `-- #<MessagesViewController:0x131a1bc0>
1025
+ => #<MainScreenController:0xac23b80>
1026
+ ```
1027
+
910
1028
 
911
1029
  Pointers
912
1030
  ----------
@@ -944,3 +1062,21 @@ Quick wrapper for `CFUUIDCreate()` and `CFUUIDCreateString()`. Identical to the
944
1062
  [teacup]: https://github.com/rubymotion/teacup
945
1063
  [Fusionbox]: http://www.fusionbox.com/
946
1064
  [fusionbox announcement]: http://fusionbox.org/projects/rubymotion-sugarcube/
1065
+
1066
+ Ruby on Rails Ripoffs (RoR-R?)
1067
+ ---------------
1068
+
1069
+ ```ruby
1070
+ # truthiness with `blank?`
1071
+ nil.blank? # => true
1072
+ false.blank? # => true
1073
+ ''.blank? # => true
1074
+ [].blank? # => true
1075
+ {}.blank? # => true
1076
+
1077
+ 0.blank? # => false
1078
+ true.blank? # => false
1079
+ 'a'.blank? # => false
1080
+ ['a'].blank? # => false
1081
+ {a: 'a'}.blank? # => false
1082
+ ```
@@ -18,21 +18,24 @@ module SugarCube
18
18
  return @@sugarcube_view if not view
19
19
 
20
20
  if view.is_a? Fixnum
21
- @@sugarcube_views ||= nil
22
- raise "no views have been assigned to SugarCube::Adjust::tree" unless @@sugarcube_views
21
+ @@sugarcube_items ||= nil
22
+ raise "no views have been assigned to SugarCube::Adjust::tree" unless @@sugarcube_items
23
23
 
24
- view = @@sugarcube_views[view]
24
+ view = @@sugarcube_items[view]
25
25
  end
26
26
 
27
- @@sugarcube_view = view
28
- @@sugarcube_restore = {
29
- frame: SugarCube::Adjust.frame,
30
- shadow: SugarCube::Adjust.shadow,
31
- }
27
+ if view.is_a?(UIView)
28
+ @@sugarcube_view = view
29
+ @@sugarcube_restore = {
30
+ frame: SugarCube::Adjust.frame,
31
+ shadow: SugarCube::Adjust.shadow,
32
+ }
32
33
 
33
- if format
34
- puts format_frame view.frame
34
+ if format
35
+ puts format_frame view.frame
36
+ end
35
37
  end
38
+
36
39
  view
37
40
  end
38
41
  alias a adjust
@@ -165,6 +168,52 @@ module SugarCube
165
168
  end
166
169
  alias z size
167
170
 
171
+ def center(*args)
172
+ @@sugarcube_view ||= nil
173
+ raise "no view has been assigned to SugarCube::Adjust::adjust" unless @@sugarcube_view
174
+
175
+ element = nil
176
+ total = nil
177
+ direction = 'h'
178
+ args.each do |option|
179
+ case option
180
+ when String, Symbol # accept string or symbol
181
+ direction = option.to_s
182
+ when Numeric
183
+ if not total
184
+ total = option
185
+ elsif not element
186
+ element = option
187
+ else
188
+ raise "I don't know what to do with #{option.inspect}"
189
+ end
190
+ else
191
+ raise "I don't know what to do with #{option.inspect}"
192
+ end
193
+ end
194
+ element = 1 unless element
195
+ total = 1 unless total
196
+
197
+ view = @@sugarcube_view
198
+
199
+ left = view.origin.x
200
+ top = view.origin.y
201
+
202
+ if /h|x/.match(direction.downcase)
203
+ swidth = view.frame.width
204
+ pwidth = view.superview.frame.width / total
205
+ left = (pwidth - swidth) / 2 + pwidth * (element - 1)
206
+ end
207
+ if /v|y/.match(direction.downcase)
208
+ sheight = view.frame.height
209
+ pheight = view.superview.frame.height / total
210
+ top = (pheight - sheight) / 2 + pheight * (element - 1)
211
+ end
212
+
213
+ self.origin left, top
214
+ end
215
+ alias c center
216
+
168
217
  ##| SHADOW
169
218
  def shadow shadow=nil
170
219
  @@sugarcube_view ||= nil
@@ -201,64 +250,110 @@ module SugarCube
201
250
  alias h shadow
202
251
 
203
252
  ##| TREE
204
- def tree(view=nil, tab=nil, is_last=true, views_index=nil)
205
- unless view
206
- view = UIApplication.sharedApplication.keyWindow
253
+ def tree(item=nil, selector=nil, &sel_blk)
254
+ unless item
255
+ item = UIApplication.sharedApplication.keyWindow
256
+ end
257
+ if not item
258
+ puts 'View is nil (no window, view, or controller to display)'
259
+ return
207
260
  end
208
261
 
209
- if not views_index
210
- is_first = true
211
- @@sugarcube_views = [view]
212
- views_index = 0
262
+ if sel_blk
263
+ if selector
264
+ raise "You can't hand me a block AND a selector. I don't know what to do with them!"
265
+ end
266
+ if sel_blk.arity != 1
267
+ raise "The block you passed should accept one and only one object"
268
+ end
269
+ selector = sel_blk
270
+ elsif ! selector
271
+ if item.is_a? UIView
272
+ selector = :subviews
273
+ elsif item.is_a? UIViewController
274
+ selector = lambda { |ctlr|
275
+ ret = Array.new ctlr.childViewControllers
276
+ if ctlr.presentedViewController && ctlr.presentedViewController.presentingViewController == ctlr
277
+ ret << ctlr.presentedViewController
278
+ end
279
+ ret
280
+ }
281
+ else
282
+ raise "Unable to determine a SugarCube::Adjust::tree selector for #{item.class.name}"
283
+ end
284
+ end
285
+
286
+ @@sugarcube_items = []
287
+ if self.respond_to? :draw_tree
288
+ total = draw_tree(item, selector)
213
289
  else
214
- is_first = false
215
- @@sugarcube_views << view
290
+ total = SugarCube::Adjust::draw_tree(item, selector)
216
291
  end
292
+ puts ''
293
+
294
+ return item
295
+ end
296
+
297
+ def draw_tree(item, selector, tab=nil, is_last=true, items_index=0)
298
+ @@sugarcube_items << item
217
299
 
218
300
  space = ' '
219
- if views_index < 10
220
- print " "
221
- elsif views_index < 100
222
- print " "
223
- elsif views_index > 999 # good god, man!
301
+ if items_index < 10
302
+ print ' '
303
+ elsif items_index < 100
304
+ print ' '
305
+ elsif items_index > 999 # good god, man!
224
306
  space = ''
225
307
  end
226
- print views_index.to_s + ":" + space
308
+ print items_index.to_s + ":" + space
227
309
 
228
310
  if tab
229
311
  print tab
230
- print is_last ? "`-- " : "+-- "
231
- tab += is_last ? " " : "| "
312
+ if is_last
313
+ print '`-- '
314
+ tab += ' '
315
+ else
316
+ print '+-- '
317
+ tab += '| '
318
+ end
232
319
  else
233
- print ". "
234
- tab = ""
320
+ print '. '
321
+ tab = ''
235
322
  end
236
323
 
237
- if not view
238
- puts "View is nil (no window or view to display)"
324
+ if self == item
325
+ print "\033[1m"
326
+ end
327
+ if item.is_a? UIView
328
+ puts item.to_s superview: false
239
329
  else
240
- if self == view
241
- print "\033[1m"
242
- end
243
- puts "#{view.class.name}(##{view.object_id.to_s(16)}: #{format_frame(view.frame)})"
244
- if self == view
245
- print "\033[0m"
246
- end
330
+ puts item.to_s
331
+ end
332
+ if self == item
333
+ print "\033[0m"
334
+ end
247
335
 
248
- view.subviews.each_index {|index|
249
- subview = view.subviews[index]
250
- views_index += 1
251
- views_index = tree(subview, tab, index == view.subviews.length - 1, views_index)
252
- }
336
+ if selector.is_a? Proc
337
+ items = selector.call(item)
338
+ else
339
+ items = item.send(selector)
253
340
  end
341
+ items.each_with_index { |subview, index|
342
+ items_index += 1
343
+ items_index = SugarCube::Adjust::draw_tree(subview, selector, tab, index == items.length - 1, items_index)
344
+ }
254
345
 
255
- return is_first ? view : views_index
346
+ return items_index
347
+ end
348
+
349
+ def root
350
+ (UIApplication.sharedApplication.keyWindow || UIApplication.sharedApplication.windows[0]).rootViewController
256
351
  end
257
352
 
258
353
  ##| RESTORE
259
354
  def restore
260
355
  @@sugarcube_view ||= nil
261
- raise "no view has been assigned to SugarCube::Adjust::adjust" unless @@sugarcube_view
356
+ raise 'no view has been assigned to SugarCube::Adjust::adjust' unless @@sugarcube_view
262
357
 
263
358
  @@sugarcube_restore.each do |msg, value|
264
359
  SugarCube::Adjust.send(msg, value)
@@ -267,9 +362,9 @@ module SugarCube
267
362
 
268
363
  def format_frame(frame)
269
364
  case SugarCube::Adjust::repl_format
270
- when :json then "[x: #{frame.origin.x}, y: #{frame.origin.y}, height: #{frame.size.width}, width: #{frame.size.height}]"
365
+ when :json then "{x: #{frame.origin.x}, y: #{frame.origin.y}, width: #{frame.size.width}, height: #{frame.size.height}}"
271
366
  when :ruby then "[[#{frame.origin.x}, #{frame.origin.y}], [#{frame.size.width}, #{frame.size.height}]]"
272
- when nil, :objc
367
+ when :objc
273
368
  frame.to_s
274
369
  else
275
370
  raise "Unknown repl_format #{SugarCube::Adjust::repl_format.inspect}"
@@ -34,7 +34,7 @@ class IndexPath
34
34
  @values.each do |val|
35
35
  next_val = other[other_i]
36
36
  other_i += 1
37
- unless val === next_val
37
+ unless val == true || val === next_val
38
38
  ret = false
39
39
  break
40
40
  end
@@ -4,4 +4,8 @@ class NSURL
4
4
  NSUIApplication.sharedApplication.openURL(NSUrl.URLWithString(self))
5
5
  end
6
6
 
7
+ def can_open?
8
+ NSUIApplication.sharedApplication.canOpenURL(NSUrl.URLWithString(self))
9
+ end
10
+
7
11
  end
@@ -0,0 +1,16 @@
1
+ class NSUserDefaults
2
+
3
+ class << self
4
+ # Retrieves the object for the passed key
5
+ def [](key)
6
+ self.standardUserDefaults.objectForKey(key.to_s)
7
+ end
8
+
9
+ # Sets the value for a given key and save it right away.
10
+ def []=(key, val)
11
+ self.standardUserDefaults.setObject(val, forKey: key.to_s)
12
+ self.standardUserDefaults.synchronize
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,9 @@
1
+ # thanks ruby on rails!
2
+ #
3
+ # these are all blatent, unapologetic rip offs of RoR extensions.
4
+
5
+ class Object
6
+ def blank?
7
+ respond_to?(:empty?) ? empty? : !self
8
+ end
9
+ end
@@ -31,6 +31,7 @@ class Symbol
31
31
  attr_accessor :barmetrics
32
32
  attr_accessor :barbuttomitems
33
33
  attr_accessor :keyboardtypes
34
+ attr_accessor :autoresizemasks
34
35
 
35
36
  attr_accessor :textalignments
36
37
  attr_accessor :linebreakmodes
@@ -120,6 +121,8 @@ class Symbol
120
121
  touch_up: UIControlEventTouchUpInside,
121
122
  touch_down: UIControlEventTouchDown,
122
123
  change: UIControlEventValueChanged|UIControlEventEditingChanged,
124
+ begin: UIControlEventEditingDidBegin,
125
+ end: UIControlEventEditingDidEnd,
123
126
  # I'm leaving this for backwards compatibility. please use 'change' or
124
127
  # 'editing_did_change':
125
128
  changed: UIControlEventValueChanged|UIControlEventEditingChanged,
@@ -291,6 +294,25 @@ class Symbol
291
294
  email: UIKeyboardTypeEmailAddress,
292
295
  }
293
296
 
297
+ @autoresizemasks = {
298
+ none: UIViewAutoresizingNone,
299
+
300
+ flexibleleft: UIViewAutoresizingFlexibleLeftMargin,
301
+ flexiblewidth: UIViewAutoresizingFlexibleWidth,
302
+ flexibleright: UIViewAutoresizingFlexibleRightMargin,
303
+ flexibletop: UIViewAutoresizingFlexibleTopMargin,
304
+ flexibleheight: UIViewAutoresizingFlexibleHeight,
305
+ flexiblebottom: UIViewAutoresizingFlexibleBottomMargin,
306
+
307
+ # aliases
308
+ left: UIViewAutoresizingFlexibleLeftMargin,
309
+ width: UIViewAutoresizingFlexibleWidth,
310
+ right: UIViewAutoresizingFlexibleRightMargin,
311
+ top: UIViewAutoresizingFlexibleTopMargin,
312
+ height: UIViewAutoresizingFlexibleHeight,
313
+ bottom: UIViewAutoresizingFlexibleBottomMargin,
314
+ }
315
+
294
316
  private
295
317
  def look_in(here)
296
318
  return here[self] if here.has_key? self
@@ -406,6 +428,11 @@ class Symbol
406
428
  look_in(Symbol.keyboardtypes)
407
429
  end
408
430
 
431
+ def uiautoresize
432
+ look_in(Symbol.autoresizemasks)
433
+ end
434
+ alias uiviewautoresizing uiautoresize
435
+
409
436
  def uifont(size=UIFont.systemFontSize)
410
437
  # system fonts
411
438
  if Symbol.system_fonts.has_key? self
@@ -1,4 +1,9 @@
1
1
  class NSError
2
+ def localized
3
+ localizedDescription
4
+ end
5
+ alias _ localized
6
+
2
7
  def to_s
3
8
  "#<#{self.class.name}:0x#{self.object_id.to_s(16)}, "+
4
9
  "description=#{self.localizedDescription.inspect}, code=#{code}, "+
@@ -0,0 +1,7 @@
1
+ class UILabel
2
+
3
+ def to_s(options={})
4
+ super options.merge(inner: 'text: ' + text.inspect)
5
+ end
6
+
7
+ end
@@ -1,8 +1,11 @@
1
1
  class UIView
2
2
 
3
- def to_s
4
- "#{self.class.name}(##{self.object_id.to_s(16)}, #{SugarCube::Adjust::format_frame(self.frame)})" +
5
- (self.superview ? ", child of #{self.superview.class.name}(##{self.superview.object_id.to_s(16)})" : '')
3
+ def to_s(options={})
4
+ options[:superview] = true if options[:superview].nil?
5
+ "#{self.class.name}(##{self.object_id.to_s(16)}, #{SugarCube::Adjust::format_frame(self.frame)}" +
6
+ (options[:inner] ? ', ' + options[:inner] : '') +
7
+ ')' +
8
+ (options[:superview] && self.superview ? ", child of #{self.superview.class.name}(##{self.superview.object_id.to_s(16)})" : '')
6
9
  end
7
10
 
8
11
  end
@@ -0,0 +1,11 @@
1
+ class UIViewController
2
+
3
+ def to_s
4
+ ret = super
5
+ if self.presentingViewController
6
+ ret += " presented by #{self.presentingViewController.to_s}"
7
+ end
8
+ ret
9
+ end
10
+
11
+ end
@@ -13,4 +13,5 @@ class UIActivityIndicatorView
13
13
  self.alloc.initWithActivityIndicatorStyle(:gray.uiactivityindicatorstyle)
14
14
  end
15
15
  end
16
- end
16
+
17
+ end
@@ -9,6 +9,10 @@ class UIAlertView
9
9
  # success: proc{ |pressed| puts "pressed: #{pressed}" },
10
10
  # )
11
11
  def self.alert(title, options={}, &block)
12
+ if options.is_a? String
13
+ options = {message: options}
14
+ end
15
+
12
16
  # create the delegate
13
17
  delegate = SugarCube::AlertViewDelegate.new
14
18
  delegate.on_success = options[:success] || block
@@ -14,5 +14,26 @@ class UIImage
14
14
  @uiimageview = UIImageView.alloc.initWithImage(self)
15
15
  end
16
16
 
17
+ ##|
18
+ ##| REALLY HANDY STUFF!
19
+ ##|
20
+ def scale_to new_size
21
+ UIGraphicsBeginImageContextWithOptions(new_size, false, 0.0)
22
+ self.drawInRect([[0, 0], new_size])
23
+ image = UIGraphicsGetImageFromCurrentImageContext()
24
+ UIGraphicsEndImageContext()
25
+ return image
26
+ end
27
+
28
+ def rounded(corner_radius=5)
29
+ UIGraphicsBeginImageContext(size)
30
+ path = UIBezierPath.bezierPathWithRoundedRect([[0, 0], size], cornerRadius:corner_radius)
31
+ path.addClip
32
+ self.drawInRect([[0, 0], size])
33
+ image = UIGraphicsGetImageFromCurrentImageContext()
34
+
35
+ UIGraphicsEndImageContext()
36
+ return image
37
+ end
17
38
 
18
39
  end
@@ -1,26 +1,27 @@
1
- class UINavigationController
1
+ class UIViewController
2
2
 
3
3
  def push(view_controller)
4
- self.pushViewController(view_controller, animated: true)
4
+ self.addChildViewController(view_controller)
5
5
  self
6
6
  end
7
+ alias << push
8
+
9
+ end
10
+
11
+
12
+ class UINavigationController
7
13
 
8
- def <<(view_controller)
14
+ def push(view_controller)
9
15
  self.pushViewController(view_controller, animated: true)
10
16
  self
11
17
  end
18
+ alias << push
12
19
 
13
20
  def pop(to_view=nil)
14
- return self.!(to_view) if to_view
15
-
16
- self.popViewControllerAnimated(true)
17
- end
18
-
19
- def !(to_view=nil)
20
21
  if to_view
21
22
  self.popToViewController(to_view, animated: true)
22
23
  else
23
- self.popToRootViewControllerAnimated(true)
24
+ self.popViewControllerAnimated(true)
24
25
  end
25
26
  end
26
27
 
@@ -29,11 +30,12 @@ end
29
30
 
30
31
  class UITabBarController
31
32
 
32
- def <<(view_controller)
33
+ def push(view_controller)
33
34
  view_controllers = [] + self.viewControllers
34
35
  view_controllers << view_controller
35
36
  self.setViewControllers(view_controllers, animated: true)
36
37
  self
37
38
  end
39
+ alias << push
38
40
 
39
41
  end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.10'
2
+ Version = '0.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugarcube
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.10'
4
+ version: '0.11'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-19 00:00:00.000000000 Z
13
+ date: 2012-10-24 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: ! '== Description
16
16
 
@@ -60,7 +60,9 @@ files:
60
60
  - lib/sugarcube/nsindexset.rb
61
61
  - lib/sugarcube/nsstring.rb
62
62
  - lib/sugarcube/nsurl.rb
63
+ - lib/sugarcube/nsuserdefaults.rb
63
64
  - lib/sugarcube/numeric.rb
65
+ - lib/sugarcube/ror.rb
64
66
  - lib/sugarcube/symbol.rb
65
67
  - lib/sugarcube/symbol/symbol_uicolor.rb
66
68
  - lib/sugarcube/timer.rb
@@ -68,8 +70,10 @@ files:
68
70
  - lib/sugarcube/to_s/nsset.rb
69
71
  - lib/sugarcube/to_s/uicolor.rb
70
72
  - lib/sugarcube/to_s/uievent.rb
73
+ - lib/sugarcube/to_s/uilabel.rb
71
74
  - lib/sugarcube/to_s/uitouch.rb
72
75
  - lib/sugarcube/to_s/uiview.rb
76
+ - lib/sugarcube/to_s/uiviewcontroller.rb
73
77
  - lib/sugarcube/uiactivityindicator.rb
74
78
  - lib/sugarcube/uialertview.rb
75
79
  - lib/sugarcube/uibutton.rb