# Create a new pointer to the object type.
error_ptr = Pointer.new(:object)
unless data.writeToFile(path, options: mask, error:
error_ptr)
# De-reference the pointer.
error = error_ptr[0]
# Now we can use the `error' object.
$stderr.puts "Error when writing data: #{error}"
end
12年7月26日星期四
Slide 32
Slide 32 text
Reuse existing
Objective-C code base
12年7月26日星期四
Slide 33
Slide 33 text
or use CocoaPods
12年7月26日星期四
Slide 34
Slide 34 text
Why?
12年7月26日星期四
Slide 35
Slide 35 text
Easier to learn
12年7月26日星期四
Slide 36
Slide 36 text
Less boilerplates
12年7月26日星期四
Slide 37
Slide 37 text
Shorter, concise code
12年7月26日星期四
Slide 38
Slide 38 text
Build your own tool
12年7月26日星期四
Slide 39
Slide 39 text
Gems
12年7月26日星期四
Slide 40
Slide 40 text
BubbleWrap
http://bubblewrap.io
12年7月26日星期四
Slide 41
Slide 41 text
HTTP
BubbleWrap::HTTP.get("https://
api.github.com/users/mattetti") do |response|
puts response.body.to_str
end
12年7月26日星期四
Slide 42
Slide 42 text
KVO
class ExampleViewController < UIViewController
include BW::KVO
def viewDidLoad
observe(@text_field, :text) do |old_value,
new_value|
puts "Text field did changed: #{new_value}!"
end
end
end
12年7月26日星期四
Slide 43
Slide 43 text
Location
BW::Location.get do |r|
puts "From Lat #{r[:from].latitude}, Long #{r[:from].longitude}"
puts "To Lat #{r[:to].latitude}, Long #{r[:to].longitude}"
end
12年7月26日星期四