Start to sort out iOS job interview questions and answers, and start to sort out ios job interviews

Source: Internet
Author: User

Start to sort out iOS job interview questions and answers, and start to sort out ios job interviews

Can Object-c classes be inherited in multiple ways? Can multiple interfaces be implemented? What is Category? Is the method of rewriting a class well inherited or well classified? Why?

A: The class of Object-c cannot be inherited multiple times. Multiple Interfaces can be implemented to implement multiple inheritance of C ++. Category is a class, generally, classification is good, and the class method is rewritten with Category, which is only valid for this Category and does not affect the relationship between other classes and the original classes.

  

# What is the difference between import and # include? What is the difference between @ class and # import <> and # import?

A: # import is the keyword used to import the Objective-C header file. # include is the keyword used to import the C/C ++ header file. The # import header file is automatically imported only once and will not be imported repeatedly, it is equivalent to # include and # pragma once; @ class tells the compiler about the declaration of a class. Only when executed can we view the implementation file of the class, which can solve the mutual inclusion of header files; # import <> is used to include the system header file, and # import "is used to include the user header file.

 

  

What are the functions of attributes readwrite, readonly, assign, retain, copy, and nonatomic?

 

1. readwrite is a readable and writable feature; when the getter method and setter method need to be generated 2. readonly is a read-only feature that only generates the getter method and does not generate the setter method. You do not want the attribute to be changed outside the class. 3. assign is a value assignment feature. The setter method assigns input parameters to instance variables. Only variables are set. 4. retain indicates that the property is held. The setter method will retain the input parameter first, and then assign a value. The retaincount of the input parameter will be + 1; 5. copy indicates the value assignment feature. The setter method copies the input object. When a new variable is required. 6. nonatomic non-atomic operations determine whether the setter getter generated by the compiler is an atomic operation. atomic indicates multi-thread security. nonatomic

 

  

Write a setter method to complete @ property (nonatomic, retain) NSString * name, and write a setter method to complete @ property (nonatomic, copy) NSString * name

- (void) setName:(NSString*) str {  [str retain];  [name release];  name = str;
}
- (void)setName:(NSString *)str {  id t = [str copy];  [name release];  name = t;}

 

For the statement NSString * obj = [[NSData alloc] init]; what types of objects are used when obj is compiled and run?

It is an NSString type during compilation, and an object of the NSData type during runtime.

 

  

What are the common object-c data types? What is the difference between them and C's basic data types? Such as NSInteger and int

 

The Data Types of object-c include NSString, NSNumber, NSArray, NSMutableArray, and NSData. These are all classes. After the object is created, the basic data type of c language is int, only a certain byte of memory space is used to store numeric values. NSInteger is a basic data type, not a subclass of NSNumber, and of course not a subclass of NSObject. NSInteger is the alias of the basic data type Int or Long (NSInteger defines typedef long NSInteger), the difference is that, NSInteger determines whether it is an int or Long based on whether the system is 32-bit or 64-bit.

 

 

What are the features of the object declared by id?

The object declared by id has the runtime feature, that is, it can point to any type of objcetive-c object;

 

  

What is the thread creation method in Object C? What is the method for executing code in the main thread? If you want to delay code execution, what is the method?

There are three ways to create a thread: Use NSThread to create a thread, use GCD dispatch, use NSOperation as a subclass, and then add it to NSOperationQueue; execute code in the main thread by running mselecw.mainthread, if you want to run code in a delayed manner, you can use javasmselector: onThread: withObject: waitUntilDone:

 

 

What is the difference between shallow replication and deep replication?

Answer: copy the pointer to the object instead of the referenced object. Deep replication: Copies the referenced object itself. That is to say, I have an object A. After copying A copy and getting the_copy object, for the shortest copy, A and A_copy point to the same memory resource, and the copy is just A pointer, there is only one resource for the object itself. If we perform A modification operation on A_copy, we will find that the object referenced by A is also modified, which violates the idea of copying. Deep replication is easy to understand. There are two independent objects in the memory. In the plain words of the old man on the net, it will be: the light replication is like you and your shadow. You are finished, and your shadow is also finished. The deep replication is like you and your clone, and you are finished, your clone is still alive.

  

What do we mean when oc is a dynamic runtime language?

Answer: polymorphism. It mainly delays the determination of data types from compilation to runtime. This problem actually involves two concepts: runtime and polymorphism. Simply put, the runtime determines the class of an object and calls the specified method of the Class Object until it is run. Polymorphism: the ability of different objects to respond to the same message in their own way is called polymorphism. This means that we assume that there is an identical Method for biology (life)-eat; that humans belong to biology, and that pigs also belong to biology. After all of them inherit life, they can implement their own eat, however, we only need to call their respective eat methods. That is, different objects respond to the same message in their own way (response to the eat selector ). Therefore, we can also say that the runtime mechanism is the basis of polymorphism ?~~~

  

What are the differences between notifications and protocols?

Answer: The Protocol has a control link (has-a). No notification is sent. First of all, I didn't quite understand what a control chain is ~). However, in a simple analysis, we can understand the behavior patterns of the notification and proxy. in simple words, the notification can be one-to-many, and one message can be sent to multiple message recipients. According to our understanding, agents do not directly say that they cannot be one-to-many. For example, if we know a celebrity economic representative, a single economic person is often responsible for the affairs of Several stars. It is only for different stars that 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, let alone B's press conference. 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.

  

What is the difference between frame and bounds?

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)

 

NSOperation queue?

 

Answer: The collection class that stores NSOperation. The operation and operation queue can basically be seen as the concept of threads and thread pools in java. It is used to handle ios multi-thread development issues. Some materials on the Internet mentioned that although it is a queue, it is not a concept with a queue. The put operations are not strictly advanced. There is another question here: 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 it first, however, Bfunc is started and executed only after Afunc is fully operated. Therefore, the concept of queue is a little different from that of multi-thread processing. However, you can refer to the Bank's ticketing and calling system. Therefore, for A to get votes in the queue before B, but B is the first to complete the operation, we can also perceive this as A queue. However, I later saw an article about this operation queue topic. One of the articles mentioned that "because the time interval between the two operations is very close, it is not certain who starts the thread in the thread pool ." In an instant, I think this queue name is a little dumb. It's not as good as pool ~ To sum it up, we know that he can be of great use in helping with multi-thread programming.

 

  

What is delayed loading?

Answer: The Lazy mode is initialized only when used. It can also be understood as delayed loading. I think the simplest column is the loading and display of images in tableView. One delayed load prevents excessive memory and asynchronous loading to avoid thread congestion.

 

 

 

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.