Is the first article:
1. Difference between shallow copy and deep copy? What is the difference between shallow replication and deep replication? Bytes
Answer: copy the pointer to the object instead of the referenced object. Deep copy: copy the referenced object itself. Copying means that I have an A object. After copying A copy and getting the_copy object, for the shortest copy, A and A_copy point to the same memory resource, copying is only A pointer, and the resource quota of the object is only one. If we modify A_copy, we find that the object referenced by A is also modified, this actually violates the idea of copying copies. Deep replication is easy to understand. There are two independent objects in the memory. In the plain words of a friend on the Internet, it is like copying you and your shadow. You are finished, and your shadow is complete, you're done, and your clone remains alive.
2. What is advantage of categories? What is difference between implementing a category and inheritance? What is the role of category? What are the differences between inheritance and category implementation?
Answer: you can add a new method to the category without learning or changing the original code. You can only add the method, but cannot delete the modification. If the category conflicts with the method in the original class, the category overwrites the original method because the category has a higher priority. Category has three main roles: category (1) disperses the implementation of classes into multiple different files or different frameworks. Forward (2) creates a forward reference to a private method. Protocol (3) adds informal protocols to objects. You can add, modify, or delete methods and add attributes to the sequence inheritance.
3. Difference between categories and extensions? The differences between category and class extension.
Answer: The difference between category and extensions is that the latter can add attributes. In addition, the method added by the latter must be implemented. Extension extensions can be considered as a private Category.
4. Difference between protocol in objective c and interfaces in java? What is the difference between the Protocol in objective obc and the interface concept in java? Bytes
Answer: The proxy in OBC has two meanings: formal and informal protocol. The former is the same as the Java interface. The methods in the
informal protocol belong to the scope of design pattern Consideration and are not required. However, if there is an implementation, the attributes of the class will be changed. Actually, I have read about formal agreements, types, and informal agreements a long time ago, I also wrote it in my tutorial: "the concept of informal protocols is actually another expression of classes." Here are some methods you may want to implement, you can use them to better complete the work ". This means that these are optional. For example, if we want a better method, we will declare such a category to implement it. Then you can directly use these better methods later. From this perspective, category is a bit like an optional protocol. "Now, protocal has started to unify and standardize the two, because the document says" Informal protocol uses interface modifier ". Now we can see two modifiers in the Protocol: "Must be implemented (@ requied)" and "optional implementation (@ optional )".
5. What are KVO and KVC? Bytes
Answer: kvc: Key-value encoding is an indirect access object attribute that uses a string to identify the attribute, instead of calling an access method, or directly accessing the attribute through instance variables. Program code can be simplified in many cases. The apple documentation provides a good example.
Kvo: the key-value observation mechanism. It provides a method to observe the changes of a certain attribute, greatly simplifying the code. The specific usage of the listener is to monitor the status of button click changes. For example, a Custom button named [cpp] custom [self addObserver: self forKeyPath: @ "highlighted" options: 0 context: nil]; required parameter values # pragma mark KVO encode-(void) observeValueForKeyPath :( NSString *) keyPath ofObject :( id) object change :( NSDictionary *) change context :( void *) context encryption {encryption if ([keyPath isw.tostring: @ "highlighted"]) {encryption [self setNeedsDisplay]; encryption} encoding}
In theory, the system changes the value obtained based on keypath, which is the same as the kvc mechanism. When using the kvc mechanism to find the value: Comment "when calling an object through KVC, for example, [self valueForKey: @" someKey, the program automatically tries to parse the call in several different ways. First, check whether the object has the someKey method. If it is not found, it will continue to find whether the object has the someKey instance variable (iVar). If it has not been found, the program will continue to try to call-(id) valueForUndefinedKey: This method. If this method is still not implemented, the program will throw an NSUndefinedKeyException error. Cocoachina.com Note: When you search for the Key-Value Coding method, you will not only find the someKey method, but also the getsomeKey method. Add a get, or _ someKey and _ getsomeKey. In addition, when searching for instance variables, we will not only look for the someKey variable, but also find whether the _ someKey variable exists .) ValueForUndefinedKey is designed for the intent generator method: when you use the-(id) valueForKey method to request a value from an object, the object can be before an error occurs, there is a final opportunity to respond to this request. There are many benefits to doing so. The following two examples illustrate the benefits of doing so. "Cocoa is used as an example, which makes sense. Because we know that the button has a highlighted instance variable, we can just add a related keypath. Then we can understand the logic of the kvc search.
6. What is purpose of delegates? What is the role of the ingress proxy?
Answer: The proxy aims to change or transmit the control chain. Allows a class to notify other classes at certain times without obtaining pointers to those classes. This reduces the complexity of the framework. In addition, the proxy can be understood as a similar callback listening mechanism in java.
7. What are mutable and immutable types in Objective C? The type can be modified or not in objective obc. Bytes
Answer: you can modify unchangeable collection classes. In my personal understanding, dynamic addition and modification are the same as dynamic addition and modification. Examples include NSArray and NSMutableArray. The former memory control after Initialization is fixed and immutable, and the latter can be added, and new memory space can be dynamically applied.
8. When we call objective c is runtime language what does it mean? What does obc mean by dynamic runtime language? Bytes
Answer: polymorphism. It mainly delays the determination of data types from compilation to runtime. The issue of runtime actually involves two concepts: runtime and polymorphism. In short, the runtime determines the class of an object and calls the specified method of the Class Object until it is run. Response polymorphism: the ability of different objects to respond to the same message in their own way is called polymorphism. This means that the biological class (life) uses the same method-eat; then the human belongs to the creature, and the pig also belongs to the creature. After the life class is inherited, the corresponding eat is realized, however, we only need to call their respective eat methods. The response means that different objects respond to the same message in their own way (response to the eat selector ). The runtime mechanism is the basis of polymorphism ?~~~
9. what is difference between NSNotification and protocol? What are the differences between the notify notification and the protocol? Bytes
Answer: The Protocol has a control link (has-a). No notification is sent. First of all, I didn't quite understand what the control chain was ~). However, after a brief analysis of the notification and proxy behavior patterns, we can have a general understanding of the notify. in simple words, a notification can be one-to-many, and one message can be sent to multiple message recipients. According to our understanding, Agency agents do not directly say that they cannot be one-to-many. For example, we know that a celebrity economic representative is often responsible for the affairs of Several stars. Except for different stars, the agent objects are different and correspond to each other. It is impossible to say that A star needs to handle A press conference tomorrow. After the agent sends A message to process the press conference, b's release was announced. But the notification is different. He only cares about sending the notification, but does not care about how many notifications he is interested in. Therefore, the control chain (has-a) roughly shows the correspondence between a single ownership and a controllable English word.
10. What is push notification? What is push message? Bytes
11. Polymorphism? Polymorphism
Answer: polymorphism. Subclass pointers can be assigned to the parent class. NLP can be used in all object-oriented languages. Therefore, it is best to have a self-conscious understanding of polymorphism, inheritance, and encapsulation, it is not necessary to memorize the information in the book. The most important thing about NLP is to turn it into self-understanding.
12. Singleton? Understanding of Singleton
Answer: I think the question is actually a bit generic. It may be a programming language need or a necessary foundation. NLP can basically write a singleton in a familiar language, as well as scenarios that can be used or framework classes that you have encountered in programming. Further, consider how to ensure security when multiple threads access a single instance.
13. What is responder chain? Let's talk about the response chain
Answer: Event Response chain. Including click events and screen refresh events. Spread from top to bottom in the view stack or from top to bottom. The distribution, transfer, and processing of point events. For details, see the touch event. This is because the question is too abstract. Explain. I seriously suspect that the question is more general as it comes to the end.
14. Difference between frame and bounds? What is the difference between a writable frame and a bounds? Bytes
Answer: frame refers to the position and size of the view in the parent view coordinate system. (The reference point is the father's coordinate system)
bounds indicates the position and size of the view in its own coordinate system. (The reference point is its own coordinate system)
15. Difference between method and selector? What is the difference between the delimiter method and the selector? Bytes
Answer: selector is the name of a method. method is a combination of names and implementations. For more information, see the apple documentation.
16. Is there any garbage collection mechanic in Objective C .? What is the garbage collection mechanism of objective OBC? Bytes
Answer: There is a Garbage collection in OBC2.0, but it is not provided on the iOS platform. Objective-c, which we know in general, is manual for memory management, but there are also automatic release pools. Except for most of the information, it seems that we should not mix it with the arc mechanism. Seek for more ~~
17. NSOperation queue? Bytes
Answer: The collection class that stores NSOperation. Queue operations and operation queues can basically be seen as the concept of threads and thread pools in java. It is used to handle ios multi-thread development issues. According to some documents on the Alibaba Cloud website, although it is a queue, it is not a queue concept. The put operations are not strictly advanced. There is another doubt on the queue side: For a queue, the concept of first-in-first-out is that Afunc is added to the queue, and Bfunc is followed into the queue. Afunc is required to execute first, the concept of queue is a little different from that of multi-thread processing. You can refer to the Bank's ticketing and calling system. Then, for A to get tickets in the queue before B, but B is the first to complete the operation, we can also perceive this as A queue. But later I saw an article about this operation queue topic. One of the articles mentioned "because the time interval between the two operations is very close, the threads in the thread pool, it cannot be started first." Xiaoming instantly thinks this queue name is a bit dumb, and it's not as good as pool ~ Just a bit more comprehensive, we know that he can be more useful in helping with multi-thread programming.
18. What is lazy loading? Bytes
Answer: The Lazy mode is initialized only when used. Latency can also be considered as delayed loading. In my opinion, the simplest column is the loading and display of images in tableView. Upload a delayed load to avoid excessive memory and asynchronous loading to avoid thread congestion.
19. Can we use two tableview controllers on one viewcontroller? Does the observer embed two tableview controllers in a view controller? Bytes
Answer: A View control only provides one View. Theoretically, a tableViewController cannot be used. A View can only be embedded in a tableview. Of course, the question itself is also ambiguous. If we do not consider UIViewController as a qualitative controller, but a macro view controller, we can regard it as a view controller, it can control multiple view controllers, such as TabbarController controllers.
20. Can we use one tableview with two different datasources? How you will achieve this? Can a tableView of tables be associated with two different data sources? What do you do? Bytes
Answer: First of all, we can see from the code that how the data source is associated is actually implemented in the proxy method of the data source Association. Therefore, we do not care about how to associate a data source. Instead, we only need to let me set the relevant data source as needed. Therefore, I think you can set multiple data sources, but the question is, what do you want to do? How do I display the list and partition blocks of different data sources?
21. can Object-c classes be inherited multiple times? Can multiple interfaces be implemented? Is the method of rewriting a class well inherited or well classified? Why?
Objective-c only supports single inheritance. If you want to implement multi-inheritance, You can implement it through classes and protocols. All classes in cocoa are subclasses of NSObject, multi-inheritance is implemented by the protocol delegate proxy.
22. # What is the difference between import and # include? # What is the difference between import and # import?
Answer: @ class is generally used when an instance variable of this class needs to be declared in the header file, in m files, # import is still needed, while # import does not cause cross-compilation compared with # include.
23. What do the @ protected, @ private, @ public, and @ package declarations of class variables have?
24. What are the features of the object declared by id?
Answer: id is a very important type. It is a pointer that can point to any type or can be understood as a pointer to any unknown type.
25. What is MVC? What are the features? Why is it widely used on iPhone?
Answer: The MVC design model considers three objects: model object, view object, and controller object. Model Objects represent special knowledge and expertise that are responsible for retaining application data and defining the logic of operational data. View objects know how to display the model data of an application and may allow users to edit it. The Controller object is the coordinator between the view object and the model object of the application.
26. For the statement NSString * testObject = [[NSData alloc] init]; what types of objects are testObject during compilation and runtime?
27. What is secure release?
28. Why is an error reported when some 4.0 unique objective-c functions run on 3.1, while 4.0 exclusive classes do not report an error when allocating memory on 3.1? What is the allocation result?
29. Why is no error reported when the c function exclusive to 4.0 runs on 3.1 machines (without being called ?) When a class name exclusive to 4.0 runs on 3.1 machines, an error is reported?
30. How to capture an exception? What is the overhead of different CPU Structures? What are the similar methods in C?
31. What are the meanings of attributes retain, copy, and assgin in property? What is the difference? How can I convert it into a get/set method? What are precautions?
32. What is delegation? What attributes are used for the delegated property declaration? Why?
34. Does Cocoa have the concept of virtual base classes? How to implement it in a concise manner?
35. What is the difference between the automatic release pool and GC? Is there GC on the iPhone? What is the difference between [pool release] and [pool drain?
No GC is available on the iPhone. There is no garbage collection mechanism during iPhone development.
In the garbage collection environment, release is an empty operation. Therefore, the nalutoreleasepool provides the drain method. In the reference counting environment, this method is equivalent to calling release, but in the garbage collection environment, it triggers garbage collection (if the memory allocated since the previous garbage collection is greater than the current threshold ). Therefore, in general, you should use drain instead of release to destroy the automatic release pool.
36.
For (int index = 0; index <20; index ++ ){
NSString * tempStr = @ "tempStr ";
NSLog (tempStr );
NSNumber * tempNumber = [NSNumber numberWithInt: 2];
NSLog (tempNumber );
}
What is the problem with this code .? Will it cause memory leakage (multithreading )? Is the pool automatically released when a large loop is made on a device with insufficient memory written in the loop or out of the loop? Why?
37. What are the principles of memory management? According to the default rule, which keywords need to be manually released? How can we effectively avoid Memory leakage when combined with property?
38. Before an object is released, what problems may occur if it is added to icationicationcenter. If it is not removed from icationicationcenter?
39. How to implement a singleton class.
40. What is serialization or Acrchiving, what can be used for, how to combine with copy, and what is the principle ?.
41. What are the differences and connections between threads and processes?
Answer: both processes and threads are the basic units for running programs that the operating system understands. The system uses this basic unit to realize the system's concurrency for applications.
The main difference between processes and threads is that they are different operating system resource management methods. A process has an independent address space. After a process crashes, it will not affect other processes in the protection mode, but the thread is only a different execution path in the process. A thread has its own stack and local variation, but there is no separate address space between threads. If a thread dies, the whole process dies. Therefore, multi-process programs are more robust than multi-threaded programs, however, during process switching, resources are consumed and the efficiency is lower. But for some concurrent operations that require simultaneous and shared variables, you can only use threads, not processes.
42. There are two things to do on the iphone. Is it highly efficient in order in one thread or two threads? Why?
43. What is runloop? An asynchronous function is called in a function in the main thread. How to block the current thread and respond to timer events and touch events of the current thread.
44. How does the ios platform achieve data persistence? Is coredata bound to sqlite? Is coredata a relational database?
In iOS, there are four types of persistent Data: attribute list, object archiving, SQLite3, and Core data. core Data allows you to quickly define app data models in a GUI, at the same time, it is easy to get in your code. Core data provides the basic structure to process common functions, such as saving, restoring, undo, and redo, allowing you to create new tasks in the app. When using core data, you do not need to install additional database systems, because core data uses the built-in sqlite database. Core data puts the model layer of your app into a group of data objects defined in the memory. Core data will track the changes of these objects and make the opposite changes as needed. For example, you can execute the undo command. When the core data changes your app data, the core data archives the data and stores it permanently.
Sqlite library in mac OS x is a lightweight and powerful relational data engine that can be easily embedded into applications. It can be used on multiple platforms. sqlite is a lightweight embedded SQL database programming. Unlike the core data framework, sqlite uses programmatic APIs to directly operate data tables.
Core Data is neither a relational database nor a relational database management system (RDBMS ). Although Core Dta supports SQLite as a storage type, it cannot use any SQLite database. You can create the database yourself when using Core Data. Core Data supports the one-to-many relationship.
45. Describe the lifecycle of an nil object generated from the interface bulider, loaded to the program running space, and finally released.