首页 > 其他 > 详细

使用野狗(Wilddog)云setValue写入数据

时间:2016-04-05 19:55:47      阅读:216      评论:0      收藏:0      [点我收藏+]
- (void)viewDidLoad {
    [super viewDidLoad];
    //创建野狗实例化对象 用于随时监听数值变化
    Wilddog *myRootRef = [[Wilddog alloc] initWithUrl:@"https://exile.wilddogio.com/weather"];
    //监听键值
    [myRootRef observeEventType:WEventTypeValue withBlock:^(WDataSnapshot *snapshot) {
        NSLog(@"%@ -> %@", snapshot.key, snapshot.value);
    }];
    //为weather键赋初始值
    [myRootRef setValue:@"Sunny"];
    
    UIButton* btn1=[[UIButton alloc]initWithFrame:CGRectMake(20, 20, 100, 30)];
    btn1.backgroundColor=[UIColor orangeColor];
    [btn1 addTarget:self action:@selector(changeValue1) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn1];
    
    UIButton* btn2=[[UIButton alloc]initWithFrame:CGRectMake(20, 70, 100, 30)];
    btn2.backgroundColor=[UIColor orangeColor];
    [btn2 addTarget:self action:@selector(changeValue2) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn2];
}

-(void)changeValue1
{
    Wilddog *myRootRef = [[Wilddog alloc] initWithUrl:@"https://exile.wilddogio.com/weather"];
    [myRootRef setValue:@"Snow"];
}

-(void)changeValue2
{
    Wilddog *myRootRef = [[Wilddog alloc] initWithUrl:@"https://exile.wilddogio.com/weather"];
    [myRootRef setValue:@"Wind"];
}

 

使用野狗(Wilddog)云setValue写入数据

原文:http://www.cnblogs.com/death3721/p/5356164.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!