ReactiveCocoa Programming on iOS pdf
One of the key concepts of functional programming is that of a “higher-order function”. According to Wikipedia, a higher-order function is a function that satisfies these two conditions: • It takes one or more functions as input. • It outputs a function. In Objective-C, we often use blocks as functions. We don’t have to look very far to find some higher-order functions baked into Foundation for us by Apple. Consider a simple array of numbers: 1 NSArray *array = @[@(1), @(2), @(3)]; We might want to enumerate over the contents of that array, doing something with each element. “Fine”, you say, “I’ll just write a for loop.” Stop right there, buddy. As I’ve written before, stop writing for loops. There is a higher-order function of NSArray’s that we can use, instead. This code: 1 for (NSNumber *number in array) { 2 NSLog(@"%@", number); 3 } … is equivalent to
- 粉丝: 0
- 资源: 15
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助