1. Briefly describe the memory management mechanism in OC. The method used for pairing with retain is dealloc or release, why? How do I use the Dealloc or release method to pair with Alloc? Readwrite,readonly,assign,retain,copy,nonatomic, Atomic, strong, weak properties?
The reference counting mechanism for memory management.
retain the corresponding is Release , the memory is released with Release .
Alloc the corresponding is Dealloc , the memory is destroyed with Dealloc .
ReadWrite This tag indicates that the property is read-write, which is also the default property.
ReadOnly This tag indicates that the property can only be read, that is, it cannot be set and can be obtained.
Assign does not add the reference count 1 , which is directly assigned to the value.
retain The reference count is added 1 .
Copy Create an index count of 1 An object that uses a copy of the passed-in value when the value is assigned.
nonatomic : Non-atomic access, multi-threaded concurrent access improves performance.
Atomic: Atomic access.
Strong: Open ARC is used, which is equivalent to retain .
Copy: applicable to the acceptance of nscopy object type of the protocol
Assign: suitable for general types
Retain: For general object types
2. @protected of class variables, @private, @public, @package, what does the declaration mean?
@protected methods in this class and in all subclasses can directly access such variables.
@private methods in this class are accessible, and subclasses are not accessible.
@public can be accessed by all classes
@package for use within this package, cross-packs may not
3. What is a thread? What is the process? What are the differences and connections?
threads, sometimes called lightweight processes, are the basic operating units of the system that are scheduled and CPU independent.
A process is the basic unit in the operating system that can work in parallel.
There is at least one process in an application, and at least one thread in a process
4. Talk about your understanding of multithreading development? There are several ways to implement multithreading in iOS
There are multiple threads in a process, each of which has its own individual task advantages efficiency fast disadvantage unsafe, consume resources
There are three kinds: the first, using @synchronized (self) The second, using the GCD third, using the Nsoperationqueue
5. What are the differences between thread synchronization and Asynchrony? How does multi-threaded synchronization work in iOS?
A process initiates multiple unrelated threads that are related to each other asynchronously.
Synchronous refers to multi-threaded simultaneous operation of a data at this time need to add protection to the data this protection is the synchronization of threads.
Use the serial queue in the GCD to explain multi-threaded synchronization, that is, the queue of tasks are serial, they are dependent on the adjacent task, if task 1 is not completed, then Task 2 will not start, this is the synchronization
6. Suppose there is a string Aabcad, write a program, remove the string is not adjacent to the repeating string, that the above string processing after the output is: AABCD
nsmutablestring *str = [[nsmutablestring alloc]initwithformat:@ "Aabcad"];for (int i = 0; i < str.length - 1; i++) { unsigned char a = [str characterAtIndex:i]; for ( int j = i + 1; j < str.length; j++) { unsigned char b = [str characterAtIndex:j]; if (a == b) { if (j == i + 1) { }else{ [str Deletecharactersinrange:nsmakerange (j, 1)]; } } }} nslog (@ "%@", str);
7. What are the methods for obtaining a unique label for a single device?
1.UDID
2.UUID
3.MAC ADDRESS
4.OPEN UDID
5. Advertising Identifiers
6.vindor identifiers
iOS7 after the use of Keychain (Keychain)
8.caniOS classes inherit more? If not, can it be implemented in other ways? Describe the implementation process.
No use catogory,extension to achieve
Category also called classification or class , The main work is to There is no class-Add method for the source code . The method added by category becomes the part of the original class. The ability to extend a class from the reach.
Extension ( extended ) The main work of the management class is the " Private " Method
9. What is the difference between heap and stack?
Heap requires the user to manually free the memory, while the stack is the compiler automatically frees the memory
the difference between stacks :
( 1 Management method : without our manual control for heaps release work controlled by programmer easy to generate memory leak &NBSP;
( 2 Application size : in the computer system,
( 3 Fragmentation problem : for heaps frequent new/delete &NBSP; for stacks There will be no problem with because the stack is an advanced post-out queue they're so. One by one corresponds to &NBSP; &NBSP;
( 4 allocation method : There is no statically allocated heap. Stack has 2 : Static allocation and dynamic allocation. Static assignment is the compiler finishes &NBSP; alloca But the dynamic allocation of stacks and heaps is different His dynamic assignment is by the compiler &NBSP;
( 5 allocation efficiency : The computer provides support for the stack at the bottom : Assigning the address of a dedicated register stack pressure stack out stack &NBSP; There are special instructions to execute This determines the efficiency of the stack is relatively high. The heap is c/c++
What are the different ways of 10.ios local data storage?
1. Nskeyedarchiver (return file)
2. Nsuserdefaults
3. Write Writing method
4. SQLite3
5.coredata
Dynamic type (strongly typed) ID for iOS
You can determine the type of an object while your code is running. Using an ID type (also known as a strong type) can be replaced with any data type at run time. Dynamic typing makes the program more flexible, but it reduces the uniformity of the data. Our usual static types, such as NSString, have their own advantages, and using a static type compiler can fully analyze the performance of your code and be more predictable.
iOS Dynamic binding
You can determine what method to invoke when the code is running. Dynamic types and dynamic bindings make it possible to select the recipient and which method to invoke to decide at run time.
Dynamic loading
Applications can load executable code and resources as needed, rather than load all resources at startup.
This article is from the "http://fanyuecheng.blog.51cto.com/9529438/1686105 blog" blog, please make sure to keep this source.
iOS face question One