iOS

1、Xcode

  • Xcode is an Integrated Development Environment (IDE) containing a suite of software development tools developed by Apple for developing software for OS X and iOS.
  • In Xcode environment, describe how to connect an UILabel on the storyboard with the view controller of the application.

2、 iOS technology layers(要打印)

  • Cocoa Touch: User interface components、Handling all Touch and Event-driven、Systemwide interface
  • Media: Playing audio and video、Animation、 2D and 3D Graphics
  • Core Services : Lower-level features、Files services、Networking services、Location services
  • Core OS: Access memory、 Hardware access、Low-level networking

3、Objective-C HelloWorld(要打印)

  • 什么是 storeBoard:A storyboard is a plan for the appearance and flow of an application.Container to include all other UI Components. You still lay out views and connect them to view controllers.(storeBoard 类似 Android 里的布局文件)

  • View Controller:Controls various UI components on the screen view, i.e., when, where, and how the UI components are shown(类似 Android 的 Activity,主要用于获取和操作控件,以及给控件绑定click和touch事件)

  • UIApplication:UIApplication对象是应用程序的象征,一个UIApplication对象就代表一个应用程序。

  • Application Delegate:Listener such as Application Launched and Application Terminated(类似 Android 中 Activity 的生命周期)

image.png
  • IBOutlet:An IBOutlet helps connect the button control to the code to make the button accessible programmatically.
    类似Android里的 Button btn = findViewById(R.id.btn);

  • IBAction:A method that's called as an action from Interface Builder.
    类似Android里给某个控件绑定监听器,如click事件的监听器 btn.setOnClickListener(new View.OnClickListener() {})

  • 下面只是 ViewController 的代码,控件引用的获取和事件监听器的添加都是直接在界面上拖拽,给你演示过的。最好看一下HelloWorld的过程:ppt [iOS1] 56页开始

  • ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UILabel *lable1;

- (IBAction)clickBtn:(id)sender;

@end
  • ViewController.m
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize lable1;

// Do any additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)clickBtn:(id)sender {
    lable1.text = @"Hello hyx";
}

@end
  • 13年试卷有一道题:In Xcode environment, describe how to connect an UILabel on the storyboard with the view controller of the application?答案在这:
    (1)Open “ViewController.h”
    (2)Press the Control key and drag the label to it at the same time (under “@interface” and before “@end”)
    (3)You will be asked to enter a name for your Label. (input label1)
    (4)The following statement will be added into “ViewController.h”:
    @property (weak, nonatomic) IBOutlet UILabel *label1;

  • 今年还可能这么问:如何绑定UIButton的click事件监听器,答案:
    (1)press the Control key and drag the Button to “ViewController.h” at the same time (under the “label1” statement because “label1” will react based on the button’s action)
    (2)Choose “Action” for “Connection”
    (3)Choose“TouchUpInside”for“Event”
    (4)You will be asked to enter a name. (btn1)
    (5)The following statement will be added into “ViewController.h” for you:
    (IBAction) btn1:(id)sender;

  • 创建新的 View Controller 的步骤(Each view should have its own view controller)
    (1)Go to “File” -> “New File”
    (2)Select “Cocoa Touch Class”
    (3)Choose “UIViewController” for the “Subclass of” field
    (4)Type a meaningful name
    (5)Select the view in the storyboard, in the Inspector window, set the custom class to the newly created class


4、Swift HelloWorld(要打印)

  • 和 Objective-C HelloWorld 的例子类似,不详细说,直接上代码

  • ViewController.swift

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var label1: UILabel!
    
    @IBAction func btnClick(sender: AnyObject) {
        label1.text = "Hello hyx!"
    }
    
    // Do any additional setup after loading the view, typically from a nib.
    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

5、语法:Objective-C 、Swift 的区别

  • Objective-C is the superset of C,所以也可以使用 C 语言开发 iOS

5.1 变量声明

  • Objective-C / C++
    int width = 5;
    Primitive 类型:int、float、double、BOOL、char
    Reference 变量一般需要写成指针(加星号*):People *hyx = ......;

  • Swift

Swift 可以不指定变量类型,var 就代表无类型,下面的四种定义方式都可以:

var width = 5;
var width: Int = 5
var width = Int(5)
var width = Int(5)

Primitive 类型:Int、Float、Double、Character、String、BOOL
Constants:Constants are a way of telling Swift that a particular value should not and will not change,(eg:let width = 5,let A: Int = 10)Swift’s compiler can optimize memory used for constants to make code perform better.

5.2 for 循环和 while 循环

  • Objective-C / C++
for (int i = 0; i < 100; i++) {
    // Do something
}

int count = 0 ;
while (count < 10) {
    // Do something
    ++count ;
}

int count = 0 ;
do {
    // Do something
    ++count ;
} while (count < 10);
  • Swift(语法比较奇怪,注意看下)
// 代表 i 的值从1 循环到100 
for i in 1 … 100 {
    // Do Something
}

while count < 10 {
    // Do Something
    count++
}

// 和  do while 一个意思
var count = 0
repeat {
    // Do Something
    ++count
} while count < 10

5.3 类和方法(要打印,C++的不打印)

  • Objective-C
.h 文件包含了 class 中属性和方法的定义:The header file that contains the declaration of a
class,Also contains declaration of member variables and methods of the class.

.m 文件包含了 class 中方法的实现:Contains the definition (implementation) of the
methods of the corresponding class, manipulation of data and objects.

People.h

// 引入系统的基础库
#import <Foundation/Foundation.h>
#import “Constants.h”

// 一定要继承 NSObject
@interface People: NSObject {
    NSString* name;
    int age;
}

// The “@property” lines are needed to get and 
// set the variables of an object of People class from other objects
//(加了@property才允许在外部访问这些变量)
@property NSString* name;
@property int age;

// 定义构造函数,People*是返回值
- (People*) initialize: (NSString*) name: (int) age ;
// 定义run函数,void是返回值,表示没有返回值
- (void) run: (float) distance;

@end

People.m

#import “People.h”

// 表示接下来是People类两个方法的实现
@implementation People

// This line directly corresponds to the two @property statements in the .h file.
// If you want to use the property to store a value and if you don’t use = here
// @synthesize uses the name of the property for storage
@synthesize name, age;

- (People*) initialize: (NSString*) name: (int) age {
    [self init];
    self.name= name;
    self.age = age ;
    return self;
}

- (void) run: (float) distance {
    // run run ......
}

// 这个必须写
- (void) dealloc {
    [super dealloc];
}

@end

Use Class People

// 只要是创建新对象,都需要写alloc,给新对象分配内存
People* hyx= [[People alloc] initialize: @"Huang YingXue": 22];
[hyx run: 666.66];

People* mxm= [[People alloc] initialize: @"Mo Xumin": 24];
[mxm run: 1000.66];
  • C++

跟 Objective-C 一样,.h是类和方法的声明,.cc是类和方法的实现,下面看用法(Student继承了People):

Student.h

// 假设Student 继承 People,C++里在class声明处的冒号表示继承
class Student : People {

private:
  string name;
  int age;

public:
  Student(string name, int age);
  void run(float distance);
};

Student.cc(或Student.cpp)

include "Student.h"

Student::Student(string name, int age) {
  this->name = name;
  this->age = age;
}

void Student::run(float distance) {
    // run run
}

Use Class Student

Student *hyx = new Student("Huang YingXue",22);
hyx->run(666.666);
  • Swift
import Foundation

class People {

    var name: NSString
    var age: Int

    // 构造方法
    init(name: NSString, age: Int) {
        self.name = name
        self.age = age
    }

    // run 方法
    func run(distance:Float) {
        // run run ......
    }
}

Use People

var hyx = People(name:"Huang YingXue", age:22)
var mxm = People(name:"Mo Xumin", age:24)
hyx.run(distance:666.666)

5.4 类方法和实例方法(Class method and Instance method)

  • Objective-C

这个和 Java 的 static 类似,Java 的 static 方法是类方法,直接用类名调用方法People.run(),没加 static 的方法是实例方法,需要通过对象来调用hyx.run()

Objective-C里没有static关键字,通过+和-来区分,函数开头用-表示是实例方法,调用方式是[hyx run:6.6],函数开头用+表示是类方法,调用方式是[People eat: "吃屎"]

  • Swift
// 类方法,加class前缀
class func aClassMethod() {
    print("I am a class method") 
}

// 实例方法
func anInstanceMethod() {
    print("I am a instance method")
}

// 调用
People.aClassMethod();
hyx.anInstanceMethod();

5.5 Swift Function 的特殊定义形式

  • 定义1
// 定义
func someFunction(a: Int, b: Int) {
 
}

// 调用
someFunction(a: 1, b: 2)
  • 定义2:带有返回值的方法
// 表示返回值是一个 String 字符串
func greet(person: String, from hometown: String) -> String  {
    return "Hello \(person)! Glad you could visit from \(hometown)."
}

// 调用
String result = greet(person: "Bill", from: "Cupertino");
  • 定义3:参数前加 __ 下划线,调用时不用写参数名
// 定义
func someFunction(__ a: Int, __ b: Int) {
 
}

// 调用
someFunction(1, 2)
  • 定义4:有的参数有默认值
// 定义,b : Int 后加了个 = 2,表示如果调用的时候不写第二个参数,默认就当你传了2进去
func someFunction(a: Int, b: Int = 2) {
 
}

// 调用,这样写其实等于写了 someFunction(a:1, b:2)
someFunction(a:1)
  • 定义5:可变参数的方法定义
// Double 后加了 ... 省略号,表示参数可以传任意多个 double 数,最后把所有传入的 double 树遍历一次,加起来,然后返回
func add(_ numbers: Double...) -> Double { 
    var total: Double = 0
    for number in numbers { 
        total += number
    }
    return total; 
}

// 调用
add(1,2,3,4,5,6);

5.7 String

  • Objective-C
// There are two types of strings: NSString and NSMutableString:
// 1) A string of type NSString cannot be modified once it is created
// 2) A string of type NSMutableString can be modified

// 普通字符串
NSString * lionStr = @“Lion";

// 格式化字符串
int age = 22;
float gpa = 3.6;
NSString *name = "YingXue"
NSString * str = [NSString stringWithFormat:@ "%@ age is %d, %@ gpa is %f ", name, age, name, gpa];
// 将会得到字符串: "YingXue age is 22, YingXue gpa is 3.6"

// 查找子字符串
NSString *Str = @“hello world”;
NSRange *range = [Str rangeOfString:@“world”];
// 得到结果:range.location is 6, range.length is 5

OC里的NSLog要看下,就是打印字符串在日志,如下:

// 和上面的 stringWithFormat 规则一样,看懂就好了
NSLog(@ "%@ age is %d, %@ gpa is %f ", name, age, name, gpa);
  • Swift
// Swift 的 String 有三种定义方式
var S = “hi”
var S: String = “hi”
var S = String(“hi”)

// 查找子字符串与 Objective-C 类似
var S = “hello world”
var range = S.rangeOfString(“world”)

5.8 数组 Array(要打印)

  • Objective-C
// 1) 普通数组,类似 Java
int myArray[100]; 
myArray[0] = 555; 
myArray[1] = 666;

// 2) 对象数组(nil表示空元素,也可当做数组结束符)
NSArray *array = [[NSArray alloc] initWithObjects: @”red”, @”green”, @”blue”, nil];
for (int i = 0; i < [array count]; i ++) { 
    // 打印
    NSLog(@”array[%d] = %@”, i, [array objectAtIndex: I]);
}

// 输出结果如下:
array[0] = red
array[1] = white 
array[2] = blue

// 3) Mutables数组(动态数组),类似 Java 的 ArrayList,10表示数组的初始长度是10
NSMutableArray *peoples = [[NSMutableArray alloc] initWithCapacity:10];
People* hyx= [[People alloc] initialize: @"Huang YingXue": 22];
People* mxm= [[People alloc] initialize: @"Mo Xumin": 24];
// 把两个 People 对象塞到数组里
[peoples addObject:hyx];
[peoples addObject:mxm];

// 使用完了要释放数组元素的内存
[[peoples objectAtIndex:0] release];
[[peoples objectAtIndex:1] release];
// 然后把数组元素从数组里删除
[peoples removeObjectAtIndex:0];
[peoples removeObjectAtIndex:1];
// 最后释放数组自身的内存
[peoples release];
  • Swift
// 1)普通数组的三种定义方式
var myArray: Array<Int> = [555, 666]
var myArray: [Int] = [555, 666]
var myArray = [555, 666]
var somevalue = myArray[0] // 得到值555

// 2)Mutables 数组承载对象
var hyx = People(name:"Huang YingXue", age:22)
var mxm = People(name:"Mo Xumin", age:24)
// 第一种写法
var peoples:[People]=[hyx, mxm]
// 第二种写法
var peoples:[People]=[]
peoples.append(hyx)
peoples.append(mxm)
// 然后遍历peoples数组里的每个元素,打印name
for i in 0..< peoples.count {
    print(peoples[i].name)
}

5.10 @property (weak, nonatomic)(要打印)

  • A “property” is just the combination of a getter method and a setter method in a class. If you want to use the property to store a value and if you don’t use = here,@synthesize uses the name of the property for storage.
  • nonatomic means its getter and setter are not thread-safe. This is no problem if this is UI code because all UI code happens on the same thread.
  • weak and strong:
    • An object will be deallocated as soon as
      there are no strong pointers to it.
    • Even if weak pointers point to it, once the
      last strong pointer is gone, the object will
      be deallocated, and all remaining weak
      pointers will be zeroed out.
    • 中文解释:weak是软引用、strong是强引用,如果某个对象没有strong引用,会马上被系统回收掉属于它的内存(即使有weak引用存在),答题的时候,写上面两句英文就好了

5.9 C++/Objective-C/Swift 代码互译(要打印)

-- C/C++ Objective-C Swift
Framework inclusion #include <stdio.h> #import <Foundation/Foundation.h> Import Foundation
Header File inclusion #include "People.h" #import "People.h" 不写
Constant Definition #define COUNT 9 #define COUNT 9 let COUNT = 9
Header File/ Implementation File C: .h/.c C++: .h/.cc .h/.m .swift
Member Variables Declaration int age; int age; var age: Int
Class Method Declaration static void helloWorld(){} + (void) helloWorld{} class func helloWorld() {}
Instance Method Declaration int getAge(){} - (int) getAge{} func getAge() {}
Dynamic Memory Allocation and Pointer variable Assignment People * hyx=malloc(sizeof(People)); People * hyx = new People(); People * hyx = [People alloc]; var hyx = People()
Class Method Invoke People::run(); [People run]; People.run()
Instance Method Invoke hyx->run(); [hyx run]; hyx.run();
String Format "Hello" @"Hello" "Hello"
Release Object Memory delete hyx [hyx release] 不需要手动释放内存

5.11 Optionals in Swift(要打印)

  • 首先,在 Objective-C 和 Swift 中都有类似 nil 的概念,nil 表示空值,一个变量在被成功赋值前,都是 nil 的.(OC 中的 nil 和 Swift 的 nil 其实不太一样,但是这个深层区别你不用 care,他们表达的意思都是说某个变量没有值)

  • 严格的说,在 Swift 中没有 nil 的概念,Swift 用 Optionals 来表达 nil,Optionals 的作用如下:(Swift is a type safe language,optional which handle the absence of a value)

(1)When a property can be there or not there
(2)When a method can return a value or nothing, like searching for a match in an array
(3)When a method can return either a result or get an error and return nothing
(4)Delegate properties (which don't always have to be set)
(5)For a large resource that might have to be released to reclaim memory

  • 看下 ppt iOS2 80-83页的例子就懂了,不用想这么复杂,Optionals 只是为了保证 Swift 的安全性,不会影响代码的逻辑,如果实在记不住,忽略掉就好

5.12 Pointer(指针)

只说这三个关键字(OC的内存回收算法是基于引用计数,也就是说,有一个引用指向某个对象的时候,这个对象的引用就会被加1)
alloc:在创建对象的时候调用,表示为这个对象分配内存
retain:只要有一个引用指向这个对象,引用数就加1
release:表示要释放对这个对象的引用,引用数-1
当引用数为0时,对象的内存会被系统回收

// 我这里为了快,用C++写OC的例子,原理一样的
// 这时候 alloc 会被调用
People hyx1 = new People();
// 这时候hyx2的引用也指向了hyx1原来指向的对象,所以有两个对象同时指向了黄映雪对象
// 这时候retain会被调用,引用数变成了2
People hyx2 = hyx1;
// 释放两个引用,引用数变为0,之前new的对象内存就会被回收
delete hyx1;
delete hyx2;

6、Navigation Control

  • Navigation 就是顶部导航栏,如下面两个截图,可以点击 Next 跳转到下个页面,也可以点击 Back 返回。


    image.png
  • 这里没有代码,全部是通过XCode拖拽完成设置,只要理解意思,把下面的步骤缩印即可,可以看看IOS1 的 PPT 95-105页的步骤

6.1 创建 Navigation 的步骤(要打印)

(1)Click and choose:Editor -> Embed In -> Navigation Controller
(2)Dragging “Bar Button Item” to the title bar and be named “next”
(3)Create more new “pages” by dragging “View Controller”
(4)Connect the “next ”button with the new “page” (“control” + drag),choose the action segue “Show”
(5)The “back” buttons will be created automatically


7、Tab Control

  • 看下面图我圈起来的地方,你就知道什么是 TabView 了
image.png
  • 这个也没有代码,XCode 直接就创建出来 Tab Control 的项目了,看 iOS1 的 ppt 114-119 页就知道了,知道这是啥就行

8、UIImage & UIImageView

  • UIImage:用来存放图像的数据(比如每个像素的颜色值)
  • UIImageView:用来显示图片的控件,类似 Android 的 ImageView,还支持动态图、图片 animation(gif)

8.1 Adding Images 步骤(缩印就好了)

(1)Drag the images into the “Resources” folder
(2)在 ViewController.m 中的 viewDidLoad 方法中添加如下代码:

// 创建 UIImageView 对象,加载名字为puppy.jpeg的图片
UIImageView *myImage = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"puppy.jpeg"]];
// 把 UIImageView 添加到界面中
[self.view addSubview:myImage];

8.2 Positioning Images

  • 设置图片中心点的坐标
// (x,y)= (150,200)
myImage.center = CGPointMake(150, 200);

8.3 Scaling Images

  • 设置图片的大小
// (x,y) = (0,0),width=50,height=25
myImage.frame = CGRectMake(0, 0, 50, 25);
  • 注意,frame 会覆盖 center 的坐标
// 1)设置后,中心坐标是(0,0),width为50,height为25
myImage.center = CGPointMake(150, 200); 
myImage.frame = CGRectMake(0, 0, 50, 25); 

2)设置后,中心坐标是(150,200),width为50,height为25
myImage.frame = CGRectMake(0, 0, 50, 25); 
myImage.center = CGPointMake(150, 200);

9、Touching Events

9.1 Single Touch

  • when you touch onto the screen
 (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    // 获得触摸位置的坐标
    CGPoint *location = [touch locationInView:touch.view];
    // 每次触摸都修改图片的坐标
    image.center = location;
}
  • after you touch onto and start moving across the screen
(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    // 再次调用touchesBegan,实现了拖动图片的效果
    [self touchesBegan:touches withEvent:event];
}
  • when your finger leaves the screen
(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

}

9.2 Multiple Touches

  • when you touch onto the screen
 (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    // 获取所有手指的触摸点
    NSSet *touches = [event allTouches];
    for (UITouch *myTouch in touches) {
        // 获取每个触摸点的坐标
        CGPoint location = [myTouch locationInView:self];
    }
}

10、Putting Your iOS Apps onto a Real Device(要打印)

  • iOS 应用发布审核比较严格,要求代码签名(code-signed)、开发者证书(Certificate)验证。

10.1 Each app that is compiled to run on a device must be “code-signed”

Unlike Android , Apple has strict security regarding who can distribute apps.
(1)Your app is built and signed by you or a trusted team member.
(2)Apps signed by you or your team run only on designated development
devices.
(3)Apps run only on the test devices you specify.
(4)Your app isn’t using app services you didn’t add to your app.
(5)Only you can upload builds of your app to iTunes Connect.
(6)If you choose to distribute outside of the store (Mac only), the app can’t be modified and distributed by someone else.

  • 所以你需要这样做:
    (1) Obtain Developer Certificate to “sign” the app
    (2)Obtain Provisioning Profile which identifies your certificate, device,
    and app on that device

10.2 证书分类(Certificate Type)(要打印)

image.png

11、传感器(Motion sensor)

  • 作用:Tracking Orientation and Motion,Reports linear acceleration changes along the primary axes in three-dimensional space

  • 应用场景:微信摇一摇、Apple 健康(记录行走步数等)


12、Xcode vs. Cocoa

  • Xcode is the tool, specifically Integrated Development Environment (IDE), that you use to write your Objective-C or Swift
    program and turn it into an actual application.
  • Cocoa is the library of code you use to write applications. Cocoa usually refers to user interface code, such as windows and menu bars, but it also refers to code that lets you work with various data types, such as arrays.

13、APPStore Apps review policy(可以打印)

  1. Safety:the app doesn’t contain upsetting or offensive content, won’t damage their device, and isn’t likely to cause physical harm from its use.

  2. Performance:App Completeness、Beta Testing、Accurate Metadata、Hardware Compatibility

  3. Business:There are many ways to monetize your app on the App Store. If your business model isn’t obvious, make sure to explain in its metadata and App Review notes. If we can’t understand how your app works or your in-app purchases aren’t immediately obvious, it will delay your review and may trigger a rejection.

  4. Design:不允许抄袭、APP应该有实用价值、和APPStore上已有的APP重复功能的APP也有可能会审核不通过

  5. Legal:Apps must comply with all legal requirements in any location where you make them available (if you’re not sure, check with a lawyer).
    Such as:Privacy、Intellectual Property、国家或地区对于Gaming, Gambling, and Lotteries的法律法规

  • 14年最后一道题答案:
    (1)Apps that use non-public APIs will be rejected?(因为私有api不安全)
    (2)Multitasking Apps may only use background services for their intended purposes:VoIP, audio playback, location, task completion, local notifications, etc?(把耗时很长的操作放到background services执行,保证APP体验流程)
    (3)Apps cannot transmit data about a user without obtaining the user's prior permission and providing the user with access to information about how and where the data will be used?(安全)
    (4)Apps that link to external mechanisms for purchases or subscriptions to be used in the App, such as a "buy" button that goes to a web site to purchase a digital book, will be rejected?(iap 苹果关于收费的规定,app内的支付虚拟产品 不允许走第三方支付渠道,如微信打赏)

14、访问网络

// 获取用户名和密码,看题目到时候从哪获取就是从哪获取
NSString* username = nameInput.text;
NSString* pass = passInput.text;

// 判断用户名密码如果为空,就停止程序(isEqualToString就是判断两个字符串是不是相等,就可以判断账号密码是不是为"")
if([nameInput.text isEqualToString: @""]||[passInput.text isEqualToString:@""]){
    ...
    return;
}

// 把用户名密码信息写入网络请求,设置一些网络配置信息
NSString *post=[[NSString alloc]initWithFormat:@"uname=%@&pwd=%@",username,pass];
NSData *postData=[post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength=[NSString stringWithFormat:@"%d",[postData length]];
// 需要访问的URL
NSURL *url=[NSURL URLWithString:@"http://www.cs.hku.hk/~c7506/login.php"];
// 访问网络返回的结果存放在theRequest里
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
 [theRequest setHTTPBody:postData];
// 连接网络
NSURLConnection*theConnection = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];

// 下面是几个连接网络的方法,抄下来就好了
 -(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response {
     [webData setLength:0];
}
-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data {
     [webData appendData:data];
}
 -(void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error {
     [connection release];
     [webData release];
}

 // 访问网路结束后,会调用这个函数
 -(void)connectionDidFinishLoading:(NSURLConnection*)connection {
    NSString* loginStatus=[[NSString alloc]initWithBytes:[webData mutableBytes]length:[webData length]encoding:NSUTF8StringEncoding];
    NSLog(loginStatus);
    [connection release];
    [webData release];
}

15、其他

  • APP Store 的利润分享模式:revenue of 70% for developer and 30% for Apple

  • swift优点:Safe(In terms of type checking)、Powerful(Highly optimized LLVM compile)、Modern(Adopted many features from other languages to make the language more concise yet expressive)

  • iOS 的后台任务:等我找答案,ppt没有

  • 断点续传:等我找答案,ppt没有

  • A10 处理器有助于延长电池寿命:ppt没有

  • Hey siri的技术:ppt没有

  • 为什么 XCode 只能从 APPStore 下载?
    (1)在外面下载的XCode可能被恶意修改,可能有病毒
    (2)只有正式版的XCode才能生成开发者证书,才可以发布 iOS APP 到 APP Store 上

  • Console programming 和 GUI programming 的区别((要打印)):Console programming only need yo write the code、 compile it and run and debug it;But GUI programming also need to design the interface (i.e., screen layout of the application) with the help of an interface builder、work on code and interface alternately.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,098评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,213评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,960评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,519评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,512评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,533评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,914评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,574评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,804评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,563评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,644评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,350评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,933评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,908评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,146评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,847评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,361评论 2 342

推荐阅读更多精彩内容