- RubyMotion iOS Develoment Essentials
- Abhishek Nalwaya Akshat Paul
- 431字
- 2021-08-13 16:43:54
Folder structure
In this section, we will understand the folder structure of our application as we know from the previous section that motion create <project name>
sets up the directory structure with all the essential files to run a simple RubyMotion application. Let's walk through each one of them to have a precise understanding of their function:
- The
app
folder: This is the core of your application code; you will write most of your code in this folder. RubyMotion iterates in this folder and loads any.rb
file that it catches.Tip
If you want to keep your code somewhere else other than the
app
directory, add the folder path to theRakefile
. - The
app_delegate.rb
file in theapp
folder: This file is at the heart of the RubyMotion application. If you are a little familiar with iOS development, this is the delegate file. A delegate is an object that usually reacts to some event in another object and/or can affect how another object behaves. There are various methods that can be implemented inUIApplicationDelegate
. These methods are called during the different phases of an application, such as during the finish of its launch, during termination, when the application is low on memory, and during the occurrence of important changes. While the application is running, tracking its state transitions is one of the main jobs of the application delegate.App delegates use the method
application:didFinishLaunchingWithOptions
as the first entry point. This method is called after your application has been launched. When this method is called, your application is in the inactive state. A few other methods available are:applicationWillEnterForeground
applicationWillTerminate
application:shouldSaveApplicationState
application:shouldRestoreApplicationState
A full list of available methods can be obtained from the iOS developer library (http://developer.apple.com/library/ios). The good part here is that most of the methods are self-explanatory by their name. For example,
applicationWillEnterForeground
will be called when your application is relaunched.Tip
We see that in some iOS 6 applications, the app is restored to the previous state; we can handle this in an application delegate.
- The
resources
folder: As the name suggests, theresources
folder contains static content, such as images, sounds, UI layouts, and icons that we use in our applications. - The
Spec
folder: This folder contains automated test cases. RubyMotion supports a Ruby testing framework, Bacon; it is a small RSpec clone that is used for writing unit, functional, and UI tests. By default, it createsmain_spec.rb
as an example. Rakefile
: WithRakefile
we can configure our application name, resources, gems to be included, and the code location. We will discuss more aboutRakefile
later in this chapter.
- 零基礎玩轉區塊鏈
- 編程卓越之道(卷3):軟件工程化
- 體驗設計原理:行為、情感和細節
- Learning ArcGIS for Desktop
- Android系統級深入開發
- LabVIEW虛擬儀器入門與測控應用100例
- Developing SSRS Reports for Dynamics AX
- 精通MySQL 8(視頻教學版)
- Ext JS 4 Plugin and Extension Development
- Blender 3D Cookbook
- Scala編程(第4版)
- 打造流暢的Android App
- Building E-Commerce Solutions with WooCommerce(Second Edition)
- 微信公眾平臺服務號開發:揭秘九大高級接口
- 計算機視覺增強現實應用平臺開發