大学IT网 - 最懂大学生的IT学习网站! QQ资料交流群:367606806
当前位置:大学IT网 > IOS技巧 > ios技术面试题

ios技术面试题

关键词:面试题技术ios  阅读(1047) 赞(17)

[摘要]本文是对ios技术面试题的讲解,对学习IOS苹果软件开发有所帮助,与大家分享。

1.Difference between shallow copy and deep copy?

浅复制 只拷贝地址 不拷贝地址指向的对象

深复制 拷贝地址 并且指向拷贝的新对象
2.What is advantage of categories? What is difference between implementing a category and inheritance?

categories: 在不影响或修改原来的类别或模组的情况下去修改原有的功能,增加新的功能
3.Difference between categories and extensions?

categories: 在不影响或修改原来的类别或模组的情况下去修改原有的功能,增加新的功能
4.Difference between protocol in objective c and interfaces in java?

暂时觉得它们是一样的 protocol 可以被继承 interfaces 不可以

在java 中的interfaces 在 objective-c 中就是 protocol

在java 中的 class 在 objective-c 中就是 interface

5.What are KVO and KVC?

一个对象拥有某些属性。比如说,一个 Person 对象有一个 name 和一个 address 属性。以 KVC 说法,Person 对象分别有一个 value 对应他的 name 和 address 的 key。 key 只是一个字符串,它对应的值可以是任意类型的对象。从最基础的层次上看,KVC 有两个方法:一个是设置 key 的值,另一个是获取 key 的值。如下面的例子:

voidchangeName(Person*p,NSString*newName)
{
//usingtheKVCaccessor(getter)method
NSString*originalName=[pvalueForKey:@"name"];
//usingtheKVCaccessor(setter)method.
[psetValue:newNameforKey:@"name"];
NSLog(@"Changed%@'snameto:%@",originalName,newName);
}

现在,如果 Person 有另外一个 key 配偶(spouse),spouse 的 key 值是另一个 Person 对象,用 KVC 可以这样写:

voidlogMarriage(Person*p)
{
//justusingtheaccessoragain,sameasexampleabove
NSString*personsName=[pvalueForKey:@"name"];
//thislineisdifferent,becauseitisusing
//a"keypath"insteadofanormal"key"
NSString*spousesName=[pvalueForKeyPath:@"spouse.name"];
NSLog(@"%@ishappilymarriedto%@",personsName,spousesName);
}

Key-Value Observing (KVO) 建立在 KVC 之上,它能够观察一个对象的 KVC key path 值的变化。举个例子,用代码观察一个 person 对象的 address 变化,以下是实现的三个方法:

  • watchPersonForChangeOfAddress: 实现观察
  • observeValueForKeyPath:ofObject:change:context: 在被观察的 key path 的值变化时调用。
  • dealloc 停止观察static NSString *const KVO_CONTEXT_ADDRESS_CHANGED = @"KVO_CONTEXT_ADDRESS_CHANGED"
@implementationPersonWatcher
-(void)watchPersonForChangeOfAddress:(Person*)p
{
//thisbeginstheobserving
[paddObserver:self
forKeyPath:@"address"
options:0
context:KVO_CONTEXT_ADDRESS_CHANGED];
//keeparecordofallthepeoplebeingobserved,
//becauseweneedtostopobservingthemindealloc
[m_observedPeopleaddObject:p];
}
//wheneveranobservedkeypathchanges,thismethodwillbecalled
-(void)observeValueForKeyPath:(NSString*)keyPath
ofObject:(id)object
change:(NSDictionary*)change
context:(void*)context
{
//usethecontexttomakesurethisisachangeintheaddress,
//becausewemayalsobeobservingotherthings
if(context==KVO_CONTEXT_ADDRESS_CHANGED){
NSString*name=[objectvalueForKey:@"name"];
NSString*address=[objectvalueForKey:@"address"];
NSLog(@"%@hasanewaddress:%@",name,address);
}
}
-(void)dealloc;
{
//muststopobservingeverythingbeforethisobjectis
//deallocated,otherwiseitwillcausecrashes
for(Person*pinm_observedPeople){
[premoveObserver:selfforKeyPath:@"address"];
}
[m_observedPeoplerelease];
m_observedPeople=nil;
[superdealloc];
}
-(id)init;
{
if(self=[superinit]){
m_observedPeople=[NSMutableArraynew];
}
returnself;
}
@end
这就是 KVO 的作用,它通过 key path 观察对象的值,当值发生变化的时候会收到通知。

6.What is purpose of delegates?
7.What are mutable and immutable types in Objective C?
8.When we call objective c is runtime language what does it mean?
9.what is difference between NSNotification and protocol?
10.What is push notification?
11.Polymorphism?
12.Singleton?

单例
13.What is responder chain?
14.Difference between frame and bounds?
15.Difference between method and selector?
16.Is there any garbage collection mechanism in Objective C.?
17.NSOperation queue?
18.What is lazy loading?
19.Can we use two tableview controllers on one viewcontroller?
20.Can we use one tableview with two different datasources? How you will achieve this?
21.What is advantage of using RESTful webservices?
22.When to use NSMutableArray and when to use NSArray?
23.What is the difference between REST and SOAP?
24.Give us example of what are delegate methods and what are data source methods of uitableview.
25.How many autorelease you can create in your application? Is there any limit?
26.If we don’t create any autorelease pool in our application then is there any autorelease pool already provided to us?
27.When you will create an autorelease pool in your application?
28.When retain count increase?
29.Difference between copy and assign in objective c?
30.What are commonly used NSObject class methods?
31.What is convenience constructor?
32.How to design universal application in Xcode?
33.What is keyword atomic in Objective C?
34.What are UIView animations?
35.How can you store data in iPhone applications?
36.What is coredata?
37.What is NSManagedObject model?
38.What is NSManagedobjectContext?
39.What is predicate?
40.What kind of persistence store we can use with coredata?



相关评论