国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ios技術面試題

2019-11-14 20:04:06
字體:
來源:轉載
供稿:網友

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?

 

轉自 http://magicalboy.com/kvc_and_kvo/

 

一個對象擁有某些屬性。比如說,一個 Person 對象有一個 name 和一個 address 屬性。以 KVC 說法,Person 對象分別有一個 value 對應他的 name 和 address 的 key。 key 只是一個字符串,它對應的值可以是任意類型的對象。從最基礎的層次上看,KVC 有兩個方法:一個是設置 key 的值,另一個是獲取 key 的值。如下面的例子: 

 

 

Java代碼  收藏代碼
  1. void changeName(Person *p, NSString *newName)  
  2. {  
  3.    
  4.     // using the KVC accessor (getter) method  
  5.     NSString *originalName = [p valueForKey:@"name"];  
  6.    
  7.     // using the KVC  accessor (setter) method.  
  8.     [p setValue:newName forKey:@"name"];  
  9.    
  10.     NSLog(@"Changed %@'s name to: %@", originalName, newName);  
  11.    
  12. }  

  現在,如果 Person 有另外一個 key 配偶(spouse),spouse 的 key 值是另一個 Person 對象,用 KVC 可以這樣寫:

 

Java代碼  收藏代碼
  1. void logMarriage(Person *p)  
  2. {  
  3.    
  4.     // just using the accessor again, same as example above  
  5.     NSString *personsName = [p valueForKey:@"name"];  
  6.    
  7.     // this line is different, because it is using  
  8.     // a "key path" instead of a normal "key"  
  9.     NSString *spousesName = [p valueForKeyPath:@"spouse.name"];  
  10.    
  11.     NSLog(@"%@ is happily married to %@", personsName, spousesName);  
  12.    
  13. }  

 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"
    Java代碼  收藏代碼
    1.    
    2. @implementation PersonWatcher  
    3.    
    4. -(void) watchPersonForChangeOfAddress:(Person *)p  
    5. {  
    6.    
    7.     // this begins the observing  
    8.     [p addObserver:self  
    9.         forKeyPath:@"address"  
    10.            options:0  
    11.            context:KVO_CONTEXT_ADDRESS_CHANGED];  
    12.    
    13.     // keep a record of all the people being observed,  
    14.     // because we need to stop observing them in dealloc  
    15.     [m_observedPeople addObject:p];  
    16. }  
    17.    
    18. // whenever an observed key path changes, this method will be called  
    19. - (void)observeValueForKeyPath:(NSString *)keyPath  
    20.                       ofObject:(id)object  
    21.                         change:(NSDictionary *)change  
    22.                        context:(void *)context  
    23.    
    24. {  
    25.     // use the context to make sure this is a change in the address,  
    26.     // because we may also be observing other things  
    27.     if(context == KVO_CONTEXT_ADDRESS_CHANGED) {  
    28.         NSString *name = [object valueForKey:@"name"];  
    29.         NSString *address = [object valueForKey:@"address"];  
    30.         NSLog(@"%@ has a new address: %@", name, address);  
    31.     }  
    32. }  
    33.    
    34. -(void) dealloc;  
    35. {  
    36.    
    37.     // must stop observing everything before this object is  
    38.     // deallocated, otherwise it will cause crashes  
    39.     for(Person *p in m_observedPeople){  
    40.         [p removeObserver:self forKeyPath:@"address"];  
    41.     }  
    42.    
    43.     [m_observedPeople release];  
    44.     m_observedPeople = nil;  
    45.    
    46.     [super dealloc];  
    47.    
    48. }  
    49.    
    50. -(id) init;  
    51. {  
    52.     if(self = [super init]){  
    53.         m_observedPeople = [NSMutableArray new];  
    54.     }  
    55.    
    56.     return self;  
    57. }  
    58.    
    59. @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?


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 潞西市| 邵阳市| 张北县| 邛崃市| 巴塘县| 鄂伦春自治旗| 天津市| 阜城县| 溧水县| 泊头市| 开原市| 宁德市| 海林市| 翼城县| 江门市| 资阳市| 民和| 南召县| 佛学| 淮滨县| 华蓥市| 浠水县| 柳江县| 漾濞| 汉中市| 神木县| 沾益县| 福海县| 文昌市| 扬中市| 阜新| 红原县| 普洱| 商水县| 罗平县| 元朗区| 隆林| 浦北县| 布拖县| 海城市| 新晃|