iOS face questions

Source: Internet
Author: User
Tags gcd html header shallow copy

is the class of the basic article objective-c multiple inheritance? Can I use multiple protocols?

It is not possible to multiply inheritance, you can use multiple protocols.

What mechanism does OBJC use to manage object memory?
    1. MRC Manual Reference count
    2. ARC Auto Reference count, now usually using auto reference count
Import and # include what difference, @class, #import<> and #import "" What difference?

Import is the objective-c import header file keyword, #include是C/c++ import header file keyword, using #import header file will automatically import only once, do not repeat the import, equivalent to # include and #pragma once @class tell the compiler of a class declaration, when executed, to see the implementation of the class file, you can resolve the header file of each other, #import <> used to include the system header file, #import "" to include the user header file.

Describe how to implement the MVC development model in the iOS SDK

MVC is a model, an attempt to control the development pattern, and for the iOS SDK, all views are view layers, which should be independent of the model layer and controlled by the view control layer. All user data is the model layer and should be independent of the view. All Viewcontroller are control layers, which are responsible for controlling the view and accessing the model data.

The difference between shallow copy and deep copy?
    1. Shallow copy: Copies only pointers to objects, not the reference object itself.
    2. Deep copy: Copies the reference object itself.

That means I have an A object, after copying a copy to get A_copy object, for shallow copy, A and a_copy point to the same memory resource, copy is just a pointer, the object itself resources
There is only one copy, so if we do a modification to a_copy, then we find that the object referenced by A is also modified, which violates the idea of copying copies. Deep replication is a good idea, and there's an in-memory
Two copies of the independent object itself.

What is category? How do you extend a class by inheriting good or class? Why?

Category is category. Good, because the inheritance to meet A is a B relationship, and the class only need to meet A has a B relationship, the limitations are smaller, you can extend the function of a class without defining subclasses, but also to separate the definition of the class into different source files, the category to rewrite the method of the class , which is valid only for this category, does not affect the relationship of other classes to the original class.

What is extension? What is the role?

Extension (extension): Adds a class in the implementation file of its own class to declare a private method.

Explain the lazy pattern?

Lazy mode, only in the use of the time to initialize.
Can also be understood as delayed loading.
I think the best is also the simplest of a sample is the TableView in the picture loading shows.
A delay load, to avoid excessive memory, an asynchronous load, to avoid thread congestion.

What are the attribute keywords in the advanced article @property?

Attributes can have traits that fall into four categories:

    1. Atomicity--The characteristics of nonatomic

By default, the method synthesized by the compiler ensures its atomicity (atomicity) through a locking mechanism. If the attribute has a nonatomic trait, no synchronization lock is used. Note that although there is no trait named "Atomic" (if a property does not have a nonatomic trait, it is "Atomic" (atomic)), it can still be stated in the attribute trait, and the compiler will not give an error. If you define the access method, you should follow the atomicity that corresponds to the attribute trait.

    1. Read/write Permissions--readwrite (read-write), readonly (readable only)

    2. Memory management semantics--assign, strong, weak, copy
      Method Name--getter=, setter=

What are some third-party libraries you often use?
    1. Afnetworking
    2. Sdwebimage
    3. FMDB
    4. Jsonkit
    5. Mjrefresh
    6. Mjextension
    7. Masonry
    8. Friends Alliance, SHARESDK and other three-party library.
What are the design patterns you often use?
    1. Mvc
    2. Proxy mode
    3. Observer pattern
    4. Single-Case mode
    5. Factory mode
What are the local storage methods?
    1. Attribute list (Nsuserdefault or plist)
    2. Object Archive (Nskeyedarchiver)
    3. Sqlite
    4. CoreData
Does the weak attribute need to be nil in dealloc?

No, in the ARC environment either a strong pointer or a weak pointer need not be set to Nil,arc in the Deallco to automatically help us with it.

What are the roles of @synthesize and @dynamic respectively?
    1. @property have two corresponding words, one is @synthesize and the other is @dynamic. If @synthesize and @dynamic are not written, then the default is @syntheszie var = _var;
    2. The semantics of @synthesize is that if you do not implement setter methods and Getter methods manually, then the compiler will automatically add these two methods to you.
    3. @dynamic tells the compiler that the setter and getter methods of the property are implemented by the user themselves and are not generated automatically.
NSString (or Nsarray,nsdictionary) declared with @property often uses the copy keyword, why? If you use the strong keyword, what might be causing the problem?
    1. Because the parent pointer can point to a subclass object, the purpose of using copy is to make the properties of this object unaffected by the outside world, and by using copy, whether I pass in a mutable object or a non-object, I am holding an immutable copy.
    2. If we use a strong, then this property may point to a mutable object, which is affected if the Mutable object is modified externally.
When will you report unrecognized selector's abnormality?

When there is a method on the object that does not implement this method

What happens when a block is used and how is the reference loop resolved?
    1. As long as an object has a strong reference to the block, there is a direct use of the object within the block.
    2. Solution: __weak id weakself = self;
If you are using some of the system's block APIs (such as the block version of UIView for animation), do you also consider reference loops?

Generally not considered, because the official documentation does not tell us to pay attention to the occurrence of strong references, so it is assumed that the system control is generally not strong references to these blocks, so we can not consider the problem of cyclic strong reference

What are the two types of GCD queues (dispatch_queue_t)?

Serial Queue and parallel queue

How can I synchronize several asynchronous calls with GCD? (such as loading multiple pictures asynchronously based on several URLs, and then compositing an entire image after the download is complete)

Overall: Use dispatch group, then wait forever to finish, or take group notify to notify the callback.

1
2
3
4
5
6
7
8
dispatch_queue_tQueue= dispatch_get_global_queue (Dispatch_queue_priority_default, 0); 
dispatch_group_t group = dispatch_group_create ();
dispatch_group_async (group, queue, ^{/* load image 1 */});
dispatch_group_async (group, queue, ^{/* load image 2 */});
dispatch_group_async (group, queue, ^{/* load image 3 */});
dispatch_group_notify (group, Dispatch_get_main_queue (), ^{
//merge picture
})
How does the following code work?

can only output 1, and then thread the main path deadlock

1
2
3
4
5
6
7
8
9
-(void) viewdidload
{
[Super Viewdidload];
NSLog (@"1");
Dispatch_sync (dispatch_get_main_queue (), ^{
NSLog (@"2");
});
NSLog (@"3");
}
If a class has an instance variable NSString *_foo, call Setvalue:forkey: Can I use Foo or _foo as key?

All can

Why can iboutlet view properties be set to weak?

Because the view already has a strong reference to it

How do you understand how to use the single case?

Singleton pattern Single case design mode, through a single case model can ensure that a class only one instance and the instance is easy to access outside, so as to facilitate the control of the number of instances and save system resources. Singleton mode is the best solution if you want to have only one object for a class in the system. A class can have only one instance, and it must be accessed from a well-known access point, such as a factory method. This unique instance can only be extended by subclasses, and the extended object does not break the client code. For example, UIApplication's Sharedapplication method will return a uiapplication instance of the current application at any time.

LLDB (GDB) Common debug commands?

Most commonly used is: PO Object

What is a predicate?

predicate is through the nspredicate, is through the given logic condition as the constraint condition, completes the filtering to the data.

+ (void) load; + (void) initialize; The difference?

+ (void) load; Executes immediately after the program is run.
+ (void) initialize; Executed when the method of the class is first tuned.

What is KVC and what is KVO?
    1. KVC: Key-value encoding is a mechanism that indirectly accesses an object's properties by using a string to identify the property, rather than by invoking an access method, either directly or through an instance variable.
    2. KVO: A key-value observation mechanism that provides a way to observe a change in a property, greatly simplifying the code.
When to use delegate, when to use notification?

Delegate for one-to-one relationships, and reciever can return a value to Sender,notification can be for One-to-one/many/none, Reciever cannot return a value to sender. Therefore, delegate is used by sender to receive a function feedback value to reciever, notification is used to notify multiple object of an event

Block andWeak difference?
    1. __block can be used in either ARC or MRC mode, can be decorated with objects, and can also be decorated with basic data types.
    2. __weak can only be used in Arc mode, can only be decorated with objects (nsstring), and cannot be decorated with basic data types (int).
    3. The block object can be re-assigned in the block,weak not.
What is the difference between frame and bounds?

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 refers to the position and size of the view in its own coordinate system. (The reference point is its own coordinate system)

What's the difference between UIView and Calayer?

The big difference is that the layer is not rendered directly to the screen, UIView is the basis of the interface elements in the iOS system, and all the interface elements are inherited from it. It is entirely by coreanimation to achieve it. The real drawing part of it is managed by a Calayer class. The UIView itself is more like a Calayer manager. A uiview can have n calayer, each layer shows a kind of thing, enhance UIView's ability of presentation.

What is the difference between TCP and UDP?
    1. TCP: (Transmission Control Protocol), providing connection-oriented, reliable location-to-point communication;
    2. UDP: (User Datagram Protocol), providing non-connected unreliable point-to-multipoint communication;
    3. In the actual application, look at the procedure to pay attention to which aspect is reliable or fast;
Socket connection and HTTP connection
    1. HTTP connection: Short connection. That is, the client sends a request to the server, and after the server responds, the link is broken;
    2. Socket connection: Long connection. That is, once the client is established with the server, it will not be actively broken down.
What is the difference between post and get in HTTP, and how do you choose them in practice?
    1. Get is the data that is fetched from the server, and post is the data that is sent to the server.
    2. On the client side, the Get method submits the data through the URL, the data is visible in the URL, and the data is placed within the HTML header by the Post method.
    3. For the Get method, the server side uses Request.QueryString to get the value of the variable, and for post, the server side uses Request.Form to get the submitted data.
    4. The Get method submits only 1024 bytes of data, while Post does not have this limit.
    5. Security issues. As mentioned in (1), when you use Get, the parameters are displayed on the address bar, and Post does not. So, if the data is in Chinese and is non-sensitive, then use get; If the user enters data that is not a Chinese character and contains sensitive data, then it is better to use post.
      HTTP defines different ways to interact with the server, with 4 basic methods, namely get,post,put,delete. URL full name is a resource descriptor, we can think: a URL address, which is used to describe a network of resources, and HTTP get,post,put,delete corresponding to this resource, change, increase, delete 4 operations. Get is typically used to get/query resource information, and post is typically used to update resource information.
What are the ways to check for memory management problems
    1. Click Productàanalyze in the Xcode top menu. This method can be used primarily to view memory leaks, variables not initialized, variables defined and not
    2. Check with the Instrument tool. Click Product profile in the Xcode top menu to pop up an interface, select the memory on the left, and then choose the leaks on the right.
    3. Manual Check
On the pros and cons of Android and Apple

Apple system advantages are left and right smooth, software, the interface is gorgeous, the icon is unified, very beautiful; The disadvantage is that the system is closed, does not allow the user too many personalization settings, and can only be used on the Apple phone. Android system advantages are open, can expand their own a lot of things, support more hardware, all the price of mobile phones have, the drawback is that the software is too messy, compatibility problems, icon confusion is not beautiful. iOS is really smoother than Android, which is only reflected in the larger software switch, the other is almost smooth, iOS does not do a full background, if it is completely back-end estimates will not be smoother than Android. Conversely, if Android is only focused on a single operation, fluency will greatly improve, iOS system updates are not as frequent as Android, Love experience will choose Android, those who are afraid of annoying will choose iOS. iOS's hardware needs are less than Android, so Android is hotter than iOS and more power-consuming.

How do you understand the operation of the great God?

OBJC runtime is actually a runtime library, basically written in C and sink, this library makes C language has the object-oriented ability (the brain emerges when you Joe Master visited Xerox Parker's SmallTalk after the mouth of a smile). This library does the pre-loading of the class information, the method of distribution and forwarding and so on. OC is a language that targets runtime (runtime), which means that it can defer the execution of the code as much as possible from the time it is compiled and linked to the runtime. This gives programmers a lot of flexibility in writing code, such as the ability to forward messages to the object you want, or to swap out the implementation of a method. This requires the runtime to detect whether an object can respond to a method, and then distribute the method to the corresponding object.

How to use @property in @protocol and category
    1. Using property in protocol only generates setter and getter method declarations, and we use properties to implement this property for objects that wish to abide by my protocol.
    2. The use of category @property is also the only way to generate a setter and getter method declaration, if we really need to add property to the category implementation, need to rely on the run-time two functions:
    • Objc_setassociatedobject
    • Objc_getassociatedobject
How does runtime find the corresponding IMP address via selector?

Each class object is a list of methods, the method list records the name of the method, the method implementation, and the parameter type, in fact, selector is the method name, the method name can be found in the method list corresponding method implementation.

How does a OBJC object perform memory layout?
    1. All of the parent class's member variables and their own member variables are stored in the corresponding storage space for that object.
    2. Each object has an Isa pointer inside it, pointing to his class object, which holds the object's
    • Object Method List (the list of messages that an object can receive, stored in its corresponding class object)
    • A list of member variables,
    • Property list,

Inside it there is also an Isa pointer to the meta-object (meta Class), where the meta-object holds a list of class methods, and a superclass pointer inside the class object that points to his parent class object.

iOS face questions

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.