第一章 Quiz
1.手动设置xib与delegate相关联
创建single view application,删除 xib,storyboard,viewcontroller.m/.h
以及info.plist中 launchScreen..的条目[删除这个表示在项目设置中没有设置launchScreen可选择]
*对xib你可以在属性检查器中设置方向和大小来模拟,例如一般是正方形你可以改为4吋的大小*
2.MVC
v :visible to user,like button,label.
model:hold data,know nothing about user interface
模拟现实中的事物。模拟,模型
controller: manage your application,handle "and then?" question.
比如按下按钮,就发送信息给controller,他知道要干嘛。
3.storyboard,xib , nib
storyboard管理着多个viewController之间的关系,稍复杂。
xib对应设计功能单一的面板,比如登录界面用一个xib
一个应用可以同时拥有多个xib和storyboard,可以在xib与storyboard中设定管理。比如登录界面xib按下按钮后跳转到main storyboard。
#http://blog.youkuaiyun.com/guchengluoye/article/details/7472771
xib会生成对应的nib? xml结构?,在app启动时被加载,解析
4.outlet,action
outlet就是定义对象,面板中的元件在代码中引用,和actionscript中一样,as中定义实例名称自己关联。
action 设定操作,按钮按下~
直接从视图面板或者dock中control拖动或者右键拖动到代码面板中,代码可以直接生成或者提前写好。
提前写好会有多种选择: 右击file's owner选择对应的action按住 + 拖到元件上等。
connections inspector中可以看到当前所有的链接。
5.viewcontroller启动时会调用 initWithNibName:boundle 可以重写这个,做一些初始化
6.在AppDelegate中自定义rootView,window
#http://blog.youkuaiyun.com/guchengluoye/article/details/7472771
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
UIStoryboard *board = [UIStoryboard storyboardWithName:@"StoryboardIdentifier" bondle:nil];
// name不带后缀的,其中还要制定一个viewController为初始视图
self.window.rootViewController = [board instantiateInitialViewController];
// 如果是关联一个xib,则不用,使用xib中的viewController
// LoginViewController 是创建对应的ViewController子类关联到xib中的视图
// LoginViewController *login = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
// self.window.rootViewController = login;
//
//
return YES;
}
7.关联storyboard中的视图和代码中的类,例如XXViewController关联后,点击对应视图控制器的file's owner就提示是XXViewController而不是默认的ViewController
8.跳转到一个新的storyboard
UIStoryboard *board = [UIStoryboard boardWithName:@"Second" bundle:nil];
[self presentViewController:[board instantiateInitialViewController] animated:YES];
第二章 Objective-c
1.一个对象在使用前必须alloc & init
2.collections,like array: holds the pointer to each object, does not contain objects,when a object add too array,the address of that object in memory is stored inside array.就是一个对象添加到数组中,array[0]只是获取0位置对象的指针
3.通常用fast enum for in 比 普通for 好,除了在for中添加或者删除元素除外
4.NSLog 的%@去获取对象的 description. 可以重写
5.类方法中的self代表调用的类,一般例如初始化中用self而不是具体的类,因为当子类调用这个方法时,self是子类
6.NULL null -> nil add in array
7.xxx_xxx.pch [pre-compile-header?]
第一次编译的时候,把需要的都编译好,所以第一次编译比较长,像Foundation.h中引用了很多的头文件
8.自定义的前缀prefix用三个字母的,防止和apple的冲突,apple都是两个字母的 CA,NS,
9.ARC:automatic reference counting
lose owner:
a.change pointer
NSString *str = @"1";
NSString *str2 = str;
str2 = @"2";
// str is lose owner,如果str只有一个owner,这时候就会被释放掉
b.set pointer to nil
NSString *str = @"1";
str = nil;
c.the owner is destoryed
NSArray *arr = @[@"1",@"2"];
arr = nil;// or ...这时候内部所持有 的都lose owner
d.remove from collection,
[arr removeObject:item];
the owner chainship的顶端被release,底下的一般也是被release,the power of ARC
10.dealloc是释放前调用的函数,你可以重写
1.手动设置xib与delegate相关联
创建single view application,删除 xib,storyboard,viewcontroller.m/.h
以及info.plist中 launchScreen..的条目[删除这个表示在项目设置中没有设置launchScreen可选择]
*对xib你可以在属性检查器中设置方向和大小来模拟,例如一般是正方形你可以改为4吋的大小*
2.MVC
v :visible to user,like button,label.
model:hold data,know nothing about user interface
模拟现实中的事物。模拟,模型
controller: manage your application,handle "and then?" question.
比如按下按钮,就发送信息给controller,他知道要干嘛。
3.storyboard,xib , nib
storyboard管理着多个viewController之间的关系,稍复杂。
xib对应设计功能单一的面板,比如登录界面用一个xib
一个应用可以同时拥有多个xib和storyboard,可以在xib与storyboard中设定管理。比如登录界面xib按下按钮后跳转到main storyboard。
#http://blog.youkuaiyun.com/guchengluoye/article/details/7472771
xib会生成对应的nib? xml结构?,在app启动时被加载,解析
4.outlet,action
outlet就是定义对象,面板中的元件在代码中引用,和actionscript中一样,as中定义实例名称自己关联。
action 设定操作,按钮按下~
直接从视图面板或者dock中control拖动或者右键拖动到代码面板中,代码可以直接生成或者提前写好。
提前写好会有多种选择: 右击file's owner选择对应的action按住 + 拖到元件上等。
connections inspector中可以看到当前所有的链接。
5.viewcontroller启动时会调用 initWithNibName:boundle 可以重写这个,做一些初始化
6.在AppDelegate中自定义rootView,window
#http://blog.youkuaiyun.com/guchengluoye/article/details/7472771
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
UIStoryboard *board = [UIStoryboard storyboardWithName:@"StoryboardIdentifier" bondle:nil];
// name不带后缀的,其中还要制定一个viewController为初始视图
self.window.rootViewController = [board instantiateInitialViewController];
// 如果是关联一个xib,则不用,使用xib中的viewController
// LoginViewController 是创建对应的ViewController子类关联到xib中的视图
// LoginViewController *login = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
// self.window.rootViewController = login;
//
//
return YES;
}
7.关联storyboard中的视图和代码中的类,例如XXViewController关联后,点击对应视图控制器的file's owner就提示是XXViewController而不是默认的ViewController
8.跳转到一个新的storyboard
UIStoryboard *board = [UIStoryboard boardWithName:@"Second" bundle:nil];
[self presentViewController:[board instantiateInitialViewController] animated:YES];
第二章 Objective-c
1.一个对象在使用前必须alloc & init
2.collections,like array: holds the pointer to each object, does not contain objects,when a object add too array,the address of that object in memory is stored inside array.就是一个对象添加到数组中,array[0]只是获取0位置对象的指针
3.通常用fast enum for in 比 普通for 好,除了在for中添加或者删除元素除外
4.NSLog 的%@去获取对象的 description. 可以重写
5.类方法中的self代表调用的类,一般例如初始化中用self而不是具体的类,因为当子类调用这个方法时,self是子类
6.NULL null -> nil add in array
7.xxx_xxx.pch [pre-compile-header?]
第一次编译的时候,把需要的都编译好,所以第一次编译比较长,像Foundation.h中引用了很多的头文件
8.自定义的前缀prefix用三个字母的,防止和apple的冲突,apple都是两个字母的 CA,NS,
9.ARC:automatic reference counting
lose owner:
a.change pointer
NSString *str = @"1";
NSString *str2 = str;
str2 = @"2";
// str is lose owner,如果str只有一个owner,这时候就会被释放掉
b.set pointer to nil
NSString *str = @"1";
str = nil;
c.the owner is destoryed
NSArray *arr = @[@"1",@"2"];
arr = nil;// or ...这时候内部所持有 的都lose owner
d.remove from collection,
[arr removeObject:item];
the owner chainship的顶端被release,底下的一般也是被release,the power of ARC
10.dealloc是释放前调用的函数,你可以重写