iOS face Test 4
1. The @protected of the class variable @private @public what the @package declaration means.
@private scope is only within its own class (inaccessible outside, subclasses cannot inherit)
@protected scoped to its own classes and subclasses, the outside world is inaccessible, but subclasses can inherit. (If not modified, the default is @protected)
@public the outside world can access, can also be a quilt class inheritance
@package scope is within a frame
2. Briefly describe the memory management mechanism in OC. The method used for pairing with retain is dealloc or release, why. The method that needs to be paired with Alloc is Dealloc or release, why. The
ReadWrite readonly assign copy nonatomic atomic strong properties.
One,
1) The garbage collection mechanism (GC) system reclaims and reallocate memory that has been freed when allocating memory space, which is not managed in time for memory and is discarded after OS X 10.6
2 manual reference count management mechanism (MRC): The programmer is responsible for opening up the memory space, and managing the reference count of memory space, each reference will be a counter plus one, no longer refer to the counter when the counter is 0 o'clock, recycling this block of memory space, such a mechanism can do to the precise control of memory, Unused memory can be recycled in time, but the programmer's requirements are higher
3) automatic reference counting mechanism: the programmer to open up the memory space, by the compiler to help us in the right enemy to add reference counting operations code, do not need programmers to manually manage memory reference count, Using this mechanism, it is possible to control the allocation and recovery of memory accurately, and to allow programmers to concentrate on programming rather than memory count control.
Arc is a mechanism based on MRC, ARC is not GC
on the iOS platform, because memory is more precious, arc or MRC manages memory
II, retain corresponds to release Retain is the reference count of memory plus one (that is, hold the object once), release is to reduce the reference count of memory (end of the holding of objects)
Three, and alloc corresponding method is dealloc because Alloc represents the opening of memory space, Creates an object that Dealloc represents a reclaimed memory space, releasing the object
ReadWrite readable writable compilers automatically synthesize setter and getter methods
ReadOnly is read-only, the compiler automatically synthesizes the getter method and does not synthesize the setter method
Assign modifies basic data types and struct types without manipulating the reference count of memory
Retain modifies objects in OC and operates on reference counts to prevent objects that are held from being accidentally reclaimed
Copy copies a copy of the object that will be held in the read-write method of the properties that are decorated with the copy, and holds copies of the object rather than the original object. A variable object is a deep copy that opens up new memory space and copies the original object into a new space; The immutable object is a shallow copy, and only the memory address of the object is copied.
Atomic atomic properties ensure that only one thread modifies access to the corresponding instance variable at the same time in a multi-threaded way
Nonatomic non-atomic characteristics do not guarantee thread safety under multithreading
Strong arc, equivalent to the retain in MRC, will manipulate the reference count of memory
The Assign in the weak arc, equivalent to MRC, not only does not manipulate the reference count of memory, but after the object is reclaimed, the pointer is placed as nil to prevent the occurrence of wild pointers.
The Alloc,loadview of 3.ViewController, when the viewdidload,viewwillappear,dealloc,init were called. What these functions should do when customizing the Viewcontroller.
Alloc create objects, allocate memory space
Init initializes the object, which is called when the data is initialized
Loadview load view from nib, usually this step does not need to interfere unless you are not using Xib file to create a view
Viewdidload load completion enables customization of data and dynamic creation of other controls
The Viewwillappear view will appear in front of the screen, and the view will be displayed on the screen immediately.
4. What the thread is. What the process is. What is the difference and connection between the two.
Process: The dynamic execution process of a program on a dataset, the basic unit of allocating resources
Threads: A basic scheduling unit within a process
A thread's partitioning scale is less than a process, and a process contains one or more ground threads.
5 Runloop is what.
Runloop is the infrastructure part of the thread. A Runloop is an event-handling loop that is used to continuously redeploy work and handle input events. The purpose of using Runloop is to have your thread work when there is work and hibernate when there is no.
The management of Runloop is not entirely automatic. You still have to design your thread code to start runloop at the right time and enter the event appropriately. Both cocoa and corefoundation provide runloop objects to facilitate the configuration and management of thread runloop. The program you create does not need to explicitly create runloop, and each thread, including the main thread of the program (main thread), has a corresponding Runloop object. However, the child threads created by themselves need to run runloop manually, and in carbon and cocoa programs, the main thread creates and runs the Runloop itself when the program is started.
Copyright statement: This article by http://www.bestnathan.com/Original, Welcome to reprint share. Please respect the work of the author, reprinted when the statement and the author blog link, thank you