Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
liberalisman committed Aug 9, 2018
1 parent 5ff0885 commit f47f15d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
- 3.`App` 编译过程有了解吗?- [链接](https://github.com/liberalisman/iOS-InterviewQuestion-collection/blob/master/其他问题/3.第三题.md)
- 4.说一下对 `APNS` 的认识?- [链接](https://github.com/liberalisman/iOS-InterviewQuestion-collection/blob/master/其他问题/4.第四题.md)
- 5.`App` 上有一数据列表,客户端和服务端均没有任何缓存,当服务端有数据更新时,该列表在 `wifi` 下能获取到数据,在 4G 下刷新不到,但是在 4g 环境下其他 `App` 都可以正常打开,分析其产生的原因?
- 6.是否了解链式编程?
- 6.是否了解链式编程?- [链接](https://github.com/liberalisman/iOS-InterviewQuestion-collection/blob/master/其他问题/6.第六题.md)



Expand Down
3 changes: 0 additions & 3 deletions 其他问题/11.第十一题.md

This file was deleted.

70 changes: 70 additions & 0 deletions 其他问题/6.第六题.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@



## 6.是否了解链式编程?

##### 链式编程其实就两个要点:
- Block 作为当前对象的属性。
- Block 返回值是当前对象。




##### 写个特别简单的小Demo:

###### .h文件

```objc
#import <UIKit/UIKit.h>

@interface SecViewController : UIViewController

@property (nonatomic,copy ) SecViewController *(^setUpBackGroundColor)(UIColor *color) ;

@property (nonatomic,copy ) SecViewController *(^setUpTitle)(NSString *title);

@end
```


###### .m文件

```objc
@implementation SecViewController

- (SecViewController *(^)(NSString *))setUpTitle {

return ^(NSString *title) {

self.title = title;
return self;
};
}

- (SecViewController *(^)(UIColor *))setUpBackGroundColor {

return ^(UIColor *backColor) {

self.view.backgroundColor = backColor;
return self;
};
}

@end
```
###### 外部调用
```objc
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
SecViewController *sec = [SecViewController new];
sec.setUpBackGroundColor([UIColor orangeColor]).setUpTitle(@"heihei");
[self.navigationController pushViewController:sec animated:YES];
}
```


如果看不懂自己敲一遍就懂了。

0 comments on commit f47f15d

Please sign in to comment.