zoukankan      html  css  js  c++  java
  • #在蓝懿学习iOS的日子#day19

    今天没有学习什么新的知识,我都是在反复使用这里两天学习的内容进行知识的展示,让一个内容变得丰富 1、web view的使用 搭建 然后编写代码 @property (weak, nonatomic) IBOutlet UIWebView *myWV; @property (weak, nonatomic) IBOutlet UITextField *myTF; @end @implementation ViewController - (IBAction)clicked:(id)sender { NSURL *url = [NSURL URLWithString:self.myTF.text]; //创建请求 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [self.myWV loadRequest:request]; } 2,创建解析类jsonParser +(TrainInfo *)parserTrainInfoWithDic:(NSDictionary *)dic{ NSDictionary *resultDic = dic[@"result"]; TrainInfo*t = [[TrainInfo alloc]init]; t.name =resultDic[@"name"]; t.start = resultDic[@"start"]; t.end = resultDic[@"end"]; t.starttime = resultDic[@"starttime"]; t.endtime = resultDic[@"endtime"]; t.mileage = resultDic[@"mileage"]; NSArray*station_listArr = resultDic[@"station_list"]; for (NSDictionary*stationDic in station_listArr) { Station*s = [[Station alloc]init]; s.train_id = stationDic[@"train_id"]; s.arrived_time = stationDic[@"arrived_time"]; s.leave_time = stationDic[@"leave_time"]; s.mileage=stationDic[@"mileage"]; [t.station_list addObject:s]; } return t; } 3、Web Utils,网络端口类 +(TrainInfo *)requstTrainInfoWithTarinCode:(NSString *)code{ NSString*path = [NSString stringWithFormat: @"http://apis.juhe.cn/train/s?name=%@&key=30ad4a93a8cb60dead364ec6de779427",code]; path =[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; // 此内容,修改为上一行 path = [path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString:path]; NSData *data = [NSData dataWithContentsOfURL:url]; NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; TrainInfo *ti = [JsonParser parserTrainInfoWithDic:dic ]; return ti; }
  • 相关阅读:
    Cocos2d-x 3.2编译生成Android程序出错Error running command, return code: 2的解决方法
    利用Theme自定义Activity进入退出动画
    Activity的四种launchMode
    android中设置控件获得焦点
    android 反编译 for mac
    android中libs目录下armeabi和armeabi-v7a的区别
    解决Sublime Text 3中文显示乱码(tab中文方块)问题,sublime tab乱码
    mysql教程
    Failed to load c++ bson extension, using pure JS version
    mongodb导出数据
  • 原文地址:https://www.cnblogs.com/odileye/p/4967302.html
Copyright © 2011-2022 走看看