- RubyMotion iOS Develoment Essentials
- Abhishek Nalwaya Akshat Paul
- 346字
- 2021-08-13 16:43:55
REPL – the interactive console
RubyMotion comes with an interactive console that lets us traverse and scan the code that we are using in our application. The good thing is that the console is connected to the application running on the simulator. This means that if we make any changes from the console, it will be reflected on the simulator in real time. Let's try this with our HelloWorld
application.
Run the application as follows:
$rake
As expected, it will open a simulator and the terminal screen will show:
(main)>
Now hold the Command key and hover the mouse over the simulator. You will see a red-bordered box. As we move the mouse pointer over an element, we can see its corresponding class object appearing in the terminal window (UIView:0xc5710c0)?
as seen in the following screenshot. Now click the mouse to select the object that you want to work on dynamically.

Try the following command on the terminal and observe the changes in the simulator:
self
returns the current object selected by the mouse.
(#<UIView:0x7652680>)> self => #<UIView:0x7652680>
Create an object blue
for the UIColor
class and assign the color blue to the variable as follows:
(#<UIView:0x7652680>)> blue = UIColor.blueColor
To change the background color of the view, use the backgroundColor
property of the selected view as follows:
=> #<UICachedDeviceRGBColor:0xb05a800> (#<UIView:0x7652680>)> self.backgroundColor = blue => #<UICachedDeviceRGBColor:0xb05a800>
Make sure that the background color on the simulator has been changed to blue as shown in the following screenshot:

Let's dismiss the alert box by clicking on any button and put a new alert box with the following code:
a = UIAlertView.new a.title = "My Title" a.message = "Hello World!" a.show
The simulator shows a new alert box on screen without compiling the code as shown in the following screenshot:

You can dismiss the alert box as follows:
(main) > a.dismiss
We can see how REPL is a great tool for developing applications for iOS and how it helps us make changes dynamically. To make these changes permanent we need to add the same code to our source code.
- Node.js Design Patterns
- Hands-On Machine Learning with scikit:learn and Scientific Python Toolkits
- BeagleBone Media Center
- PostgreSQL技術內幕:事務處理深度探索
- Visual Basic程序設計(第3版):學習指導與練習
- Windows Presentation Foundation Development Cookbook
- Building Mapping Applications with QGIS
- Java程序設計
- Getting Started with Gulp
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- R語言數據可視化:科技圖表繪制
- Raspberry Pi Robotic Blueprints
- Beginning PHP
- ASP.NET jQuery Cookbook(Second Edition)
- VC++ 2008專題應用程序開發實例精講