iso小练习,获取界面的空间,变量字符串int循环判断,get请求数据

来源:互联网 发布:过期未注册域名查询 编辑:程序博客网 时间:2024/04/30 17:37

UILabel *l1 = (UILabel *)[self.viewviewWithTag:(20)];

    l1.text=@"aaaaa";

    NSString *ss=@"我是张无法";

    ss=@"xxxxxxxxx";

    int a=0;

    int b=1;

    int c=a+b;

    NSString *res=[NSStringstringWithFormat:@"%d",c];

    NSLog(res);

    NSLog(@"测试");

    NSLog(ss);

    for (int i=0; i<10; i++) {

        NSLog([NSStringstringWithFormat:@"%d",i ]);

    }

    if (1==1) {

        NSLog(@"判断成功");

    }

    //第一步,创建URL

    NSURL *url = [NSURLURLWithString:@"http://zq.55085.cn/houtai/home/ss/getsai"];

    //第二步,通过URL创建网络请求

    NSURLRequest *request = [[NSURLRequestalloc]initWithURL:urlcachePolicy:NSURLRequestUseProtocolCachePolicytimeoutInterval:10];

    //NSURLRequest初始化方法第一个参数:请求访问路径,第二个参数:缓存协议,第三个参数:网络请求超时时间(秒)

    //第三步,连接服务器

    NSData *received = [NSURLConnectionsendSynchronousRequest:requestreturningResponse:nilerror:nil];

    

    NSString *str = [[NSStringalloc]initWithData:receivedencoding:NSUTF8StringEncoding];

    

    NSLog(@"%@",str);

     l1.text=str;

    UIAlertView *mBoxView = [[UIAlertViewalloc]

                             initWithTitle:@"获取数据成功"

                             message:@"您单击了'显示提示框按钮'"

                             delegate:nil

                             cancelButtonTitle:@"取消"

                             otherButtonTitles:@"确定",nil];

    [mBoxView show];}

0 0
原创粉丝点击