1. Briefly describe the memory management mechanism in OC
The memory management mechanism in OC is an automatic reference count, which is divided into two ways: MRC and ARC,MRC are manually managed memory, ARC is the system automatically manages the memory; his principles are who open who to release, there will be destruction
2. What are the effects of readwrite,readonly,assign,retain,copy,nonatomic, Atomic, strong, and weak properties?
Readwrite: Read-write feature, readable writable (default property)
Readonly: Read only, getter not setter
Assign: Modifies some basic data types (int char float double) and ID type
Retain: Modifying some count types
Copy: Generic modifier String type
Nonatomic: Non-atomicity, no need to consider thread security, high execution efficiency
Atomic: The advantage of atomicity is that threads are safe, but execution is inefficient
3. About iOS Multithreading issues
There are three ways of multithreading: Nsthread, Nsoperationqueue, GCD
Nsthread: is a relatively lightweight thread that needs to manage its own thread inland life cycle, thread synchronization
Nsoperationqueue: is an operations queue that manages the execution of Operation objects and automatically opens up the appropriate number of threads to perform tasks as needed
GCD: Is a more commonly used thread, can be divided into three kinds: main thread queue, parallel queue and serial queue
4. Some suggestions on improving the performance of UITableView
A Use lazy loading, when to use, when to initialize and open up memory space, reduce memory consumption
b Customize the height of the cell
C Cell reuse mechanism to add a reuse identifier to the cell
5. What are the differences between thread synchronization and Asynchrony?
Synchronization: A thread waits for the last thread to execute before executing the current thread
Asynchronous: It is possible to execute multiple threads concurrently
6. What is the difference between heap and stack?
Stack area: is automatically allocated by the compiler to release, mainly store some functions of the parameter value, the value of local variables, the order is advanced after the
Heap area: is assigned by the programmer to release, the order is FIFO
Global Zone (static zone): Initialized global variables and static variables are placed in an area, uninitialized in the adjacent area, after the end of the program, there is a system to release
Literal constant area: a constant string, the system released after the end of the program
Program code Area: a binary file that holds the body of the function
Can the 7.iOS class implement multiple inheritance?
Multiple inheritance is not possible and can be implemented by delegate and protocol and categories like multiple inheritance
What are the different ways of 8.iOS local data storage? How does iOS implement the storage of complex objects?
File write, Object archive, Sqlite,coredata,nsuserdefault
File write: Permanently saved on disk, only support nsstring,nsdata,nsarray,nsdictionary
Object archiving: is to encrypt the object data to ensure the security of the data, the custom object archive must follow the Ndcoding protocol
SQLite: The database needs to be aware that Fmdb is not a database, but a database management framework
Dynamic nature of the 9.iOS
Dynamic type: Generally used is the ID type, that is, when the program runs, you can determine the specific type
Dynamic binding: When the program is running, call the appropriate method as needed
Dynamic loading: When the program is running, the corresponding module is loaded according to the requirements
10. Deep copy and shallow copy understanding?
A deep copy, a copy of the content, a shallow copy of the pointer, the difference is to see whether the address of the object has changed, if there is a change is a deep copy
11. What is safe release
Set the pointer to nil after release in Object Dealloc
12. How to achieve a singleton.
+ (Zmysingleton *) sharedinstance{
static Losingleton *sharedinstance = nil;
Static dispatch_once_t Oncetoken; Lock
Dispatch_once (& Oncetoken, ^ {
Call at most once
Sharedinstance = [[Zmysingleton alloc] init];
});
return sharedinstance;
}
What is 13.Runloop?
A runloop is a loop of event processing, often used in threads, when a thread is opened there will be a runloop, the main thread of the Runloop default is open, manually open the sub-thread Runloop default is not open, if need to open to call api[[ Nsrunloop Currentrunloop] Run opens. The most common runloop to open is to invoke a timer inside a child thread Nstimer
14. Write a standard macro min, this macro enter two parameters and return the smaller one?
#define KMIN (x x) > (Y))? (Y):(X)
15. Briefly describe the life cycle when the application presses the home key into the background and the life cycle from the background back to the foreground?
Go to the background life cycle: (will enter the background, has entered the background)
-(void) Applicationwillresignactive: (uiapplication*) Application;
-(void) Applicationdidenterbackground: (uiapplication*) Application;
Back to the foreground life cycle walk: (will enter the front desk, has entered the front desk)
-(void) Applicationwillenterforeground: (uiapplication*) Application;
-(void) Applicationdidbecomactive: (uiapplication*) Application;
When was the 16.ViewController Loadview, Viewdidload,viewwillappear,viewdidunload,dealloc, and Init respectively called? What should be done in these functions when customizing Viewcontroller?
Loadview: Called when the view is loaded
Viewdidload: Called after attempting to load is complete
Viewwillappear: Call when attempting to appear
Discard > After viewdidunload:<ios6 the method is called when the system is out of memory, releasing the attempt and corresponding controller that is not currently displayed in the window
17. Describe the startup order of the application.
1. Program Entry main function Create UIApplication instance and UIApplication Proxy instance
2, rewrite the startup method in the UIApplication proxy instance, set the first Viewcontroller
3, add the control in the first Viewcontroller, implement the corresponding program interface.
18. Why are the properties of the write agent assign rather than retain? Please illustrate.
the proxy attribute uses assign to prevent circular references, such as Self.delegate = Self
19.UIImage There are several ways to initialize a picture? Describe the pros and cons of each.
A. Read from the resource, that is, the picture is taken from the cache, first of all to determine whether the cache has this picture, not to add the picture to the cache in use, some words can be used directly, but the disadvantage is that the efficiency of the implementation is relatively low
B. From the phone to read locally, you need to obtain a picture of the storage path, the implementation of high efficiency, but it is more cumbersome to use
20. What's wrong with this code:
@implementation person
-(void) Setage: (int) NewAge {
Self.age = NewAge;
}
@end
Dead loop
21. Write a bubble sort with OC
Nsmutablearray*array = [Nsmutablearray arraywitharray:@[@ "3", @ "1", @ "10", @ "5", @ "2", @ "7", @ "12", @ "4", @ "8"];
for (int i =0; i < Array.count;i + +) {
for (INTJ =0; j < array.count-1-I; j + +) {
if ([[Arrayobjectatindex:j]integervalue] > [[arrayobjectatindex:j +1]integervalue]) {
[Arrayexchangeobjectatindex:jwithobjectatindex:j +1];
}
}
}
NSLog (@ "%@", array);
22. Describe your understanding of UIView, UIWindow and Calayer
UIView inherits from Uiresponder, Uiresponder inherits from Nsobject,uiview can respond to user events, and Calayer does not do this; UIView focuses on content management, Calayer focuses on content rendering, Animate the Content
(Examples of life: Pictures on the wall)
23.frame and Bounds differences:
frame: The position and size of the view in the parent view coordinate system. (The reference point is the coordinate system of the parent view)
Bounds: The position and size of the view in the local coordinate system. (Reference point Yes, local coordinate system)
The key to the local coordinate system is to know its origin (0,0)
24. Write a complete agent
25. Analyze the differences between JSON and XML? How does the underlying JSON, XML parsing approach work?
XML is a label language that is suitable for web transport
JSON is a lightweight data interchange format that uses afnetworking for JSON data parsing, with high compatibility and readability, completely independent of the language text format
When was the didreceivememorywarning of 26.ViewController called? What is the default action?
Didreceivememorywarning executes this method when a memory warning occurs, and the default action is to release the reusable objects that are temporarily unused.
27. Three main features of object-oriented, and make a brief introduction
Encapsulation: Encapsulates an objective object into an abstract class, hides its internal implementation, and provides only interfaces
Inheritance: You can use all the features of an existing class
Polymorphic: Different objects use their own methods to respond to the same message
28. Simply say lazy loading
Lazy loading is when to use, when to create, to open up memory, so as to reduce the memory footprint
29. What are the categories (categories) and extensions (extensions) described separately? And the difference between the two? What is the difference between inheritance and class in implementation? Why can category only add methods to objects, but cannot add member variables?
Class: Is to extend the method for a class without knowing the source code
Extension: Declaring private methods and variables for a class
The purpose of a class is to add a method to a known class
What is the difference between #import, #include和 @class
#import与 # include is the method in the view class, #import是确保头文件只能引入一次, does not cause cross-compilation
@class declare a class, tell the compiler that it has this class, but the definition in the class doesn't know anything.
@class is more efficient than #import, and the main difference between the two is that it solves the problem of invoking deadlocks.
31. Talk about your understanding of MVC? Why use MVC? How is MVC implemented in cocoa? Are you familiar with other OC design patterns or other design patterns?
MVC is a design pattern, Model-view-controller,model is a data model, view is the real content, controller is equivalent to the model and the bridge between view, It can show the data in the model on the view
Using MVC can improve the reusability of code, facilitate the maintenance and update of the code later
Common design Patterns are: delegate, single case, target-action design mode
32. String substitution method:
[String stringbyreplacingoccurrencesofstring:@ "PNG" withstring: @ ""]
33. For statement nsstring* testobject = [[NSData alloc] init]; What types of objects are testobject at compile time and run time?
compile time is nsstring type, when run is NSData type
34. What is the Sandbox (sandbox)? The sandbox contains the files that describe the usage scenarios for each file. How do I get the path to these files? How do I get the path to a file in an application package?
Sandbox: Refers to the area where the program's system files are stored, containing three files: Documents,library and TMP
Documents: Files for browsing
Library: Store cached Files (Exit app will not be deleted)
TMP: Store temporary files (exit program will be deleted)
What are the roles of Iskindofclass and Ismemberofclass?
The effect of both is to detect whether an object is a member of a class, but Iskindofclass can also detect whether an object derives from a member of a class of that class
36.TCP: Is the Transmission Control layer protocol, is a connection-oriented, reliable, byte-stream-based transport layer; (following the three-time handshake principle: When sending a message to the server, it will return a message, telling the other that the data has been received, and then returning a message telling the other party that it has received the data, Prove that the line is safe)
The role of 37.static keywords
Static global variables
Variables of the static tag are stored in the global variable area with the same life cycle as the program
is only visible in the declared class, and the previous value is used again after the declared class ends
Advantages:
Save memory. Static variables are stored only once, can be used by all objects, values can be updated, and objects can be accessed directly to the updated value
42. The application layer has 8 layers:
Telnet protocol, FTP file Transfer Protocol, Hypertext Transfer Protocol (HTTP), SMTP Simple Mail Transfer Protocol, time protocol, DNS, SNMP Simple Network Management Protocol, TFTP simple File Transfer Protocol
How many layers does the 43.iOS system framework consist of?
iOS system framework is divided into 4 layers: Touch layer (Cocoa touch), Media layer (medium), Core service layer (core Services), Kernel OS layer
Touch layer: is a touch interaction on an iOS device, and the General program framework is on the touch layer
Media layer: Use media files in your app to implement audio, video, and animation effects
Core Service tiers: access to some of the services in iOS
Core operating layer: the implementation of some memory management, file management and power management systems such as Operation
Summary of common face questions in iOS