以下是友盟统计
加第三方
#define APPkey @“5bd954bbf1f5566d38000234”
#import <UMAnalytics/MobClick.h>
typedef NS_ENUM(NSInteger, ECstatistic) {
ECstatisticLog, ///< 日志系统
ECstatisticEvent, ///< 事件机制
ECstatisticTest ///< 集成测试
};
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
/**
储存表格单元格数据的数组
*/
@property (nonatomic,strong) NSArray *cellArray;
/**
主页面展示的表格
*/
@property (nonatomic,strong) UITableView *ojTableView;
@end
@implementation ViewController
-
(UITableView *)ojTableView{
if (!_ojTableView) {
_ojTableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStyleGrouped];
_ojTableView.delegate = self;
_ojTableView.dataSource = self;
}
return _ojTableView;
} -
(void)viewDidLoad {
[super viewDidLoad];
// 初始化数组
_cellArray = @[@“日志系统”,@“集成测试”,@“事件机制”];
[self.view addSubview:self.ojTableView];
} -
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return _cellArray.count;
} -
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
// 创建静态字符串标识单元格
static NSString * const cellID = @“com.baidu.www.Lesson-2------”;
// 创建UITableViewCell 对象
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
// 对cell进行判断
if (!cell) {
// 如果cell不存在 则初始化
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
}
cell.textLabel.text = _cellArray[indexPath.row];
return cell;
} -
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
switch (indexPath.row) {
// 日志系统
case ECstatisticLog:{
NSLog(@“点击了日志系统”);
}break;
// 集成测试
case ECstatisticTest:{
NSLog(@“点击了集成测试”);
}break;
// 事件机制
case ECstatisticEvent:{
[MobClick event:@“pay” attributes:@{@“book” : @“Swift Fundamentals”} counter:110];
}break;default: break;
}
}
@end