IOS面试题4

来源:互联网 发布:阿里云.com域名价格 编辑:程序博客网 时间:2024/04/30 06:41

1.When to use NSMutableArray and when to use NSArray? 

什么时候使用NSMutableArray,什么时候使用NSArray?

答案:当数组在程序运行时,需要不断变化的,使用NSMutableArray,当数组在初始化后,便不再改变的,使用NSArray。需要指出的是,使用NSArray只表明的是该数组在运行时不发生改变,即不能往NSAarry的数组里新增和删除元素,但不表明其数组內的元素的内容不能发生改变。NSArray是线程安全的,NSMutableArray不是线程安全的,多线程使用到NSMutableArray需要注意。

2.Give us example of what are delegate methods and what are data source methods of uitableview.

给出委托方法的实例,并且说出UITableVIew的Data Source方法

答案:CocoaTouch框架中用到了大量委托,其中UITableViewDelegate就是委托机制的典型应用,是一个典型的使用委托来实现适配器模式,其中UITableViewDelegate协议是目标,tableview是适配器,实现UITableViewDelegate协议,并将自身设置为talbeview的delegate的对象,是被适配器,一般情况下该对象是UITableViewController。

UITableVIew的Data Source方法有- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;


3.How many autorelease you can create in your application? Is there any limit?

在应用中可以创建多少autorelease对象,是否有限制?

答案:无

4.If we don’t create any autorelease pool in our application then is there any autorelease pool already provided to us?

如果我们不创建内存池,是否有内存池提供给我们?

答案:界面线程维护着自己的内存池,用户自己创建的数据线程,则需要创建该线程的内存池

5.When you will create an autorelease pool in your application?

什么时候需要在程序中创建内存池?

答案:用户自己创建的数据线程,则需要创建该线程的内存池

6.When retain count increase?

什么时候内存计数会增加?

答案:见iOS面试题(一)

7.What are commonly used NSObject class methods?

类NSObject的那些方法经常被使用?

答案:NSObject是Objetive-C的基类,其由NSObject类及一系列协议构成。

其中类方法alloc、class、 description 对象方法init、dealloc、– performSelector:withObject:afterDelay:等经常被使用 

8.What is convenience constructor?

什么是简便构造方法?

答案:简便构造方法一般由CocoaTouch框架提供,如NSNumber的 + numberWithBool:  + numberWithChar:  + numberWithDouble:  + numberWithFloat:  + numberWithInt:

Foundation下大部分类均有简便构造方法,我们可以通过简便构造方法,获得系统给我们创建好的对象,并且不需要手动释放。

9.How to design universal application in Xcode?

如何使用Xcode设计通用应用?

答案:使用MVC模式设计应用,其中Model层完成脱离界面,即在Model层,其是可运行在任何设备上,在controller层,根据iPhone与iPad(独有UISplitViewController)的不同特点选择不同的viewController对象。在View层,可根据现实要求,来设计,其中以xib文件设计时,其设置其为universal。

10.What is keyword atomic in Objective C?

在Objetive-C什么时原子关键字

答案:atomic,nonatomic见iOS面试题(一)

11.What are UIView animations?

UIView的动画效果有那些?

答案:有很多,如  UIViewAnimationOptionCurveEaseInOut     UIViewAnimationOptionCurveEaseIn     UIViewAnimationOptionCurveEaseOut    UIViewAnimationOptionTransitionFlipFromLeft   UIViewAnimationOptionTransitionFlipFromRight     UIViewAnimationOptionTransitionCurlUpUIViewAnimationOptionTransitionCurlDown 

如何使用可见该博文

12.How can you store data in iPhone applications?

在iPhone应用中如何保存数据?

答案:有以下几种保存机制:

1.通过web服务,保存在服务器上

2.通过NSCoder固化机制,将对象保存在文件中

3.通过SQlite或CoreData保存在文件数据库中

13.What is coredata?

什么是coredata?

答案:coredata是苹果提供一套数据保存框架,其基于SQlite

14.What is NSManagedObject model?

什么是NSManagedObject模型?

答案:NSManagedObject是NSObject的子类 ,也是coredata的重要组成部分,它是一个通用的类,实现了core data 模型层所需的基本功能,用户可通过子类化NSManagedObject,建立自己的数据模型。

15.What is NSManagedobjectContext?

什么是NSManagedobjectContext?

答案:NSManagedobjectContext对象负责应用和数据库之间的交互。

16.What is predicate?

什么是谓词?

答案:谓词是通过NSPredicate,是通过给定的逻辑条件作为约束条件,完成对数据的筛选。

    predicate = [NSPredicate predicateWithFormat:@"customerID == %d",n];

    a = [customers filteredArrayUsingPredicate:predicate];


17.What kind of persistence store we can use with coredata?

使用coredata有哪几种持久化存储机制?

答案:无

0 0
原创粉丝点击