Basic Questions for iOS (4)

Source: Internet
Author: User
Tags network function

Continue to summarize some interview questions, which will be more difficult in the future.

IOS interview series:

IOS interview

IOS interview questions (1)

IOS interview question (2)

IOS interview questions (3)


1. What about block? And write an animation that uses block to execute uivew?

Answer: block is an anonymous function that can obtain local variables of other functions. It is not only convenient for development, but also greatly improves the application execution efficiency (multiple core CPUs can directly process block commands)

[UIView transitionWithView:self.view                  duration:0.2                   options:UIViewAnimationOptionTransitionFlipFromLeft                animations:^{ [[blueViewController view] removeFromSuperview]; [[self view] insertSubview:yellowViewController.view atIndex:0]; }                completion:NULL];

2. Write the block definition of the above Code.

Answer:

Typedef void (^ animations) (void );

Typedef void (^ completion) (bool finished );

3. Try to use + beginanimations: Context: and the definition of the block above to write

+ (Void) transitionwithview :( uiview *) view duration :( nstimeinterval) Duration options :( uiviewanimationoptions) Options animations :( void (^) (void) animations completion :( void (^) (bool finished) completion ns_available_ios (4_0); function execution part of the operation

Answer: None

Network

3. Does a project involve the network access function? What objects are used to complete the network function?

Answer: asihttprequest and nsurlconnection

4. What is the difference between the nsurlconnection class and the + sendsynchronousrequest: returningresponse: Error: And-initwithrequest: Delegate?

Answer: nsurlconnection is mainly used for network access, where + sendsynchronousrequest: returningresponse: Error: Synchronous access data, that is, the current thread will be blocked and wait for the response returned by the request, while-initwithrequest: Delegate: asynchronous loading is used. After network access is completed, it will return to the main thread through Delegate and delegate the object.

Multithreading

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.