Miscellanies of iOS 1)

1. In many GUI builders on other platforms, you describe what you want an application to look like and then press a button to generate a bunch of code. Xcode’s interface builder is different. It is an object editor: you create and configure view objects and then save them into an archive. The archive is a XIB (pronounced “zib”) file.

A XIB file is an XML representation of the archived objects. When you build a project, the XIB file is compiled into a NIB file. Developers work with XIB files (they’re easier to edit), and applications use NIB files (they’re smaller and easier to parse). However, most iOS developers use the words XIB and NIB interchangeably.

2. File's Owner :

This is the object that will have access to the objects archived in the XIB file. It will be an instance of QuizViewController, which is the object responsible for managing events that occur on this interface.

3. You may hear iOS programmers mention the Model-View-Controllerpattern. What this means is every object you create is exactly one of the following: a model object, a view object, or a controller object.     pp42

View objects are visible to the user. In Quiz, the buttons, labels, and the view they are placed on top of are all view objects. Views are usually standard UIView subclasses (UIButton, UISlider), but you will sometimes write custom view classes. These typically have names like DangerMeterView or IncomeGraphView.

Model objects typically use standard collection classes (NSArray, NSDictionary, NSSet) and standard value types (NSString, NSDate, NSNumber). But there can be custom classes, which typically have names that sound like data-bearing objects, such as InsurancePolicy or PlayerHistory.

 

4. What do IBOutlet and IBAction do in the declarations you just entered? They allow you to connect your controller and your view objects in the XIB file.

A connection lets one object know where another object is in memory so that the two objects can work together.

Select QuizViewController.xib in the project navigator to reopen it. In the outline view, find the File's Owner object (which is standing in for the QuizViewController). Right-click or Control-click on the File's Owner to bring up the connections panel (Figure 1.14). Then drag from the circle beside questionField to the UILabel.

Notice that you drag from the object with the pointer to the object that you want that pointer to point at.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值