iPhone和iPad
软件支持
iOS
- 2007年发布
- 2008年发布开发者SDK
- iOS当前的版本为:10.2
- 官方开发者论坛:Apple Developer Forums
- 官方开发者教程文档资源库:Resources
硬件支持
- A10处理器(iPhone7/7+)
- A9处理器(iPhone6s/6s+)
- A8处理器(iPhone6/iPhone6+)
- A8X处理器(iPad Air2)
- A7处理器(iPad Mini3),A7开始处理器为64位
- 运动辅助处理器(iPhone5s和iPad Air之后)
- 3D Touch(iPhone6s/6s+之后)
- 亮度传感器
- 靠近设备感应器
- 多点触控(multi-touch)屏幕
- 加速器
- 数字罗盘
- 三轴陀螺仪
- 辅助GPS(AGPS)
- 气压计(iPhone 6和iPad Air2之后)
- 指纹传感器(iPhone 5s和iPad Air2之后)
- 压力传感器(iPhone 6s and iPhone 7)
- 触觉反馈引擎(iPhone 6s and iPhone 7)
- 前后摄像头(模式可调分辨率)
Apple Watch和Apple TV
Apple Watch
软件支持
- WatchOS(最前版本WatchOS 3.0)
硬件支持
- 处理器
- 苹果S1单片机
- 苹果S2单片计算机
- 传感器
- 环境光传感器
- 加速传感器和陀螺仪
- 心率传感器
- GPS(只支持Series2)
- 数据连接
- 蓝牙4.0(LTE)
- Wifi 802.11b/g/n 2.4 GHz(仅限在系统中使用)
- 充电
- 电感应充电
Apple TV(2015)
软件支持
- Apple tvOS
- SDK available for Apps Development
硬件支持
- 处理器(A8)
- 遥控传感器
- 加速器和陀螺仪
- 触摸传感器
- Siri麦克风
- 数据连接
- 蓝牙4.0 (LE)
- 红外线接收器
- 820.11交流Wifi天线系统
- 10/100 BASE-T以太网
- USB-C服务和支持
iOS SDK
2009年iPhone SDK 3.0发布,现在已经更新到iOS SDK 10.0。
iOS SDK 9.0/9.1特性
- Apple Pay
- App应用程序扩展
- Touch ID指纹识别授权认证
- Metal游戏引擎
- HealthKit,HomeKit,iPad多任务切换改进功能
- 3D Touch搜索GameplayKit
- App应用瘦身
- 从左到右的语言支持
- Swift改进
iOS SDK 10.0新特性
- SiriKit
- Callkit
- 集成VOIP
- 呼叫屏蔽
- Homekit改进(在控制中心组织Homekit配件)
- Apple Pay改进
- 消息应用程序集成
- Widget改进
iOS技术架构
- Cocoa Touch框架层
- UI组件
- 触摸处理和事件驱动
- 系统接口
- Media媒体层
- 音频视频播放
- 动画
- 2d和3d图形
- Core Servie核心服务层
- 底层特性
- 文件
- 网络
- 位置服务等
- Core OS系统层
- 内存管理
- 底层网络
- 硬件管理
新型语言Swift(从OC到Swift)
Swift是一门新型语言,借鉴了Haskell,Ruby,Python,C#等语言特性,看上去偏脚本化,swift仍然支持已有的Cocoa和Cocoa Touch框架。
Swift的主要新特性:
- 安全【严格的类型检查】
- 强大【高度优化的LLVM编译器】
- 新型【借鉴多种语言特性,表达更简单精确】
从基本的ViewController代码窥探OC和Swift区别
Swift
// ViewController.swift@H_787_301@
import@H_787_301@ UIKit
class@H_787_301@ ViewController: UIViewController {
@IBOutlet@H_787_301@ weak var label1: UILabel!
@IBAction@H_787_301@ func button1(sender: AnyObject) {
label1.text = "Hello iOS!!!"@H_787_301@
}
override@H_787_301@ func viewDidLoad() {
super@H_787_301@.viewDidLoad()
// Do any additional setup after loading the view,typically from a nib.@H_787_301@
}
override@H_787_301@ func didReceiveMemoryWarning() { super@H_787_301@.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.@H_787_301@
}
Objective-C
// ViewController.h@H_787_301@
#import <UIKit/UIKit.h>@H_787_301@@H_787_301@
@interface@H_787_301@ ViewController@H_787_301@ : UIViewController@H_787_301@@H_787_301@
@property@H_787_301@ (weak@H_787_301@,nonatomic@H_787_301@) IBOutlet@H_787_301@ UILabel@H_787_301@ *label1; - (IBAction@H_787_301@)button1:(id@H_787_301@)sender;
@end@H_787_301@
// ViewController.m@H_787_301@
#import "ViewController.h"@H_787_301@ @H_787_301@
@interface@H_787_301@ ViewController@H_787_301@ () @end@H_787_301@@H_787_301@
@implementation@H_787_301@ ViewController@H_787_301@ @synthesize@H_787_301@ label1@H_787_301@ ;@H_787_301@
- (void@H_787_301@)viewDidLoad {
[super@H_787_301@ viewDidLoad];
// Do any additional setup after loading the view,typically from a nib.@H_787_301@
}
- (void@H_787_301@)didReceiveMemoryWarning { [super@H_787_301@ didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.@H_787_301@
}
- (IBAction@H_787_301@)button1:(id@H_787_301@)sender {
label1.text@H_787_301@ = @"Hello iOS!!!"@H_787_301@ ;
}
@end@H_787_301@
Swift类的定义
import@H_787_301@ Foundation
class Ball {
// 变量@H_787_301@
var@H_787_301@ centerX: Float
var@H_787_301@ centerY: Float
var@H_787_301@ radius: Float
// 初始化方法@H_787_301@
init(centerX:Float,centerY:Float,radius:Float) {
self@H_787_301@.@H_787_301@centerX =@H_787_301@ centerX
self@H_787_301@.@H_787_301@centerY =@H_787_301@ centerY
self@H_787_301@.@H_787_301@radius =@H_787_301@ radius
}
// 实例方法@H_787_301@
func move(moveX:Float,_ moveY:Float) {
self@H_787_301@.@H_787_301@centerX +=@H_787_301@ moveX
self@H_787_301@.@H_787_301@centerY +=@H_787_301@ moveY
}
// 类方法@H_787_301@
class func aClassMethod() {
print("I am a class method"@H_787_301@)
}
}
...@H_787_301@
// 创建对象@H_787_301@
var@H_787_301@ ball1 =@H_787_301@ Ball(centerX: 7.0@H_787_301@,centerY: 5.0@H_787_301@,radius: 6.0@H_787_301@)
// 方法调用@H_787_301@
ball1.@H_787_301@move(moveX:1.0@H_787_301@,1.0@H_787_301@)
Ball.@H_787_301@aClassMethod()
流程控制语句
Objective-c
// 条件判断@H_787_301@
if@H_787_301@ (a < b) {
// Do something here@H_787_301@
} else@H_787_301@ {
// Do another thing here@H_787_301@
}
// for循环@H_787_301@
for@H_787_301@ (int@H_787_301@ i = 0@H_787_301@; i < 10@H_787_301@; i++){
// Do something here@H_787_301@
}
// while循环@H_787_301@
while@H_787_301@ (count@H_787_301@ < 10@H_787_301@) {
// Do something here@H_787_301@
}
// do-while循环@H_787_301@
do {
// Do something here@H_787_301@
} while@H_787_301@ (count@H_787_301@ < 10@H_787_301@);
Swift
// 条件判断@H_787_301@
if@H_787_301@ a < b {
// Do something here@H_787_301@
} else@H_787_301@ {
// Do another thing here@H_787_301@
}
// for循环@H_787_301@
for@H_787_301@ int@H_787_301@ i = 0@H_787_301@; i < 10@H_787_301@; i++{
// Do something here@H_787_301@
}
// while循环@H_787_301@
while@H_787_301@ count@H_787_301@ < 10@H_787_301@ {
// Do something here@H_787_301@
}
// repeat-while循环@H_787_301@
repeat {
// Do something here@H_787_301@
} while@H_787_301@ count@H_787_301@ < 10@H_787_301@
基本数据类型
String字符串
Objective-C
NSString@H_787_301@ * Str = @"string"@H_787_301@;
NSString@H_787_301@ * formatStr = [NSString@H_787_301@ stringWithFormat:@"%@and float%f"@H_787_301@,Str,3.1415@H_787_301@"]; @H_787_301@
Swift
// 可变字符串@H_787_301@
var@H_787_301@ Str = "string"@H_787_301@
var@H_787_301@ Str:String@H_787_301@ = "string"@H_787_301@
var@H_787_301@ Str = String@H_787_301@("string"@H_787_301@)
// 不可变字符串@H_787_301@
let@H_787_301@ Str = "string"@H_787_301@
let@H_787_301@ Str:String@H_787_301@ = "string"@H_787_301@
let@H_787_301@ Str = String@H_787_301@("string"@H_787_301@)
数组Array和MultableArray
Objective-C
// 静态数组@H_787_301@
NSArray@H_787_301@ *array = [[NSArray@H_787_301@ alloc] initWithObjects: ball1,ball2,nil@H_787_301@];
array[0@H_787_301@].radius@H_787_301@ = 10@H_787_301@;
// 可变数组@H_787_301@
NSMutableArray@H_787_301@ *mArray = [[NSMutableArray@H_787_301@ alloc] initWithCapacity: 2@H_787_301@];
[mArray addObject:ball1];
[mArray addObject:ball2];
Ball *newball = [mArray objectAtIndex:1@H_787_301@];
[mArray removeObjectAtIndex:1@H_787_301@];
Swift
// 静态数组@H_787_301@
let@H_787_301@ myArray: Array@H_787_301@<Ball> = [ball1,ball2]
let@H_787_301@ myArray: [Ball] = [ball1,ball2]
let@H_787_301@ myArray = [ball1,ball2]
myArray[0@H_787_301@].radius = 10@H_787_301@
// 可变数组@H_787_301@
var@H_787_301@ myArray: [Ball] = []
myArray.append(ball1)
myArray.append(ball2)
var@H_787_301@ newBall = myArray[1@H_787_301@];
myArray.remove(at: 0@H_787_301@)
UIImageView
Objective-C
UIImageView *myImage = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@”tiger.png”]]@H_787_301@;
[self.view addSubview:myImage];
myImage.center = CGPointMake(150@H_787_301@,200@H_787_301@);
myImage.frame = CGRectMake(0@H_787_301@,0@H_787_301@,50@H_787_301@,25@H_787_301@);
Swift
let myImage = UIImageView@H_787_301@(image: UIImage@H_787_301@(named: "tiger.png"@H_787_301@))
view.addSubview@H_787_301@(myImage)
myImage2.frame@H_787_301@ = CGRect@H_787_301@(x:0@H_787_301@,y:0@H_787_301@,width:50@H_787_301@,height:25@H_787_301@)
myImage2.center@H_787_301@ = CGPoint@H_787_301@(x:150@H_787_301@,y:200@H_787_301@)
… …