1 Objective-c provides several ways of memory management? Please give a detailed example of your understanding of OBJECTIVE-C's memory management strategy.
A: Two, ARC and manual management (retain, release, or Autorelease). When the 1.new,alloc and copy methods create an object, the object's retention counter value is 1. When you no longer use the object, you are responsible for sending a release or Autorelease message to the object. This will then be destroyed at the end of the service life. 2. When an object is obtained by any other method, it is assumed that the object has a retention counter value of 1 and has been set to be automatically freed, and no action is required to ensure that the object is cleaned up. 3. If you keep an object, you need to (eventually) release or release the object automatically. You must keep the Retain method and the release method equal in number of uses.
2 When the event occurs in iOS when to use delegate, when with Nsnotificationcenter?, what is the difference between the two, please write a delegate interface.
A: (1) When the use of this choice: Delegate: The sender told the event will occur, Delega agreed after the sender response to the event, is a one-to-one relationship.
(2) Notification: The sender of the message informs the receiver that the event has occurred or is about to occur, and that the recipient cannot affect the sender's behavior, which is a one-to-many relationship.
delegate more efficient.
(3) Delegate Example:
@protocol: MyDelegate
@interface MyClass
{
ID delegate;
}
@protocol MyClass
-(void) dosomething;
@end
What are the main attribute parameters in the 3 @property, and what are the conditions for using them separately?
Answer: ReadWrite: Produce Setter\getter method.
Readonly: Only generates simple getter, no setter.
Assign: Default type, setter method is assigned directly without retain operation.
Retain:setter method to release the old value of the parameter, and then Retain the new value.
The Copy:setter method does a copy operation, as with retain.
Nonatomic: Prohibit multi-threading, variable protection, improve performance.
4 What are the two common uses of macros in pre-processing commands, write a ' standard ' macro min, which enters two parameters and returns the smaller one.
Answer: (1) without parameters: #define Macro name string.
With parameters: #define Macro name (parameter table) string.
#define MIN (a) < (b) ( A):(B)).
What is the sandbox mechanism for iOS 5? What kinds of directory structures are commonly found in sandboxes, and what kind of data should each directory structure be used to store? How do you avoid the data storage guidelines for your app data store that violate iOS?
A: By default, each sandbox contains 3 folders: Documents, Library, and TMP. Because of the sandbox mechanism applied, the application can read and write files only in several directories.
Documents: Apple recommends that file data that is created in the program or browsed in the program be stored in this directory, which is included in itunes Backup and restore.
Library: The default settings or other status information for the stored program.
Library/caches: Store cached files, itunes does not back up this directory, files in this directory will not be deleted in the app exit.
TMP: Provides a place to create temporary files on the fly.
6 Talk about the icon size, naming specification, and device size of your iphone-specific programs and ipad-specific programs.
Answer: (1) iPhone:icon.png 57x57.
[Email protected] 114x114.
Ipad:icon-72.png 72x72.
(2) IPhone4 and 4S are 3.5 inches iPhone5 for 4 inches.
The ipad is 9.7 inches.
7 Talk about your understanding of core data.
A: With core Data, you don't have to write cumbersome code like SQLite, reduce effort, or avoid using C's syntax to lower the technical threshold for iOS development.
8 What is the use of block in iOS, define a block variable named Maxblock, and enter two integer parameters to return the larger one.
A: (1) The Objective-c feature, where a block is defined in a function, the block can access the internal variables of the function.
Int (^maxblock) (int a, int b) = ^ (int a, int b) {if (a > B) return A; else return b;};
9 Frame,bounds, the difference between center. How to get the screen size in your iphone.
(1) Frame: refers to the size and position of the view in the coordinate system of the parent view.
Bound: Refers to the size of the view in the coordinate system of the attempt itself (the origin of the position is the original point).
Center: Refers to the point at which the view is centered in the parent view coordinate system.
(2) CGRect rx = [UIScreen mainscreen].bounds;
10 What is a gcd, an example of when to use. function Dispatch_sync, Dispatch_async, dispatch_once,dispatch_apply, what are the functions of each?
A: (1) GCD is actually a multi-threading, it can improve the execution efficiency of the code and multi-Core utilization (2) Dispatch_sync: Run on the main thread.
Dispatch_async: Runs asynchronously.
Dispatch_once: The code is only run once and is thread-safe to create a singleton.
Dispatch_apply: Runs the passed-in block.
11 illustrates the life cycle of the Viewcontroller.
Answer:init->loadview->viewdidload->viewwillappear->viewdidappear->viewwilldisappear-> Viewdiddisappear->viewdidunload->dealloc.
12 Talk about Viewcontroller page jump mode
A: When jumping from one controller to another, there are generally the following 2 types:
1, the use of Uinavigationcontroller, call Pushviewcontroller, to jump, the use of the pressure stack and the way out of the stack controller management. Call the Popviewcontrolleranimated method to return.
Pickimageviewcontroller *pickimageviewcontroller = [[Pickimageviewcontroller alloc] init];
[Self.navigationcontroller Pushviewcontroller:pickimageviewcontroller animated:true];
[Pickimageviewcontroller release];
2, using the Uiviewcontroller own presentmodalviewcontroller, to jump; Call the Dismissmodalviewcontrolleranimated method to return.
Pickimageviewcontroller *pickimageviewcontroller = [[Pickimageviewcontroller alloc] init];
[Self Presentmodalviewcontroller:pickimageviewcontroller animated:yes];
Return
[Self dismissmodalviewcontrolleranimated:yes];
iOS face question 2