1 談談對Block 的理解?並寫出一個使用Block執行UIVew動畫?
答案:Block是可以獲取其他函數局部變量的匿名函數,其不但方便開發,並且可以大幅提高應用的執行效率(多核心CPU可直接處理Block指令)
- [UIView transitionWithView:self.view
- duration:0.2
- options:UIViewAnimationOptionTransitionFlipFromLeft
- animations:^{ [[blueViewController view] removeFromSuperview]; [[self view] insertSubview:yellowViewController.view atIndex:0]; }
- completion:NULL];
2 寫出上面代碼的Block的定義。
答案:
typedef void(^animations) (void);
typedef void(^completion) (BOOL finished);
3 試着使用+ beginAnimations:context:以及上述Block的定義,寫出一個可以完成
+ (void)transitionWithView:(UIView *)view duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion NS_AVAILABLE_IOS(4_0);操作的函數執行部分
答案:無
網絡部分
3 做過的項目是否涉及網絡訪問功能,使用什麼對象完成網絡功能?
答案:ASIHTTPRequest與NSURLConnection
4 簡單介紹下NSURLConnection類及+ sendSynchronousRequest:returningResponse:error:與– initWithRequest:delegate:兩個方法的區別?
答案: NSURLConnection主要用於網絡訪問,其中+ sendSynchronousRequest:returningResponse:error:是同步訪問數據,即當前線程會阻塞,並等待request的返回的response,而– initWithRequest:delegate:使用的是異步加載,當其完成網絡訪問後,會通過delegate回到主線程,並其委託的對象。
多線程部分