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