1. #import and #include ,@classWhat's the difference? # What's the difference between import<> and #import?
1> #import and #include can contain the contents of a file completely,#import prevents the same file from being included multiple times
The 2> @class simply declares a class name and does not contain a complete declaration of the class ; @class can also solve the problem of loop containment
3> #import <> used to include the file that comes with the system,#import "" to include the custom file
2. Properties readwrite,readonly,assign,retain, copy, What is the role of nonatomic, in that case?
1> ReadWrite: Simultaneous generation of both the get method and the set method declaration and implementation
2> readonly: Generate declarations and implementations of Get methods only
3> Assign: The implementation of the Set method is a direct assignment for the basic data type
4> retainset release retain oc
5> copy: The implementation of the Set method is the release old value,copy new value, for NSString,block and other types
6> nonatomic: Non-atomic, The implementation of the set method is not locked (higher than atomic performance)
3. For statement nsstring*obj = [[NSData alloc] init]; , what is the type of compile-time and run-time obj respectively?
1> compile-time is nsstring type
2> Runtime is nsdata type
4. What are the common object-c data types, and What is the difference between the basic data types of C?
1> commonly used OC types:nsstring,nsarray,nsdictionary , NSData , NSNumber wait
2> OC objects need to manage memory manually,C 's basic data type does not need to manage memory
5 the. ID declaration variables What are the characteristics?
the variable that the ID declares can point to any OC Object
6. Objective-c How to manage the memory , say your opinion and solution ?
1> Each object has a reference counter, the counter for each new object is 1, and when the object's counter is reduced to 0 , it is destroyed
2> by retain can let the object counter +1,release can let the object counter -1
3> can also manage memory through autorelease pool
If ARCis used, the compiler automatically generates code to manage memory
7. What are the several principles of memory management? Follow the default rules . whichsomeMethoddoes the generated object need to be released manually? How to effectively avoid memory leaks when combined with property?
1> as long as the alloc,copy, and new methods are called to produce a new object, all must be called at the last Release or autorelease
2> whenever retainis called, it must be called at the last release or autorelease
3> @property If you use copy or Retian, you need to do a release for the attributes that you no longer use . Operation
4> if ARCis used, another discussion
8. What are the differences between threads and processes?
1> an application corresponds to a process, a process helper occupies a piece of storage space
2> to perform a task in a process, you must turn on the thread, and a thread represents a task
3> allows multiple threads to be opened in one process, that is, performing multiple tasks at the same time
9. What is the difference between heap and stack?
The memory of the 1> heap space is dynamically allocated, typically storing objects, and requires manual memory release
The memory of the 2> stack space is automatically allocated by the system, usually storing local variables, and does not need to manage the memory manually
10. Why a lot of built-in classes, such as TableView 's delegate properties are assign not Retain?
1> TableView Agent is generally the controller that it belongs to, the controller will do a retain operation of its internal view
2> assumes that TableView also do a retain operation on the agent (Controller) , then there is a cyclic retain problem
11. When defining attributes, what is the use of copy,assign,retain?
1> copy:nsstring,Block and other types
2> Assign: basic data Type
3> retain:OC Object Type
viewcontroller loadview,viewdidload,viewdidunload when are they called, in the custom Viewcointroller what should be done in these several functions?
1> Loadview
When using the controller's view for the first time, the loadview method is called to create the view
in general, customize the view here
2> Viewdidload
Called when the controller's view is created, that is, after loadview
It is common to add child controls, initialize data
3> Viewdidunload
Called when the controller's view is destroyed because of a memory warning
usually here to recycle the interface-related resources (the interface will be destroyed, and interface-related resources must not be)
This article is from the "Bright Future" blog, please be sure to keep this source http://brilliantfuture.blog.51cto.com/8958010/1420170