iOS face question Collection

Source: Internet
Author: User

1. Please describe the differences between Nsset, Nsarray and nsdictionary.
Nsset, Nsarray, nsdictionary are all non-mutable collection classes, and only object elements can be added to the collection class to add basic data types.
Immutable: The collection class cannot be modified after it has been created.
Nsset:
1. is an unordered collection
2. The addresses stored in memory are not contiguous
3. And the added elements are non-repeatable
4. Nsset It is the location of the element directly found using the hash algorithm.
Nsarray
1. is an ordered set of
2. The addresses stored in memory are contiguous, and the added elements are repeatable
3. Nsarray can support access to elements through subscript.
4. If you want to know whether an element exists in this array, then you need to traverse the entire array to judge, so obviously efficiency underground.
Nsdictionary
1. This unordered collection
2. Its data is stored in a way that key value pairs are stored
3.key is unique throughout the nsdictionary, and if the key is duplicated, then the added element will overwrite the previous one.
4. Same as Nsset is the use of hash directly to find the location of the element, efficiency fast.

2. Please briefly describe the role of the static keyword
When static modifiers are used, the variable is called a static variable, and so-called static variables have only one copy of the memory, which is destroyed when the program ends.
Static can only be declared outside of the implement or method, and if it is not given the default value of 0, it will be initialized once the program starts.
A variable that has been modified by static cannot be accessed by the class name. If you want to access the static variable in a class and make some modifications to it, you need to provide a method.

3. Please indicate when to use the agent, when to use the notice

Agent: is a one-to-two relationship, 1 objects can only tell the other object what happened.
Notification: A Many-to-many relationship, 1 objects can tell what happens to multiple objects, and 1 objects can receive what happens to multiple objects.

4. Please indicate what is the difference between classification and class extension.
Classification: The ability to add methods to this class without being familiar with the original class. If the newly added method is the same as the method of the original class, the method of classification is used preferentially.
Class extensions: Class extensions can add properties and methods to this class based on the original class, and the methods they add must be implemented.

5. Please indicate what is lazy loading and what is the use of lazy loading?
Lazy loading is also known as deferred loading. Then load it when it's ready to use.
Lazy loading role: Generally used for the page is very long, the page but the picture in a lot of cases, if you want to put these data once loaded, it is impossible, and this performance is not good. In order to avoid this situation, the current mainstream approach is the first time the page load, only display the current visual area of the picture, when the user scrolls the page, when the picture into the visible area and then load, which can significantly improve the page loading speed, and less picture concurrent requests, can greatly reduce the pressure on the server, It was a lot more than a swoop.

Picture delay loading principle is relatively simple, first the real address of the picture is written in a custom attribute, such as Data-url (HTML5 in the beginning of the data-custom attributes are legal), SRC address is best not empty, put a 1x1 full transparent placeholder image on the line, such as
When the page scrolls, it is time to calculate whether the picture is in the visible area of the current window, and if so, replace the pseudo address of SRC with the real address of Data-url.


6. Please indicate the respective roles of #include, #import @class
#include: is a C-language precompiled directive that tells the compiler to import related header files, which can also be used in OC because OC-compatible C syntax
#import: Is the GCC compiler provides no matter how many times it appears in a file, the header file is guaranteed to be included only once
@class: Tells the compiler that the class is currently declared in this file, but the class defines what is not known and uses it to reduce compilation time

7. What is the difference between #import <> and #import ""
Header file for #import <> import System
#import "" Import user customization files

What is the 8.id type, what is instancetype, and what is the difference
ID Type: The universal pointer, which can be used as the parameter, the return type of the method.
Instancetype: can only be a scope type for a method, and the returned type is the class type of the currently defined class.

9. Please write the full name of Arc and MRC in English
Arc:automatic Reference counting self-defined reference count
Mrc:mannul Reference Counting Manual reference count

10. Please explain what Block,block can be used to do, __block what is the use.

The Block object is a C-level syntax and runtime attribute they are similar to standard C functions, but they may also contain variable auto-binding (stack) or memory-managed (heap) in addition to executable code. So a block maintains a set of States (data) that can be used to influence program behavior at execution time.
You can use blocks to write function expressions that can be used as APIs, optional storage, or used by multiple threads. Blocks is particularly useful as a callback because the block carries the execution code needed to perform the callback and the data needed during execution.

__block Effect: The default block block out variable is not modified _ that is, read-only state, using the __block modifier variable can change the value of the variables within the block.

11. What is object-oriented and what is an object-oriented feature?
The relationship between all things in the real world is abstracted into a relationship that can be represented in a computer. So this particular thing is the object.
Object-oriented features: Inheriting package polymorphism

12. What is polymorphic?
The same operation, acting on different objects, produces different results.
To achieve polymorphism to have the following conditions
1. To have inheritance
2. To have a rewrite
3. The pointer to the parent class points to the object of the child class.

13. Please outline what is MVC
Mvc:model View Controller (model, view, controller)
Model: Responsible for the processing of data logic, models object is responsible for storing in the database.
View: Responsible for displaying the data, showing the data is displayed according to the model
Controller: Responsible for handling user interactions, reading data from the view, controlling user input, and sending data to the model.
Characteristics:
Reduce the coupling between modules

MVC is not a design pattern, it is a design of architecture and architecture.
Architecture Design: An architectural pattern describes the basic structure and organization outline of a software system. The schema pattern provides some pre-defined subsystems, assigns their responsibilities, and gives the rules and guidelines for organizing them together. Some people refer to schema mode as System mode. An architectural pattern can often be decomposed into a combination of many design patterns.

Design pattern: A design pattern that provides a design that refines the components in a subsystem or software system or the relationships between them. The design pattern describes a ubiquitous structure that repeats itself in a communication component, a structure that solves a general design problem in a certain context.

14. Please write down how you know how to transfer data
1. Agent
2. Notice
3. Direct access to the object's set method for data transfer
4.block

15. What is the nature of dot grammar? Write an example of a dot grammar.
The essence of point syntax is to invoke the getter setter method.
Example: Person.age = 10;//here called [person Setage:10]
int age = Person.age; Call [person age] here;

[email protected] role

A member variable created by the compiler to automatically generate a getter setter method with the same name as a class member variable is @property the default decorated domain created by _ is private
can also be managed for object memory

[email protected]
What is the role of retain and assign?
Retain: can only be used for object types, when the set method is called, the object's reference counter +1
Assign: Direct assignment, generally to the basic data type use, does not increase the reference count, set up agents need to use assign, assign mainly to solve the circular reference count and design.

18. What is the constructor method, what is the use of the construction method, and what is the point of note in using the construction method.
What is a constructor method: A method of constructing a method that initializes an object and returns an instance of an object.
What is the use of construction methods: typically some initialization of a class is done in the constructor method
Note: The beginning of the method must start with Init and the next name should be capitalized such as Initwithname, Initlayout


19. Please describe what the agreement is and what the agreement can be used to do
Protocol: a common interface.
In the protocol can only define the method cannot define the attribute, the implementation of the Protocol needs the concrete class to follow this protocol implementation method in the Protocol. The methods defined in the protocol can be optional and must be implemented, which is optional by default.

20. What is the principle of memory management?
As soon as the New,alloc,copy,mutablecopy,copywithzone,retain appears, match the release operation, or the autorelease operation

21. Please explain the difference between frame and bounds
Frame: Displays the position and size of the current control as the origin in the upper-left corner of the parent control
Bounds: The top left corner of the control itself is the origin, showing the current size bounds changes will change the control's frame

22. Please indicate the difference between xib and storyboard.
are used to describe the software interface
Xib is lightweight and is used to describe the local UI interface
Stroyboard is a heavyweight, a multi-interface for describing the entire software, and the ability to show jump relationships between multiple interfaces

23. General rewrite Loadview is used to do
View used to customize the controller

24. Please write out the life cycle method of the view controller
Loadview
Viewdidload
Viewwillappear
Viewdisappear
Viewwilldisappear
Viewdiddisappear
Didreceivememorywaring
Viewwillunload
Viewdidunload

25. Please write down the default size
iPhone3.5 inch Non-retina 320 * 480
iPhone3.5 Retina 640 * 960
IPhone 4 inch 320 * 568
Uistatusbar 320 * 20
Uinavigationbar 320 * 44
UITableViewCell 320 * 44
Uitabbar 320 * 49

26.UIImage loading picture by
+ (UIImage *) imagenamed: (nsstring*) name;
+ (UIImage *) Imagewithcontentsoffile: (NSString *) path
The two methods are different when loading pictures.

1. The above method of loading the image only needs to pass in the name of the picture without having to pass in the specific path after loading there will be a cache.
2. Load the picture below to load the full path of the incoming picture directly
Generally use the small picture when you can choose to use the way above, large pictures using the following way.

27.drawRect: When is the law called ?
This method is called when the view is first displayed on the window
Call Setneedsdisplay or setneedsdisplayinrect manually
28. Please describe the relationship between UIView and Calayer?
UIView is able to receive the processing of events and the display of views and Calayer is just the drawing of the view, so a view he does not need to interact with the user should use Calayer performance will be higher, this is more lightweight.
29. How to draw things to the view using quartz2d
1. Get the graphics context
2. Draw the path
3. Save the path
4. Render to a specific view.
30. Can a uiviewcontroller be associated with two different data sources to display two TableView?
OK.
The first way
1. When configuring a data source, make a type judgment on the configured TableView

1-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section2 {3         if(TableView = =self.tableview1)4         {5         return 5; 6         } 7         Else8         {  9        return Ten; Ten         }  One } A  --(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) Indexpath { -staticnsstring *id1 [email protected] "Cellstyleone";  theStaticnsstring *id2 =@"Cellstyletwo"; -UITableViewCell *cell =Nil;  -   if(TableView = =self.table1) -   {     +Cell =[TableView DEQUEUEREUSABLECELLWITHIDENTIFIER:ID1];  -            if(Cell = =Nil) +            {            ACell =[[UITableViewCell alloc]initwithstyle:uitableviewcellstylesubtitle REUSEIDENTIFIER:ID1];  at            }               -[Cell.textlabel SetText:@"Itcast"];  -[Cell.detailtextlabel SetText:@"Detail"];  -   }  -   Else -   {         inCell =[TableView Dequeuereusablecellwithidentifier:id2];  -  if(Cell = =Nil) to     {            +Cell =[[UITableViewCell Alloc]initwithstyle:uitableviewcellstyledefault Reuseidentifier:id2];  -      }                the[Cell.textlabel settext:@] Kolnick"];  *   }   $   returncell;Panax Notoginseng}



The second way:
Create a new view controller that follows the data source protocol and implements the relevant method
Then create it in the first view controller and add his view to the first view controller.


31.UIImageView can directly click the response action? If not, how can it be? How do I listen for Uiimageview touch events?
No
Open userinteractionenable =yes;
Because Uiimageview is also inherited from UIView all inherited from UIView can receive user's touch event
Method 1. Overriding the Touchesbegin method
Method 2. Add a gesture to it

iOS face question Collection

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.