In July, there were relatively few job-hopping on iOS. Those who could apply for jobs during this period were either forced or confident in their skills. For July, I specially summarized the second iOS common daco interview questions (middle);
IOS interview questions are divided into three parts: top, middle and bottom, which are convenient for you to watch.
Please answer by yourself first!
Don’t say much; This article is directly on the topic: the public number [iOS advanced treasure book “iOS bottom level test questions (part)”]
6: How many ways to introspect in iOS? What’s the difference between a class method and an objc_getClass method?
- 1: What is introspection?
In computer science, introspection is the ability of a computer program to check the type of an Object at Run time, often referred to as run-time type checking. Introspection should not be confused with reflection. Further than introspectiveness, reflection is the ability of a computer program to access, detect, and modify its own state or behavior at Run time.
- 2: How many ways to introspect in iOS?
IsMemberOfClass // Whether the object is an object of a certain type
IsAncestorOfObject // Is an object of a type or subclass of a type isSubclassOfClass // Is an object of a class subclass of another type isAncestorOfObject // Is an object of a class a parent of another type RespondsToSelector // Whether to respond to a method conformsToProtocol // Whether to conform to a protocol
- 3:
class
Method classification method and object method.
- The instance
class
Method just returnsobject_getClass(self)
- class
class
Method returns directlyself
- 4.
object_getClass()
Access is the type of object. Isa – > class. Isa – > metaclass. Isa – > father metaclass. Isa – > root metaclass. Isa – > yourself (or yuan)
7: What’s the difference between classification and extension? What can they be used for? What are the limitations of classification? What are the members of the structure of classification?
- 1: Classification is mainly used to add methods, attributes, and protocols to a class (I usually use to extend methods for a system class or to split the functions of a complex class into different files)
- 2: The extension is mainly used for a class originally did not have member variables, attributes, methods. Note: Methods are only declared (I usually use extensions to declare private properties, or rewrite the.h read-only properties to be read and write)
The difference between classification and extension:
Classification merges classification information into class information at run time, and extension merges information into classes at compile time
There is no getter/setter method declaration or implementation, but there is an extension.
Classes are not used to add instance variables to classes, whereas extensions are
A class can add an implementation of a method to a class, whereas an extension can only declare methods, not implement them
Limitations of classification:
Can’t add an instance variable for the class, but can be achieved through the connection object, note: associations in memory management not weak, it needs to pay attention to the wild pointer, but through other ways to achieve, specific can consult the iOS weak keyword if rambling classification method and the class was the implementation of the zhangs, will cover the original method of implementation, note: It’s not really coverage
Methods with the same name for multiple categories call the implementation of the last compiled category
What members are in the structure of the classification
struct category_t { const char *name; // Name classref_t CLS; Struct method_list_t *instanceMethods; Struct method_list_t *classMethods; // Struct protocol_list_t *protocols; // Struct property_list_t *instanceProperties; Struct property_list_t *_classProperties; struct property_list_t *_classProperties; // Class attribute list};Copy the code
8: Can you briefly describe the implementation mechanism of Dealloc
Dealloc implementation mechanism is the focus of the content management part, to understand this knowledge point, for a full range of understanding of memory management is very necessary.
1.Dealloc call process
- 1. First call
_objc_rootDealloc()
- 2. Next call
rootDealloc()
- 3. At this time, it will judge whether it can be released or not. The judgment is mainly based on five factors: whether there are the above five conditions
NONPointer_ISA
weakly_reference
has_assoc
has_cxx_dtor
has_sidetable_rc
- 4-1. If any of the five options are available, the
object_dispose()
Method, do the next step.- 4-2. If any of the previous five conditions is not available, the release operation can be performed,
Free () of C function
.- 5. The execution is complete.
2. The object_Dispose () call process.
- Direct call
objc_destructInstance()
.- Free () of the C function is then called.
3. Objc_destructInstance () calls the process
- To determine
hasCxxDtor
If there is C++ related content, to callobject_cxxDestruct()
To destroy C++ related content.- To determine
hasAssocitatedObjects
, if any, to callobject_remove_associations()
, a series of operations that destroy the associated object.- And then call
clearDeallocating()
.- Execution is complete.
4. ClearDeallocating () calls the process.
- To perform first
sideTable_clearDellocating()
.- To perform
weak_clear_no_lock
In this step, the weak reference pointer to the object is set tonil
.- Next, execute
table.refcnts.eraser()
Erases the reference count of the object from the reference count table.- So far,
Dealloc
The execution process of the.
9: The difference between HTTPS and HTTP
HTTPS = HTTP + SSL/TLS
SSL
Is the full name ofSecure Sockets Layer
Secure Socket Layer (SSL) is a security protocol that provides security and data integrity for network communication.- The full name of TLS is
Transport Layer Security
That is, secure transport layer protocol.
That is, HTTPS is secure HTTP.
Hyper Text Transfer Protocol Secure (Hyper Text Transfer Protocol Secure) This is provided by TLS (SSL)! It’s probably provided by a library called openSSL. HTTPS and HTTP both belong to the Application Layer and are based on TCP (and UDP), but they are completely different. TCP uses port 80 and HTTPS uses port 443. (It is worth mentioning that Google invented a new protocol called QUIC which is not based on TCP and also uses port 443 for HTTPS.) Google is awesome.) In general, HTTPS is similar to HTTP, but safer than HTTP.
10: Why does TCP require three handshakes and four waves?
Three handshakes:
- The client initiates a request link to the server and sends it first
SYN
Message,The SYN = 1, seq = x
, and the client entersSYN_SENT
state- The server receives the request link, replies to the client and sends a response packet.
The SYN = 1, seq = y, ACK = 1, ACK = x + 1
, and the server enters theSYN_RCVD
state- After receiving the acknowledgement packet, the client sends the acknowledgement packet to the server.
ACK = 1, ACK = y + 1
The client enters theESTABLISHED
After receiving the acknowledgement packet from the client, the server also enters theESTABLISHED
Status, the link is successfully created
Four waves:
- The client initiates a close link to the server and stops sending data
- When the server receives a request to close the link, it sends a response to the client, I know, and stops receiving data
- When the server is finished sending data, it initiates a close link to the client and stops sending data
- When the client receives a request to close the link, it sends a response to the server, I know, and stops receiving data
Why you Need three handshakes:
To prevent an error caused by a connection request segment that has already failed from being suddenly retransmitted to the server, assume that it is a segment that has already failed. However, after receiving the invalid connection request segment, the server mistakenly considers it to be a new connection request sent by the client. An acknowledgement segment is sent to the client, agreeing to establish a connection. Assuming the “three-way handshake” is not used, a new connection is established as soon as the server issues an acknowledgement. Since the client has not made a connection request at the moment, the server’s acknowledgement is ignored and no data is sent to the server. However, the server assumes that a new shipping connection has been established and waits for the client to send data. In this way, a lot of server resources are wasted.
Why it takes four waves:
Because TCP is full-duplex communication, when receiving a close request from the client, it may also be sending data to the client, so it can no longer respond to the close request, and send a close request at the same time
11. What’s the difference between symmetric encryption and asymmetric encryption? What algorithms are implemented?
Symmetric encryption, where the encryption and decryption of the encryption use the same key.
- Asymmetric encryption, using a pair of keys for encryption and decryption, a public key and a private key. The public key can be obtained by the owner of the communication. The sender of the communication can use the public key to encrypt the communication, and the receiver can use the private key to decrypt the communication after receiving the communication.
- Symmetric encryption algorithms commonly used to implement AES,ChaCha20,DES, but DES is considered to be insecure; Asymmetric encryption algorithm with RSA, ECC
12. HTTPS handshake process? Why do you need asymmetric encryption for key delivery? Do you understand two-way authentication?
The HTTPS handshake process, shown below, is taken from the HTTP diagram
- The Client sends a Client Hello packet to start SSL communication. The packet contains the SSL version supported by the client and the list of encrypted components.
- The Server responds with a Server Hello packet. As with the client, the packet contains the SSL version supported by the client and the list of encrypted components. The encryption component content for the server is filtered from the received client encryption component
- The server sends the Certificate packet. The packet contains a public key certificate.
- The Server then sends a Server Hello Done packet to notify the client that the initial SSL handshake negotiation is over
- After the first SSL handshake, the Client uses the Client Key Exchange packet as the meeting. The message contains a random password string called a pre-master secret used in communication encryption
- Then the client sends a Change Cipher Space message. The packet prompts the server, and the communication after the packet is encrypted with the pre-master secret key
- The client sends a Finished packet. This packet contains the overall checksum value of all packets linked so far. The success of the handshake negotiation depends on whether the server can reveal the article correctly
- The server also sends a Change Cipher Space message.
- The server also sends Finished packets.
- After exchanging Finished packets between the server and client, the SSL connection is established and the HTTP communication starts. The communication content is encrypted using the pre-master secret command. The HTTP request is then sent
- After receiving an HTTP request, the application layer sends an HTTP response
- Finally, a client disconnects
Why do you need asymmetric encryption for key delivery?
Asymmetric encryption is used to ensure the security of the pre-master secret key generated by the client. According to the above steps, it is possible for the server to send the public key certificate to the client to be intercepted by others. If symmetric encryption is used, When the client sends the pre-master Secret key to the server, if it is intercepted by hackers, it can use the public key to decode, and the security of the pre-master secret key cannot be guaranteed
Do you understand two-way authentication?
The HTTPS communication process only verify the server’s identity, and the server did not verify the identity of the client, two-way authentication is the service side is also to ensure the identity of the client, probably process is the client in after checking the server’s certificate, will send your public key to the server, and then generate a new key is encrypted with the public key of a service, to the client, The client then decrypts with the private key, which is then used for symmetrically encrypted communication
IOS Hot corpus & Video analysis
1) Swift
② Underlying iOS technology
③iOS reverse protection
④iOS interview collection
⑤ Daco interview questions + underlying technology + reverse security +Swift
Remember to like friends oh ~
Collection is equal to white prostitute, praise is true love ღ(´ · ᴗ · ‘)ღ