iOS App Programming Guide => Design Basic & Core Objects
2014-01-08 04:33
561 查看
iOS App Programming Guide
Model-View-Controller—This design pattern governs the overall structure of your app.
Delegation—This design pattern facilitates the transfer information and data from one object to another.
Target-action—This design pattern translates user interactions with buttons and controls into code that your app can execute.
Block objects—You use blocks to implement callbacks and asynchronous code.
Sandboxing—All iOS apps are placed in sandboxes to protect the system and other apps. The structure of the sandbox affects the placement of your app’s files and has implications for data backups and some app-related features.
Other commonly used data types:
for scalar signed and unsigned integers that define the integer size based on the architecture.
define a contiguous portion of a series. For example, you can use ranges to define the selected characters in a string.
of seconds (whole and partial) in a given time interval.
and vertical extents.
You can also use Core Data(Core Data Programming Guide)
or Document Objects(Document-Based App
Programming Guide for iOS) when construct your data model
Programming Guide for iOS) or OpenGL ES(OpenGL
ES Programming Guide for iOS).
is a directory in the file system that groups related resources together in one place. An iOS app bundle contains the app executable file and supporting resource files such as app icons, image files, and localized content.
A typical app bundle
App Design Basics
Learning the Fundamental iOS Design Patterns and Techniques
The most important design patterns you must know are:Model-View-Controller—This design pattern governs the overall structure of your app.
Delegation—This design pattern facilitates the transfer information and data from one object to another.
Target-action—This design pattern translates user interactions with buttons and controls into code that your app can execute.
Block objects—You use blocks to implement callbacks and asynchronous code.
Sandboxing—All iOS apps are placed in sandboxes to protect the system and other apps. The structure of the sandbox affects the placement of your app’s files and has implications for data backups and some app-related features.
Core App Objects
The Core Objects of Your App
UIApplication object | You use the UIApplicationobject essentially as is—that is, without subclassing. This controller object manages the app event loop and coordinates other high-level app behaviors. Your own custom app-level logic resides in your app delegate object, which works in tandem with this object. |
App delegate object | The app delegate is a custom object created at app launch time, usually by theUIApplicationMainfunction. The primary job of this object is to handle state transitions within the app. |
Documents and data model objects | Data model objects store your app’s content and are specific to your app. Apps can also use document objects (custom subclasses of UIDocument) to manage some or all of their data model objects. Document objects are not required but offer a convenient way to group data that belongs in a single file or file package. |
View controller objects | View controller objects manage the presentation of your app’s content on screen. A view controller manages a single view and its collection of subviews. When presented, the view controller makes its views visible by installing them in the app’s window. |
UIWindow object | A UIWindowobject coordinates the presentation of one or more views on a screen. Most apps have only one window, which presents content on the main screen, but apps may have an additional window for content displayed on an external display. |
View, control, and layer objects | Views and controls provide the visual representation of your app’s content. Aview is an object that draws content in a designated rectangular area and responds to events within that area.Controls are a specialized type of view responsible for implementing familiar interface objects such as buttons, text fields, and toggle switches. In addition to incorporating views and controls, apps can also incorporate Core Animation layers into their view and control hierarchies.Layer objects are actually data objects that represent visual content. Views use layer objects intensively behind the scenes to render their content. You can also add custom layer objects to your interface to implement complex animations and other types of sophisticated visual effects. |
The Data Model
Data classes in the Foundation framework:Data | Classes | Description |
---|---|---|
Strings and text | NSString( NSMutableString) NSAttributedString ( NSMutableAttributedString) | Strings in iOS are Unicode based. The string classes provide support for creating and manipulating strings in a variety of ways. The attributed string classes support stylized text and are used only in conjunction with Core Text. |
Numbers | NSNumber NSDecimalNumber NSIndexPath | When you want to store numerical values in a collection, use number objects. TheNSNumberclass can represent integer, floating-point values, Booleans, and chartypes. The NSIndexPathclass stores a sequence of numbers and is often used to specify multi-layer selections in hierarchical lists. |
Raw bytes | NSData( NSMutableData) NSValue | For times when you need to store raw streams of bytes, use data objects. Data objects are also commonly used to store objects in an archived form. TheNSValueclass is typically extended (usingcategories) and used to archive common data types such as points and rectangles. |
Dates and times | NSDate NSDateComponents | Use date objects to store timestamps, calendar dates, and other time-related information. |
URLs | NSURL | In addition to their traditional use for referring to network resources, URLs in iOS are the preferred way to store paths to files. TheNSURLclass even provides support for getting and setting file-related attributes. |
Collections | NSArray( NSMutableArray) NSDictionary( NSMutableDictionary) NSIndexSet( NSMutableIndexSet) NSOrderedSet( NSMutableOrderedSet) NSSet( NSMutableSet) | Use collections to group related objects together in a single place. The Foundation framework provides several different types of collection classes |
NSInteger/
NSUInteger—Abstractions
for scalar signed and unsigned integers that define the integer size based on the architecture.
NSRange—A structure used to
define a contiguous portion of a series. For example, you can use ranges to define the selected characters in a string.
NSTimeInterval—The number
of seconds (whole and partial) in a given time interval.
CGPoint—An x and y coordinate value that defines a location.
CGSize—Coordinate values that define a set of horizontal
and vertical extents.
CGRect—Coordinate values that define a rectangular region.
You can also use Core Data(Core Data Programming Guide)
or Document Objects(Document-Based App
Programming Guide for iOS) when construct your data model
The User Interface
We can build an interface with UIKit Views(ViewProgramming Guide for iOS) or OpenGL ES(OpenGL
ES Programming Guide for iOS).
The App Bundle
A bundle(Bundle Programming Guide)is a directory in the file system that groups related resources together in one place. An iOS app bundle contains the app executable file and supporting resource files such as app icons, image files, and localized content.
A typical app bundle
File | Example | Description |
---|---|---|
App executable | MyApp | The executable file contains your app’s compiled code. The name of your app’s executable file is the same as your app name minus the.appextension. This file is required. |
The information property list file | Info.plist | The Info.plistfile contains configuration data for the app. The system uses this data to determine how to interact with the app. This file is required and must be called Info.plist. For more information, see“The Information Property List File.” |
App icons | Icon.png Icon@2x.png Icon-Small.png Icon-Small@2x.png | Your app icon is used to represent your app on the device’s Home screen. Other icons are used by the system in appropriate places. Icons with@2xin their filename are intended for devices with Retina displays. An app icon is required. For information about specifying icon image files, see“App Icons.” |
Launch images | Default.png Default-Portrait.png Default-Landscape.png | The system uses this file as a temporary background while your app is launching. It is removed as soon as your app is ready to display its user interface. At least one launch image is required. For information about specifying launch images, see“App Launch (Default) Images.” |
Storyboard files (or nib files) | MainBoard.storyboard | Storyboards contain the views and view controllers that the app presents on screen. Views in a storyboard are organized according to the view controller that presents them. Storyboards also identify the transitions (called segues) that take the user from one set of views to another. The name of the main storyboard file is set by Xcode when you create your project. You can change the name by assigning a different value to the NSMainStoryboardFilekey in the Info.plistfile.) Apps that usenib files instead of storyboards can replace the NSMainStoryboardFilekey with the NSMainNibFilekey and use that key to specify their main nib file. The use of storyboards (or nib files) is optional but recommended. |
Ad hoc distribution icon | iTunesArtwork | If you are distributing your app ad hoc, include a 512 x 512 pixel version of your app icon. This icon is normally provided by the App Store from the materials you submit to iTunes Connect. However, because apps distributed ad hoc do not go through the App Store, your icon must be present in your app bundle instead. iTunes uses this icon to represent your app. (The file you specify should be the same one you would have submitted to the App Store, if you were distributing your app that way.) The filename of this icon must be iTunesArtworkand must not include a filename extension. This file is required for ad hoc distribution but is optional otherwise. |
Settings bundle | Settings.bundle | If you want to expose custom app preferences through the Settings app, you must include a settings bundle. This bundle contains theproperty list data and other resource files that define your app preferences. The Settings app uses the information in this bundle to assemble the interface elements required by your app. This bundle is optional. For more information about preferences and specifying a settings bundle, seePreferences and Settings Programming Guide. |
Nonlocalized resource files | sun.png mydata.plist | Nonlocalized resources include things like images, sound files, movies, and custom data files that your app uses. All of these files should be placed at the top level of your app bundle. |
Subdirectories for localized resources | en.lproj fr.lproj es.lproj | Localized resources must be placed in language-specific project directories, the names for which consist of an ISO 639-1 language abbreviation plus the.lprojsuffix. (For example, the en.lproj, fr.lproj, and es.lprojdirectories contain resources localized for English, French, and Spanish.) An iOS app should be internationalized and have alanguage .lprojdirectory for each language it supports. In addition to providing localized versions of your app’s custom resources, you can also localize your app icon, launch images, and Settings icon by placing files with the same name in your language-specific project directories. For more information, see “Localized Resource Files.” |
相关文章推荐
- iOS App Programming Guide => State Preserve/Restore & Resources
- iOS App Programming Guide => App States
- iOS:xib(Resource Programming Guide 部分) && IB
- App Programming Guide for iOS
- iOS App Programming Guide 官方文档
- View Controller Programming Guide for iOS---(三)---Using View Controllers in Your App
- <转>IOS开发之实现App消息推…
- ios开发 <AppName>-Prefix.pch文件的用法详解
- iOS Programming Basic: How Does the Hello World App Work?
- iOS视频直播初窥:高仿<喵播APP>
- App Programming Guide for iOS
- iOS出现 Undefined symbols for architecture armv7 std::basic_string<char, std::char_traits<char>
- OpenGL ES Programming Guide for iOS 第二章
- ios 处理内存警告<一>
- <iOS, Android>移动原型工具总结
- error LNK2005: "public: void __thiscall std::basic_ofstream<char,struct std::char_traits<char> >::`v
- 关于Android Studio导入.9图片报 ':app:mergeDebugResources'. > Some file crunching failed, see logs for detai
- OpenGL ES Programming Guide for iOS
- View Controller Programming Guide for iOS---(二)---View Controller Basics
- <<The C Programming Language>>学习之路-练习题参考答案 1-3