iOS Interview questions:
One: Understanding of network theory knowledge
1:internet what protocol to use for physical and IP address translation
ARP (Address Resolution Protocol) addresses resolution Protocol
What kind of network protocol does 2:internet use? The main hierarchy of the agreement?
TCP/IP application layer, Transport layer, network layer, Data link layer
II: OBJECT-C, iphone interview related
1: What is polymorphic
Polymorphism: The ability of different objects to respond to the same message in their own way is called polymorphism.
2. What design patterns are used in your project
MVC pattern, Singleton mode, delegate mode, observer pattern
1) MVC mode:
The MVC pattern considers three types of objects: Model objects, view objects, and controller objects.
Model objects: represents special knowledge and expertise that is responsible for preserving the data of the application
and define the logic for manipulating the data.
View objects: Know how to display model data for an application
, and may allow the user to edit it.
Controller object: is the coordinator between the application's view object and the Model object.
2) Single case mode:
The following classes are all based on a single example:
NSApplication, Nsfontmanager, Nsdocumentcontroller,
Nshelpmanager, Nsnull,nsprocessinfo, Nsscriptexecutioncontext,
Nsuserdefaults
The implementation of the Singleton pattern:
+ (WATCHDOG *) Luckdog
{@synchronized (self) {
if (nil==_instance) {
_instance=[[watchdog Alloc] init]
}
Retrun _instance;
}
}
3) Commissioning Mode:
Delegate to other objects what an object is going to do.
Then the other object is the agent of this object, instead of it to take care of what to do.
Reflected in the program, the first thing is to identify the object of the client is which object,
What the delegate is doing.
The role of the principal agent:
The purpose of the agent is to change or transfer the control chain. Allows a class to be notified at certain times to other
Class without the need to get pointers to those classes. Can reduce the complexity of the frame. Another point,
Proxies can be understood as a similar type of callback listening mechanism in Java.
4) Viewer mode:
An object discovers a change and immediately notifies another object or multiple objects.
The nsnotificationcenter of the iphone is the use of observer mode.
UIApplication *app = [UIApplication sharedapplication];
[[Nsnotificationcenter Defaultcenter] addobserver:self selector: @selector (applicationwillterminate:)
Name:uiapplicationwillterminatenotification Object:app];
3: What are the forms of data storage?
1) Sqlite
2) NSString (WriteToFile), NSData (WriteToFile), Nsarray
(WriteToFile must be a type plist file such as String data), Nsdictionary
(writetofile) These basic types can be accessed directly by the file.
3) object serialization saves an object in a file.
4) Core data is similar to object serialization, but provides visual creation to be serialized
The model of the object. (nsencodeing)
5) Direct IO operation. Nsinputstream, Nsoutputstream
4: How do I see the reference count for an object? Retaincount method
What is 5:kvo and what is KVC? What are the characteristics?
Understanding KVC and KVO (key-value-encoding and key-value-monitoring)
1), Key-value coding mechanism allows you to set and get variable values by variable name.
[MyObject setvalue:valueobject forkey:@ "MyKey"];
[MyObject valueforkey:@ "MyKey"];
KVC can only handle objects, cannot handle int, float and other types;
2) Key-value observing binds a variable to a control, and when the variable changes, the
Notifies the control to change accordingly.
6.ASIDownloadCache Set Download Cache
It caches the response data for the GET request (the cached data must be a successful 200 request):
|
[ASIHTTPRequest Setdefaultcache:[asidownloadcache Sharedcache]; |
When the cache policy is set, all requests are automatically cached.
Also, if you only want a request to use a cache operation, you can use this:
|
ASIHTTPRequest *request = [ASIHTTPRequest Requestwithurl:url];
[Request Setdownloadcache:[asidownloadcache Sharedcache]; |
How the cache is stored
You can set how long the cached data needs to be saved, and ASIHTTPRequest provides two strategies:
A,asicacheforsessiondurationcachestoragepolicy, default policy, session-based cache data storage. The cache will expire the next time you run or [ASIHTTPRequest clearsession].
B,asicachepermanentlycachestoragepolicy, the cache data is permanently stored locally,
Such as:
|
ASIHTTPRequest *request = [ASIHTTPRequest Requestwithurl:url];
[Request Setcachestoragepolicy:asicachepermanentlycachestoragepolicy]; |
iOS Face test summary