@H_301_2@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_287_301@
import@H_287_301@ UIKit
class@H_287_301@ ViewController: UIViewController {
@IBOutlet@H_287_301@ weak var label1: UILabel!
@IBAction@H_287_301@ func button1(sender: AnyObject) {
label1.text = "Hello iOS!!!"@H_287_301@
}
override@H_287_301@ func viewDidLoad() {
super@H_287_301@.viewDidLoad()
// Do any additional setup after loading the view,typically from a nib.@H_287_301@
}
override@H_287_301@ func didReceiveMemoryWarning() { super@H_287_301@.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.@H_287_301@
}
Objective-C
// ViewController.h@H_287_301@
#import <UIKit/UIKit.h>@H_287_301@@H_287_301@
@interface@H_287_301@ ViewController@H_287_301@ : UIViewController@H_287_301@@H_287_301@
@property@H_287_301@ (weak@H_287_301@,nonatomic@H_287_301@) IBOutlet@H_287_301@ @H_502_352@UILabel@H_287_301@ *label1; - (IBAction@H_287_301@)button1:(id@H_287_301@)sender;
@end@H_287_301@
// ViewController.m@H_287_301@
#import "ViewController.h"@H_287_301@ @H_287_301@
@interface@H_287_301@ ViewController@H_287_301@ () @end@H_287_301@@H_287_301@
@implementation@H_287_301@ ViewController@H_287_301@ @synthesize@H_287_301@ label1@H_287_301@ ;@H_287_301@
- (void@H_287_301@)viewDidLoad {
[super@H_287_301@ viewDidLoad];
// Do any additional setup after loading the view,typically from a nib.@H_287_301@
}
- (void@H_287_301@)didReceiveMemoryWarning { [super@H_287_301@ didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.@H_287_301@
}
- (IBAction@H_287_301@)button1:(id@H_287_301@)sender {
label1.text@H_287_301@ = @"Hello iOS!!!"@H_287_301@ ;
}
@end@H_287_301@
Swift类的定义
import@H_287_301@ Foundation
class Ball {
// 变量@H_287_301@
@H_502_352@var@H_287_301@ centerX: Float
@H_502_352@var@H_287_301@ centerY: Float
@H_502_352@var@H_287_301@ radius: Float
// 初始化方法@H_287_301@
init(centerX:Float,centerY:Float,radius:Float) {
@H_502_352@self@H_287_301@@H_502_352@.@H_287_301@centerX =@H_287_301@ centerX
@H_502_352@self@H_287_301@@H_502_352@.@H_287_301@centerY =@H_287_301@ centerY
@H_502_352@self@H_287_301@@H_502_352@.@H_287_301@radius =@H_287_301@ radius
}
// 实例方法@H_287_301@
func move(moveX:Float,_ moveY:Float) {
@H_502_352@self@H_287_301@@H_502_352@.@H_287_301@centerX +=@H_287_301@ moveX
@H_502_352@self@H_287_301@@H_502_352@.@H_287_301@centerY +=@H_287_301@ moveY
}
// 类方法@H_287_301@
class func aClassMethod() {
print("I am a class method"@H_287_301@)
}
}
...@H_287_301@
// 创建对象@H_287_301@
@H_502_352@var@H_287_301@ ball1 =@H_287_301@ Ball(centerX: 7.0@H_287_301@,centerY: 5.0@H_287_301@,radius: 6.0@H_287_301@)
// 方法调用@H_287_301@
ball1@H_502_352@.@H_287_301@move(moveX:1.0@H_287_301@,1.0@H_287_301@)
Ball@H_502_352@.@H_287_301@aClassMethod()
流程控制语句
Objective-c
// 条件判断@H_287_301@
if@H_287_301@ (a < b) {
// Do something here@H_287_301@
} else@H_287_301@ {
// Do another thing here@H_287_301@
}
// for循环@H_287_301@
for@H_287_301@ (int@H_287_301@ i = 0@H_287_301@; i < 10@H_287_301@; i++){
// Do something here@H_287_301@
}
// while循环@H_287_301@
while@H_287_301@ (count@H_287_301@ < 10@H_287_301@) {
// Do something here@H_287_301@
}
// do-while循环@H_287_301@
do {
// Do something here@H_287_301@
} while@H_287_301@ (count@H_287_301@ < 10@H_287_301@);
Swift
// 条件判断@H_287_301@
if@H_287_301@ a < b {
// Do something here@H_287_301@
} else@H_287_301@ {
// Do another thing here@H_287_301@
}
// for循环@H_287_301@
for@H_287_301@ int@H_287_301@ i = 0@H_287_301@; i < 10@H_287_301@; i++{
// Do something here@H_287_301@
}
// while循环@H_287_301@
while@H_287_301@ count@H_287_301@ < 10@H_287_301@ {
// Do something here@H_287_301@
}
// repeat-while循环@H_287_301@
repeat {
// Do something here@H_287_301@
} while@H_287_301@ count@H_287_301@ < 10@H_287_301@
基本数据类型
String字符串
Objective-C
@H_502_352@NSString@H_287_301@ * Str = @"string"@H_287_301@;
@H_502_352@NSString@H_287_301@ * formatStr = [@H_502_352@NSString@H_287_301@ stringWithFormat:@"%@and float%f"@H_287_301@,Str,3.1415@H_287_301@"]; @H_287_301@
Swift
// 可变字符串@H_287_301@
var@H_287_301@ Str = "string"@H_287_301@
var@H_287_301@ Str:@H_502_352@String@H_287_301@ = "string"@H_287_301@
var@H_287_301@ Str = @H_502_352@String@H_287_301@("string"@H_287_301@)
// 不可变字符串@H_287_301@
let@H_287_301@ Str = "string"@H_287_301@
let@H_287_301@ Str:@H_502_352@String@H_287_301@ = "string"@H_287_301@
let@H_287_301@ Str = @H_502_352@String@H_287_301@("string"@H_287_301@)
数组Array和MultableArray
Objective-C
// 静态数组@H_287_301@
@H_502_352@NSArray@H_287_301@ *array = [[@H_502_352@NSArray@H_287_301@ alloc] initWithObjects: ball1,ball2,nil@H_287_301@];
array[0@H_287_301@].radius@H_287_301@ = 10@H_287_301@;
// 可变数组@H_287_301@
@H_502_352@NSMutableArray@H_287_301@ *mArray = [[@H_502_352@NSMutableArray@H_287_301@ alloc] initWithCapacity: 2@H_287_301@];
[mArray addObject:ball1];
[mArray addObject:ball2];
Ball *newball = [mArray objectAtIndex:1@H_287_301@];
[mArray removeObjectAtIndex:1@H_287_301@];
Swift
// 静态数组@H_287_301@
let@H_287_301@ myArray: @H_502_352@Array@H_287_301@<Ball> = [ball1,ball2]
let@H_287_301@ myArray: [Ball] = [ball1,ball2]
let@H_287_301@ myArray = [ball1,ball2]
myArray[0@H_287_301@].radius = 10@H_287_301@
// 可变数组@H_287_301@
var@H_287_301@ myArray: [Ball] = []
myArray.append(ball1)
myArray.append(ball2)
var@H_287_301@ newBall = myArray[1@H_287_301@];
myArray.remove(at: 0@H_287_301@)
UIImageView
Objective-C
UIImageView *myImage = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@”tiger.png”]]@H_287_301@;
[self.view addSubview:myImage];
myImage.center = CGPointMake(150@H_287_301@,200@H_287_301@);
myImage.frame = CGRectMake(0@H_287_301@,0@H_287_301@,50@H_287_301@,25@H_287_301@);
Swift
let myImage = @H_502_352@UIImageView@H_287_301@(image: @H_502_352@UIImage@H_287_301@(named: "tiger.png"@H_287_301@))
view.addSubview@H_287_301@(myImage)
myImage2.frame@H_287_301@ = @H_502_352@CGRect@H_287_301@(x:0@H_287_301@,y:0@H_287_301@,width:50@H_287_301@,height:25@H_287_301@)
myImage2.center@H_287_301@ = @H_502_352@CGPoint@H_287_301@(x:150@H_287_301@,y:200@H_287_301@)
… …