Exam

109 阅读3分钟

1. How much experience do you have using Core Data? Can you give examples?

Code Data: Code Data is a mechanish for devloper to store custom data in disk so that application can access the required data with the corresponding methods. It is basicly a relationship data base which means developers should first create table with key and type of it in Xcode. The performance of it is optimized which means we can fetch data asynchronously without block.

Example: I once created a module for monitering the performance of mobile application, the metrics contians like Net work / ANR / crash datas, the datas for net work is repeatly created with a massive count, so the upload stratage would be aggregate and compress then batch upload with time and some other rule. So I used Core Data to store this kind of data as dish memory.

 

2. What experence do you have of using the keychanin?

Keychain: Keychain is a technique to store data with a secure way, it's a store tech which is similar with Core Data / UserDefaults, but the specific of keychain is that is is a much safer way, so that we userlly store some important data with it.

 

3. What does it mean when we say "strings are collection in Swift"?

String: In Swift String is a Struct type which confirms to a batch of protocols includes Collection, Stirng in Swift is quite different with NSString in Objective-C, String is constructed by Characters and we can iterate String elements with Collection way.

 

4. Can you explain MVVM, and how it might be used on Apple's platforms?

MVVM: There are some kinds of design patterns like MVC / VPER / MVVM, the difference of them is that the code management and data flow. MVVM is a system design partten to gather different part of codes, it's constructed by M(Model) / V(View) / VM(View Model). VM(View Model) plays an citical role in MVVM, it is used to fetch remote data form back end API and business logic is also implemented here. M(Model) is typely for store repsonse data from back end API. V(View) is for display the content of VM. We usually use two way binding in MVVM to enable VM and V responds to corresponding change, so that our application can have a quick respose for data and user interaction.

 

5. How much experience do you have using Core Image? Can you give examples?

Core Image: Core Image is a low level framework, it encapsulates the low level codec detail implementions and response to high level framework like UIKit, which means developers can use the abilities it provides to deal with the image without concerning for the detail.

I once use Core Image to optimize the performance of image library to decrease the OOM when decode images from net work. The approach of it is the thumbnail decode, it will decrease the image buffer used when the application decode from data buffer.

 

6. What is type erasure and when would you use it?

Type Erasure: Generic is a very important technich in Swift, most if system Struct / Protocl / Class / Function / Declaration are using it, it helps devlopers write more compatibility code. In Protocol defination we can make type as geneic and then needs to use type erasure tech to make the type precision in the certain Struct or Class to clearify the type.

 

7. Can you explain KVO and how it's used on Apple's platforms?

KVO: KVO means Key Value Observe, with this tech a instance can be notified by the property of class it observed when is change. It is like a method we want to know when a certain thing happens but we can do other things as well, KVO is the method for this requirement, it means we just needs to tell KVO when the property of other class is changed please let me know and KVO will call back to us with the value of old and new, so we can do the business logic in call back. BTW KVO can make call back to multiple instances.

 

8. How would you explain ARC to a new iOS developer?

ARC: Automatic Reference Counting is the method of memory management while GC in Android in opposite. This tech works based on Runtime which means it is automaticlly managed by runtime and developers don't need to manage it. When a instance has a strong reference then the reference count will add one automaticly. iOS manage the Reference Counting Automaticlly and will release the instace as soon as the Reference Counting is zero. Typically there are strong / weak / unowned reference relationships and only strong one will make Reference Counting increase. It is also needs to notice that circular reference in iOS, which means there are strong Reference within coupons of instance and it will make our application memory leak, it harms application performance and also can make application crash for OOM.

 

9.  How would you explain key paths to a new Swift developer?

key Paths: key Paths is a way to locate the property, we can access the property using string seperated with ".", it is a kind of approach to access the propery easily at runtime. But we should be noticed that this kind of tech will not be checked by lint in build phase so it may take side effect at runtime.

 

10.    What are conditional conformances?

Conditional Conformances: It is a important tech for extension that confims to a protocol, and with this tech we can make the functions in the extension work in some certain condition, we generally write it with where keyword behinds the class name and condition will be after that and the functions in the extension will works if the condion is mathed.