IOS Face question 2

Source: Internet
Author: User

1. Describe the startup order of the application.
1. Program Entry main function Create UIApplication instance and UIApplication Proxy instance
2, rewrite the startup method in the UIApplication proxy instance, set the first Viewcontroller
3, add the control in the first Viewcontroller, implement the corresponding program interface.

Why are many built-in classes such as Uitableviewcontrol's delegate properties assign rather than retain? Please illustrate.
Prevent circular references,
Student * str=[];

Teacher *teacher=[[teacheralloc] init];

Student *student=[[student alloc] init];

Teacher.delegate=student;

Student.delegate=teacher;

In teacher Dealloc will release the current delegate, will trigger student object release, which will also lead to student execution Dealloc, in student will also release their delegate, Produced a cycle.

2, the use of UITableView time must be implemented in several ways?
2 of them.
-(Nsinteger) TableView: (uitableview*) Tableviewnumberofrowsinsection: (nsinteger) Section; This method returns the number of rows per partition
-(uitableviewcell*) TableView: (uitableview*) Tableviewcellforrowatindexpath: (Nsindexpath) Indexpath; This method returns each cell that we call

3, write a convenient constructor.
+ (ID) studentwithname: (nsstring*) newName andage: (int) newage
{
Student *stu = [[Student alloc]initwithname:newname andage:newage];
return [Stu Autorelease];
}

4, UIImage initialize a picture there are several ways? Describe the pros and cons of each.
1. Read from resources
UIImage *image = [UIImage imagenamed:@ "1.png"];
2. Read from the network
nsurl*url=[nsurlurlwithstring:@ "Http://www.sinaimg.cn/qc/photo_auto/chezhan/2012/50/00/15/80046_950.jpg"];
3. Read locally from the phone
Read local picture non-resource
NSString *apath3=[nsstring stringwithformat:@ "%@/documents/%@.jpg", Nshomedirectory (), @ "Test"];
UIImage *imgfromurl3=[[uiimage Alloc]initwithcontentsoffile:apath3]; 4. Get the image from the existing context

Addimageio.framework and #import <ImageIO/ImageIO.h>

Cgimagesourcerefsource = Cgimagesourcecreatewithurl ((cfurlref) URL, NULL);

Cgimageref Img=cgimagesourcecreateimageatindex (source,0,null);

Cgcontextrefctx=uigraphicsgetcurrentcontext ();

Cgcontextsavegstate (CTX);

2 Ways to TRANSFORMCTM

CGCONTEXTCONCATCTM (Ctx,cgaffinetransformmakescale (. 2,-0.2));

CGCONTEXTSCALECTM (ctx,1,-1);

Note that coordinates should be reversed, using CTX as the source of the image

Cgimagerefcapture=cgbitmapcontextcreateimage (CTX);

Cgcontextdrawimage (Ctx,cgrectmake, 0, (), [Image Cgimage]);

Cgcontextdrawimage (Ctx,cgrectmake), IMG);

Cgimagerefcapture2=cgbitmapcontextcreateimage (CTX);

5, use Quartz's cgimagesourceref to read the picture

Cgimagesourceref source= Cgimagesourcecreatewithurl ((cfurlref) URL, NULL);

Cgimageref Img=cgimagesourcecreateimageatindex (source,0,null);

Reference (http://blog.csdn.net/jerryvon/article/details/7526147#)

5. Answer the Retaincount value of person and explain why

Person *per = [[Person alloc] init];

Self.person= per;
If the person attribute is assign, then Retaincount is 1, and if it is retain, Retaincount is 2.

6. What is the problem with this code:

@implementation person

-(void) Setage: (int) NewAge {

Self.age = NewAge;

}

@end
Dead loop

7. What's wrong with this code, how to modify it

for (int i = 0; i < Somelargenumber; i++) {

NSString *string = @ "ABC";

string = [string lowercasestring];

string = [stringstringbyappendingstring:@ "xyz"];

NSLog (@ "%@", string);

}

If the number is large, it will cause memory to increase (because the Autorelease object has been created by facilitating the constructor method) until the end of the loop is reduced, and an auto-release pool is added to the loop, and the following code is changed:

for (int i = 0; i < Somelargenumber; i++) {

NSString *string = @ "ABC";
@autoreleasepool {

String =[string lowercasestring];

String =[string stringbyappendingstring:@ "xyz"];

NSLog (@ "%@", string);

}

}

8. Intercept string "20 | Http://www.baidu.com "," | " Characters before and after the data, output them separately.
NSString *string = @ "20 | Http://www.baidu.com ";
[String componentsseparatedbystring:@ "|"];

9. Write a bubble sort with obj-c

Nsmutablearray*array = [nsmutablearrayarraywitharray:@[@ "3", @ "1", @ "10", @ "5", @ "2", @ "7", @ "12", @ "4", @ "8"];

NSString *tmp;

for (int i = 0; i < array.count; i + +) {

for (int j = 0; J < array.count-1-I; j + +) {

if ([[[Array Objectatindex:j]integervalue] > [[[Array Objectatindex:j + 1] integervalue]) {

TMP = [array objectatindex:j];

[Arrayreplaceobjectatindex:j Withobject:[array objectatindex:j + 1]];

[Array replaceobjectatindex:j +1 withobject:tmp];

}

}

}

10. Describe your understanding of UIView, UIWindow and Calayer
UIView inherits from Uiresponder,uiresponder inherited from Nsobject,uiview can respond to user events. Calayer inherits from NSObject, so Calayer cannot respond to events.
UIView build interface, UIView focus on the management of content, Calayer focus on the content of the drawing.
UIView is used to display content, can handle user events, Calayer is used to draw content, the content is animated dependent and UIView to display, can not handle user events.

11, write a complete agent, including the declaration, to achieve
Slightly

12, the difference between the analysis of JSON, XML? How does the underlying JSON, XML parsing approach work?
The JSON underlying principle facilitates the characters in the string, and is ultimately differentiated according to the special aid characters specified by the municipalities, such as {},[],: number, etc., {} is a dictionary, [] represents the time array, the: number is the watershed of the dictionary's key and value, most always converts the JSON data into a dictionary. XML two parsing methods, Dom and sax,dom need to read into the entire XML document (document-driven), Sax is event-driven, do not need to read the entire document, the document read-in process is the parsing process of sax.

13. When was the didreceivememorywarning of Viewcontroller called? What is the default action?
Didreceivememorywarning executes the method in the event of a memory warning, releasing a reusable object that is temporarily unused in the method.

14, the three characteristics of object-oriented, and make a simple introduction
Encapsulation, inheritance, polymorphism. Encapsulation: It is to encapsulate objective things into abstract classes, to hide internal implementations, and to provide interfaces externally. Inheritance: You can use all of the features of an existing class and extend these features without rewriting the original class. Polymorphism: The ability of different objects to respond to the same message in their own way is called polymorphism, or the parent pointer points to a subclass object < such as UITableView, Cellforrow method, the return value type is Uitbaleviewcell, But the cell you're returning can be your custom cell, with the same method in multiple classes >

15. Override the setter and getter method of a nsstrng type, retain way to declare the Name property

16, briefly Notificationcenter, KVC, KVO, Delegate? and explain the difference between them?
NOTIFICATION: Observer mode, controller to defaultnotificationcenter add their own Notification, other classes register this Notification can receive notification, These classes can do their own operations when receiving notifications (the observers are notified by default in random order by multiple observers, and each observer waits until one of the current observers has been completed before his turn can be used to arrange the observer's reaction sequence in a notificationqueue manner, You can also set the reflection time in the Add observer, and cancel the observation needs to be written off in both Viewdidunload and Dealloc.

The KVC key-value encoding, which can be accessed directly through the string's name (key), indirectly accesses the property's mechanism, rather than by invoking the getter and setter methods.
KVO: Observes the properties of the specified object and notifies the appropriate observer when the property of the specified object changes.
Delegate: one-to-one, delegate follows a protocol and implements the Protocol declaration method.

17. What is Lazyloading?
When using the initialization, such as UITableViewCell's ImageView property, lazy loading object creation is created in the setter method.

18. What is protocol? What is an agent? Write a delegate's interface? What attributes are used for the property declaration of the delegate? Why?
The protocol provides a set of methods, but is not responsible for implementation, if a class follows a protocol, and implements the protocol inside the method, then we call this class is to follow the agent of a certain protocol. The Declaration of a property uses assign to prevent the issue of circular references.

19. What is the description category (categories) and extension (extensions) respectively? And the difference between the two? What is the difference between inheritance and category in implementation? Why can category only add methods to objects, but cannot add member variables?
Category Category: To extend a method for a class without knowing the source code, extension: Declares private methods and variables for a class.
Inheritance creates a new class, and the class is just an extension of the class, or the previous class.
The purpose of a class is to add a method to a known class.

20. Does objective-c have a private method? What about private variables? If not, is there any alternative?
There are only two methods in the Objective-c– class, static methods and instance methods.
@private to decorate a private variable
All instance variables in OC are private by default, and all instance methods are public by default.

21. What is the difference between #import, #include和 @class
#includec语言中引入一个头文件, but cross-compilation may occur
#import在OC中引入自己创建的头文件 #import "" or system frame #import<>. #import不会出现交叉编译
@class declare a class and tell the compiler that it has this class, but the definition of a class doesn't know anything about it.

22. Talk about your understanding of MVC? Why use MVC? How is MVC implemented in cocoa? Are you familiar with other OC design patterns or other design patterns?
MVC is Model-view-controller, the model-view-controller, MVC divides the software system into three parts: Model,view,controller. In cocoa, every object in your program will obviously belong to only one of these three parts, but not the other two at all. MVC can help ensure maximum reusability of the program to help implement. Each MVC element works independently of each other, and by separating these elements, it is possible to build a maintainable, independently updated program.
Singleton mode, delegate design mode, target-action design mode

23, such as monitoring system keyboard pop-up
[[Nsnotificationcenterdefaultcenter] addobserver:self selector: @selector () name:uikeyboardwillshownotification Object:nil];

24. Give more than 5 of the iOS SDK libraries you are familiar with and what are the third-party libraries?
Foundation,corefraphics,uikit,mapkit,corelocation,cfnetwork,messageui,imageio,coredata,afnetworking, Mknetworkkit,asihttprequest,fmdb,zxing,zbar,sdwebimage

25, how to publish the product in multiple languages?
Internationalization of programs

26. How to turn sensitive words into * *
String substitution stringbyreplacingoccurrencesofstring:withstring:

27. What does the minus sign and the plus sign in OBJC mean?
+ static method, also called class method,-instance method

28. What is the purpose of the Singleton and write out one?
You need to use a singleton when a class can have only one instance. Create a reference to the 2nd file

29, say the response chain
When an event occurs, the response chain is first sent to the first responder (often the view that the event occurred, where the user touches the screen). The event will be passed along the responder chain, knowing that it is accepted and processed. In general, the first response is a view object or its subclass, and when it is touched, the event is handed over to it, and if he does not process it, the time is passed to the View Controller object Uiviewcontroller (if present) and then to its top object (Superview). And so you know the top-level view. Next, along the top-level view (TopView) to the window (UIWindow object) to the program's (UIApplication object), if the entire process does not respond to this event, then the event is discarded, in general, as long as there is an object handling event in the response chain, the event is passed

A typical response roadmap is as follows:
First Responser--Thewindow-->the applicationn--App Delegate

IOS Face question 2

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.