`
guafei
  • 浏览: 322650 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

iOS App Programming Guide

 
阅读更多
用户界面的选择:
1:堆积方式:sdk提供的控件,你一个一个往上加,搭建起来就ok
2:用openGL es绘图,如果你的应用程序需要频繁的画面更新或复杂的渲染,那么使用它,一般游戏会使用这种。

数据模型:
String: NSString(NSMutableString)
         NSAttributedString(NSMutableAttributed-String)
Numbers:NSNumber NSDecimalNumber NSIndexPath
Raw bytes:NSData (NSMutableData) NSValue
Dates and times:NSDate NSDateComponents
URLs:NSURL
Collections:NSArray(NSMutableArray) NSDictionary(NSMutableDictionary)
             NSIndexSet(NSMutableIndexSet) NSOrderedSet(NSMutableOrderedSet)
             NSSet (NSMutableSet)

NSAttributedString:可以根据下标来设置字符串的颜色,字体大小等属性。
NSNumber:继承自NSValue,使用NSValue来辅助我们实现一些简单数据结构的封装,可以搜索下。
NSDecimalNumber:继承NSNumber,用科学计数来表示,10的n次
NSIndexPath:tableView里面的代理方法有这个形参,表示第几个section,第几个row。
NSSet:无序的集合,不允许重复元素

一个app bundle基本上包括:
1:可执行文件
2:配置文件(例如Info.plist)
3:app icon(也就是小图标),一般要四张(Icon.png Icon@2x.png Icon-Small.png Icon-  Small@2x.png)
4:app launch的图标
5:xib或者storyboard文件
6:iTunesArtwork
7:公开自定义自己的setting(也就是偏好设置),那么要有setting.bundle
8:本地化资源文件,比如图片,声音,使用的plist文件等
9:多国语言(en.lproj fr.lproj es.lproj,英国、法国、西班牙)

app的状态有五种:
1:not running:没有启动app
2:inactive:app运行在前台,但是没有任何事件的处理
3:active:app运行在前台,并且在处理事件
4:background:app在后台运行,还在内存中,并且执行代码
5:suspend:app还在内存中,但是不运行任何代码,如果内存不足,会自动kill掉

app states changes:


lanch app的方式有两种,一种是直接lanch到前台,展现给用户,一种是直接lanch到后台
两种方式的执行步骤:
直接lanch到前台前台

直接lanch到后台


觉得lanch到前台还是后台可以通过willFinishLaunchingWithOptions:或didFinishLaunchingWithOptions:这两个方法里设置applicationState为UIApplicationStateBackground或者UIApplicationStateInactive.

lanch的过程主要是对UIKit库的处理:
#import <UIKit/UIKit.h>
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppDelegate
class]));
}
}


对于UIKIT_EXTERN int UIApplicationMain(int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName)的后面两个参数,一般都为nil,它代表的含义是:第三个参数默认为是@"UIApplication",这个参数必须是UIApplication或其子类的名字,它代表着当前iPhone程序本身,这个程序会去读info.plist文件获取配置信息,一个重要的信息是Main nib file base name(主nib文件)的值,一般为MainWindow(.xib),第四个参数为MainWindow.xib文件中遵循UIApplicationDelegate的类的类名,因为UIApplication定义了一个delegte变量,这个变量应该遵循UIApplicationDelegate,负责控制程序的运行,在主nib文件中,你应该创建一个继承于Object,并遵循UIApplicationDelegate的类,如果主nib文件没有这个类,你应该自定义一个这样的类,并将第四个参数改为这个类的类名,否则这个程序不知道如何进行运作,因为前三个参数代表应用程序本身,它除了把应用的事件循环启动起来,并读取info.plist里的配置信息,不做其它任何事情。

app lanch之后干了些什么,调用delegate
application:willFinishLaunchingWithOptions: and
application:didFinishLaunchingWithOptions
检查内容和相应是否都ok,初始化关键数据,准备view和window显示
如果在lanch time你没有指定nib或者storybord,那么你可以在willFinishLaunchingWithOptions:中指定,不过这个两个方法尽量不要用,为了启动更快,app启动一般被设计成不超过5s,如果lanch到的前台,那么还要调用方法applicationDidBecomeActive:

IOS的对中断的处理:


app从前台切换到后台:

会有一个通知:UIApplicationDidEnterBackgroundNotification

app从后台切换到前台

会有一个通知:UIApplicationWillEnterForegroundNotification

app在被唤醒的过程中,有一系列的通知,如果注册了这些通知,那么可以收到相关通知
比如被唤醒的app所存储的数据被修改了,那么可以注册这个通知,然后被唤醒的时候,可以告知用户。

app被kill的时候会调用applicationWillTerminate:

The Main Run Loop:


检查是否支持多线程代码(IOS4之后支持):
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:@selector(isMultitaskingSupported)])
backgroundSupported = device.multitaskingSupported;


长时间在后台运行的程序,有几种情况:
1:类似音乐播放器这种应用。
2:类似导航类应用,需要不停的把位置信息。
3:下载上传等应用
4:更新应用的操作
5:app支持VoIP协议
如果需要后台运行程序,需要再plist文件中定赋值UIBackgroundModes

ios ui 保存(http://blog.csdn.net/tonny_guan/article/details/8547903):


ios ui 恢复


连接到app store的代码:
NSURL *myURL = [NSURL
URLWithString:@"todolist://www.acme.com?Quarterly%20Report#200806231300"];
[[UIApplication sharedApplication] openURL:myURL];


自定义URL,打开自己开发的app:
http://www.2cto.com/kf/201301/187156.html

关闭自动锁屏功能:
set the idleTimerDisabled property of the shared UIApplication object to
YES

在更新app的时候,一下两个目录会被保存:
<Application_Home> /Documents
<Application_Home> /Library

icloud和itunes不会备份以下目录:
<Application_Home> /AppName .app
<Application_Home> /Library/Caches
<Application_Home> /tmp

内存警告时,会调用applicationDidReceiveMemoryWarning:(这个是appdelegate的);didReceiveMemoryWarning(这个是viewcontroller)或者注册UIApplicationDidReceiveMemoryWarningNotificationnotification.通知

减少app的内存方法:
1:减少内存泄露
2:资源文件尽量小
3:使用core data或则sqllite存储大文件
4:懒加载
5:使用thumb指令集,编译代码使用-mthumb参数

明智的分配内存
1:尽量少用autorelease
2:根据size来分配内存,不要小对象分配了大内存

节省电池寿命:
1:尽量不要使用轮训,用NSRunLoop or NSTimer来替代轮训
2:set idleTimerDisabled 为no
3:尽量合并处理事务,使cpu空闲
4:避免频繁读写磁盘
5:关闭地理位置开关,当你不用的时候
6:屏幕滑动不要太快
7:使用wifi会更省电

使用UIRequiresPersistentWiFi来设置wifi,可以在plist文件中设置
每个app都有自己的一个sandbox环境,主要出于安全考虑, iOS应用程序只能在为该改程序创建的文件系统中读取文件,不可以去其它地方访问,应用程序不能翻过自己的围墙去访问别的存储空间的内容。
sandbox的目录结构:
默认情况下,每个沙盒含有3个文件夹:Documents, Library 和 tmp。因为应用的沙盒机制,应用只能在几个目录下读写文件
Documents:苹果建议将程序中建立的或在程序中浏览到的文件数据保存在该目录下,iTunes备份和恢复的时候会包括此目录
Library:存储程序的默认设置或其它状态信息;
Library/Caches:存放缓存文件,iTunes不会备份此目录,此目录下文件不会在应用退出删除
tmp:提供一个即时创建临时文件的地方。

iTunes在与iPhone同步时,备份所有的Documents和Library文件。
iPhone在重启时,会丢弃所有的tmp文件。

用keychain进行数据加密,可以使用苹果官方发布的KeychainItemWrapper或者SFHFKeychainUtils
  • 大小: 19.6 KB
  • 大小: 38.8 KB
  • 大小: 37.1 KB
  • 大小: 33.8 KB
  • 大小: 31.9 KB
  • 大小: 20.7 KB
  • 大小: 29.2 KB
  • 大小: 30.3 KB
  • 大小: 43.2 KB
分享到:
评论

相关推荐

    IOS app programming guide

    编写ios app应用的指导。包括了app设计的基础指导,app核心对象,app状态和多任务处理以及相关的资源。

    iOS App Programming Guide(2012-09-19版)

    苹果的app programming guide,2012-09-19版

    iPhone App Programming Guide

    iOS 开发,iOS开发人员不得不读的书。 英文原版

    iOS_App_Programming_Guide

    本《iOS_App_Programming_Guide》文档是Apple苹果系统的开发技术文档,详细介绍了如何在Xcode上开发iOS应用程序。

    iphone app programming guide

    苹果ios iphone app programming guide

    iOS Application Programming Guide

    Meeting the App Store and System Requirements 11 Tuning Performance for the Underlying Device 11 See Also 11 Chapter 1 The Application Runtime Environment 13 Fast Launch, Short Use 13 Specialized ...

    Mastering iOS 11 Programming, 2nd Edition 2017年出版553页

    Transition to a Professional iOS developer with the most in-depth and advanced level guide on Swift 4 and Xcode 9 About This Book Filled with practical examples, this comprehensive guide explores all...

    CarPlay-App-Programming-Guide【搜狗文档翻译_译文_英译中】1

    概观 四发展环境 七配置您的权利 七CarPlay 音频应用和向后兼容性 9CarPlay 通信应用和向后兼容性 9模拟器 9模板 11行动表 12警报 12接

    iOS_Application_Programming_Guide中文版

    本文档之前命名为iPhone OS编程指南。 iPhone SDK为创建iPhone的本地应用程序提供必需的工具和资源。在用户的 Home屏幕上,iPhone的本地应用程序表示为图标。它们和运行在Safari内部 的web应用程序不同,在基于...

    iPhone App ProgrammingGuide

    IOS 编程手册,由Apple提供,主要涉及iOS上面编程的方法,原则等等。

    iOS 7 Programming Fundamentals

    Once you master the fundamentals, you’ll be ready to tackle the details of iOS app development with author Matt Neuburg’s companion guide, Programming iOS 7—coming in December 2013., Explore the C...

    iOS 7 Programming Pushing the Limit

    Get ready to create killer apps for iPad and iPhone on the new iOS 7!...iOS 7 Programming: Pushing the Limits will help you develop applications that take full advantage of everything iOS 7 has to offer.

    iOS 7 programming pushing the limits

    iOS 7 Programming Pushing the Limits Rob Napier Mugunth Kumar ISBN: 978 1 118 81834 3 504 pages February 2014 iOS 7 Programming Pushing the Limits 1118818342 cover image Read an Excerpt Description ...

    iOS 10 App Development Essentials

    34. A Guide to Multitasking in iOS 10 35. An iOS 10 Multitasking Example 36. Working with Directories in Swift on iOS 10 37. Working with Files in Swift on iOS 10 38. iOS 10 Directory Handling and ...

    ios App programging

    官方app programming guide for ios

    iOS 10 Programming Cookbook

    iOS 10 Programming Cookbook by Hossam Ghareeb English | 6 Apr. 2017 | ASIN: B01I3OT0U0 | 520 Pages | AZW3 | 26.77 MB Key Features Create high performance iOS apps with a focus on application ...

    iOS 6 Programming Pushing the Limits

    This guide offers serious information for serious programmers who know the basics and are ready to dive into the advanced features of iOS. You'll learn to create killer apps for the iPad, iPhone, and...

    Learning IOS Game Programming_A Hands-on

    While many people think games are hard to build, they can actually be quite easy, and Learning iOS Game Programming is your perfect beginner’s guide. Michael Daley walks you through every step as ...

    Picture.Guide.to.iOS.Programming.B019HL24VK

    I have been programming in Swift since its beta release and believe that it provides a more simplified approach to app development compared to its predecessor Objective-C. I have no doubt that the ...

Global site tag (gtag.js) - Google Analytics