Skip to content

Instantly share code, notes, and snippets.

@dastels
dastels / gist:6743635
Created September 28, 2013 16:13
Why is initWithFrame: not working in RubyMotion. The method appears to be there on the UIView object.
Simulate ./build/iPhoneSimulator-7.0-Development/iLisp.app
(main)> v = UIView.alloc
=> #<UIView:0xc5b16d0>
(main)> v.methods.sort.select {|m| m.to_s =~ /init.*/}
=> [:init, :"initWithCoder:", :"initWithFrame:", :"initWithSize:", :"initialize_clone:", :"initialize_dup:", :selectionAffinity]
(main)> v.send("initWithFrame:", CGRectMake(10, 10, 100, 100))
dyld: lazy symbol binding failed: Symbol not found: __ZN9RoxorCore14find_bs_structESs
Referenced from: /Library/RubyMotion/data/ios/7.0/iPhoneSimulator/libmacruby-repl.dylib
Expected in: flat namespace
@dastels
dastels / gist:6753981
Created September 29, 2013 16:23
Sample iLisp code for using abutton
(let ((w (.window *app*))
(b (UIButton/buttonWithType: UIButtonTypeSystem)))
(.frame= b '((10 100) (100 44)))
(.backgroundColor= b (UIColor/lightGrayColor))
(.setTitle:forState: b "Push Me" UIControlStateNormal)
(.setTitleColor:forState: b (UIColor/blackColor) UIControlStateNormal)
(.when b UIControlEventTouchUpInside
(lambda (sender)
(trace "click!")))
(.addSubview w b))
@dastels
dastels / gist:6759610
Last active December 24, 2015 06:49
First working GUI iLisp code: a F<->C temperature convertor. Shows use of views, text fields, and buttons with callbacks.
(let ((w (.window *app*))
(root (.init (UIView.)))
(input (.init (UITextField.)))
(output (.init (UITextField.)))
(convert-f-c (UIButton/buttonWithType: UIButtonTypeSystem))
(convert-c-f (UIButton/buttonWithType: UIButtonTypeSystem)))
(.frame= root '((10 200) (300 300)))
(.backgroundColor= root (UIColor/lightGrayColor))
(let ((w (.window *app*))
(root (.init (UIView.)))
(input (.init (UITextField.)))
(output (.init (UITextField.)))
(convert-f-c (UIButton/buttonWithType: UIButtonTypeSystem))
(convert-c-f (UIButton/buttonWithType: UIButtonTypeSystem)))
(.frame= root '((10 200) (300 300)))
(.backgroundColor= root (UIColor/lightGrayColor))
@dastels
dastels / temperature.lsp
Created October 1, 2013 02:02
another test
(let ((w (.window *app*))
(root (.init (UIView.)))
(input (.init (UITextField.)))
(output (.init (UITextField.)))
(convert-f-c (UIButton/buttonWithType: UIButtonTypeSystem))
(convert-c-f (UIButton/buttonWithType: UIButtonTypeSystem)))
(.frame= root '((10 200) (300 300)))
(.backgroundColor= root (UIColor/lightGrayColor))
@dastels
dastels / with_close.lsp
Created October 2, 2013 05:05
F <-> C converter with a close button
(let ((w (.window *app*))
(root (.init (UIView.)))
(input (.init (UITextField.)))
(output (.init (UITextField.)))
(convert-f-c (UIButton/buttonWithType: UIButtonTypeSystem))
(convert-c-f (UIButton/buttonWithType: UIButtonTypeSystem))
(close (UIButton/buttonWithType: UIButtonTypeSystem)))
(.frame= root '((10 200) (220 200)))
(.backgroundColor= root (UIColor/lightGrayColor))
(let ((w (.window *app*))
(root (.init (UIView.)))
(input (.init (UITextField.)))
(output (.init (UITextField.)))
(convert-f-c (UIButton/buttonWithType: UIButtonTypeSystem))
(convert-c-f (UIButton/buttonWithType: UIButtonTypeSystem))
(close (UIButton/buttonWithType: UIButtonTypeSystem)))
(.frame= root '((10 200) (220 200)))
(.backgroundColor= root (UIColor/lightGrayColor))