UIAlertController、集成MJRefresh、addObject:和addObjectsFromArray:的区别

 1 ## addObject:和addObjectsFromArray:的区别 3 self.topics = @[20, 19, 18]
 4 moreTopics = @[17, 16, 15]
 5 
 6 self.topics = @[20, 19, 18, @[17, 16, 15]]
 7 [self.topics addObject:moreTopics];
 8 
 9 self.topics = @[20, 19, 18, 17, 16, 15]
10 [self.topics addObjectsFromArray:moreTopics];
11 12 
13 ## 集成MJRefresh
14 - [github](https://github.com/CoderMJLee/MJRefresh)
15 - 基本用法
16 
17 18 self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewTopics)];
19 [self.tableView.mj_header beginRefreshing];
20 
21 self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreTopics)];
22 23 
24 ## 利用AFN取消请求
25 26 // 取消所有请求
27 for (NSURLSessionTask *task in self.manager.tasks) {
28     [task cancel];
29 }
30 
31 // 取消所有请求
32 [self.manager.tasks makeObjectsPerformSelector:@selector(cancel)];
33 
34 // 关闭NSURLSession + 取消所有请求
35 // NSURLSession一旦被关闭了, 就不能再发请求
36 [self.manager invalidateSessionCancelingTasks:YES];
37 
38 // 注意: 一个请求任务被取消了(cancel), 会自动调用AFN请求的failure这个block, block中传入error参数的code是NSURLErrorCancelled
39 40 
41 ## UIAlertController
42 43 UIAlertController *controller = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
44 
45 [controller addAction:[UIAlertAction actionWithTitle:@"收藏" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
46     NSLog(@"点击了[收藏]按钮");
47 }]];
48 
49 [controller addAction:[UIAlertAction actionWithTitle:@"举报" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
50     NSLog(@"点击了[举报]按钮");
51 }]];
52 
53 [controller addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
54     NSLog(@"点击了[取消]按钮");
55 }]];
56 
57 //    [controller addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
58 //        textField.textColor = [UIColor redColor];
59 //    }];
60 
61 [self.window.rootViewController presentViewController:controller animated:YES completion:nil];
原文地址:https://www.cnblogs.com/mkai/p/5678583.html