sugarcube 1.3.7 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# Additions to UIControl to support jQuery-style `on` and `off` methods.
|
2
2
|
class UIControl
|
3
3
|
|
4
|
-
sugarcube_cleanup do
|
5
|
-
@sugarcube_callbacks = nil
|
6
|
-
end
|
7
|
-
|
8
4
|
# Add event handlers to UIControls. See symbol.rb for the uicontrolevent
|
9
5
|
# constant aliases.
|
10
6
|
#
|
@@ -15,8 +11,7 @@ class UIControl
|
|
15
11
|
# # up to two arguments can be passed in
|
16
12
|
# button.on(:touch) { |sender,touch_event| my_code }
|
17
13
|
def on(*events, &block)
|
18
|
-
handler = SugarCube::UIControlCallbackHelper.new
|
19
|
-
handler.callback = block
|
14
|
+
handler = SugarCube::UIControlCallbackHelper.new(block)
|
20
15
|
|
21
16
|
events.each do |event|
|
22
17
|
event = event.uicontrolevent if event.respond_to?(:uicontrolevent)
|
@@ -78,16 +73,19 @@ end
|
|
78
73
|
|
79
74
|
module SugarCube
|
80
75
|
class UIControlCallbackHelper
|
81
|
-
|
76
|
+
|
77
|
+
def initialize(callback)
|
78
|
+
@callback = callback!
|
79
|
+
end
|
82
80
|
|
83
81
|
def call(sender, event:event)
|
84
|
-
case callback.arity
|
82
|
+
case @callback.arity
|
85
83
|
when 0
|
86
|
-
callback.call
|
84
|
+
@callback.call
|
87
85
|
when 1
|
88
|
-
callback.call(sender)
|
86
|
+
@callback.call(sender)
|
89
87
|
else
|
90
|
-
callback.call(sender, event)
|
88
|
+
@callback.call(sender, event)
|
91
89
|
end
|
92
90
|
end
|
93
91
|
end
|
@@ -1,9 +1,5 @@
|
|
1
1
|
class UITextView
|
2
2
|
|
3
|
-
sugarcube_cleanup do
|
4
|
-
@sugarcube_callbacks = nil
|
5
|
-
end
|
6
|
-
|
7
3
|
def sugarcube_callbacks
|
8
4
|
@sugarcube_callbacks ||= Hash.new { |h,k| h[k] = [] }
|
9
5
|
end
|
@@ -70,7 +66,7 @@ private
|
|
70
66
|
self.sugarcube_callbacks[notication] << NSNotificationCenter.defaultCenter.addObserverForName(notication,
|
71
67
|
object: self,
|
72
68
|
queue: NSOperationQueue.mainQueue,
|
73
|
-
usingBlock: block)
|
69
|
+
usingBlock: block.weak!)
|
74
70
|
end
|
75
71
|
|
76
72
|
def _offEventNotification(nofication)
|
@@ -3,10 +3,6 @@
|
|
3
3
|
# changing it to suit my needs, and offering it here
|
4
4
|
class UIView
|
5
5
|
|
6
|
-
sugarcube_cleanup do
|
7
|
-
@sugarcube_recognizers = nil
|
8
|
-
end
|
9
|
-
|
10
6
|
# A generic gesture adder, but accepts a block like the other gesture methods
|
11
7
|
# @yield [recognizer] Handles the gesture event, and passes the recognizer instance to the block.
|
12
8
|
# @param options [Hash] method/value pairs to call on the gesture.
|
@@ -197,7 +193,7 @@ private
|
|
197
193
|
self.addGestureRecognizer(recognizer)
|
198
194
|
|
199
195
|
@sugarcube_recognizers = {} unless @sugarcube_recognizers
|
200
|
-
@sugarcube_recognizers[recognizer] = proc
|
196
|
+
@sugarcube_recognizers[recognizer] = proc.weak!
|
201
197
|
|
202
198
|
recognizer
|
203
199
|
end
|
@@ -1,37 +1,7 @@
|
|
1
1
|
class UIViewController
|
2
2
|
|
3
3
|
def sugarcube_cleanup
|
4
|
-
|
5
|
-
self.view.sugarcube_cleanup
|
6
|
-
self.childViewControllers.each do |subctlr|
|
7
|
-
subctlr.sugarcube_cleanup
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
class UIResponder
|
15
|
-
|
16
|
-
class << self
|
17
|
-
|
18
|
-
def sugarcube_cleanup(&block)
|
19
|
-
@sugarcube_cleanup ||= []
|
20
|
-
return @sugarcube_cleanup unless block
|
21
|
-
@sugarcube_cleanup << block
|
22
|
-
return nil
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def sugarcube_cleanup
|
28
|
-
self.class.ancestors.each do |klass|
|
29
|
-
next unless klass.respond_to?(:sugarcube_cleanup)
|
30
|
-
klass.sugarcube_cleanup.each do |block|
|
31
|
-
self.instance_eval(&block)
|
32
|
-
end
|
33
|
-
break if klass == UIResponder
|
34
|
-
end
|
4
|
+
NSLog("Good news! The sugarcube_cleanup method is no longer needed.")
|
35
5
|
end
|
36
6
|
|
37
7
|
end
|
@@ -40,10 +10,7 @@ end
|
|
40
10
|
class UIView
|
41
11
|
|
42
12
|
def sugarcube_cleanup
|
43
|
-
|
44
|
-
self.subviews.each do |subview|
|
45
|
-
subview.sugarcube_cleanup
|
46
|
-
end
|
13
|
+
NSLog("Good news! The sugarcube_cleanup method is no longer needed.")
|
47
14
|
end
|
48
15
|
|
49
16
|
end
|
data/lib/sugarcube/version.rb
CHANGED
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: 1.3.
|
4
|
+
version: 1.3.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-12-
|
15
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: ! '== Description
|
18
18
|
|