`
SorosW
  • 浏览: 9548 次
  • 来自: 苏州
文章分类
社区版块
存档分类
最新评论

[视频教程] 聚合数据 iOS 项目开发实战:条码查询器

阅读更多

课程背景:

 

聚合数据是一家国内最大的基础数据 API 提供商。免费提供从天气查询、空气质量、地图坐标到金融基金、电商比价、违章查询等各个领域的安全、稳定和高效的数据。开发者可以免费使用聚合数据 API 进行移动 App 的快速开发,免除数据收集、维护等环节,大大降低开发周期及成本。

 

核心内容:


1.条码查询器结构分析。
2.如何将聚合数据 SDK 添加到工程中。
3.模型以及业务类的封装。
4.控制器间的数据传递。
5.tableView 以及 webView 的使用。

 

开发环境:Xcode 6、Mac OS X 10.10

 

 

课程大纲
本课时通过分析条码查询的UI结构和业务逻辑,快速的搭建起条码查询器的业务界面。
本课时介绍聚合数据SDK的下载,以及通过 SDK 使用文档和其中的 Demo,为工程添加 framework,并通过申请聚合数据账号,获取工程需要的 openID 和请求参数。并通过测试代码分析聚合数据的返回数据。
本课时演示如何将第三方框架以及极客学院老师封装好的业务类以及模型添加到工程中并快速使用,并将获取的数据显示在城市选择界面,并实现城市选择界面和首页的数据传递。
本课时分析商品详情界面数据,演示如何使用已经封装好的业务类和模型将电商和超市数据显示到界面上,并给出聚合数据获取数据类型不确定的解决方案。
本课时演示如何添加组头控件以及如何利用Xib快速创建一个 tableView 的 HeaderView ,并将服务器数据利用模型传递到 Xib 内的控件中,其中 imageView 的图片显示用到了 SDWebImage。
本课时演示如何将 UIViewController 中控制器的 view 换成 webView,并利用 webView 展示购买界面,并利用 MBProgressHUD 给出了电商无购买链接时候的UI提示。


课程原型图









课程代码片段

@interface ViewController () <JKCitiesControllerDelegate>

@property (nonatomic, copy) NSString *cityID;
@property (weak, nonatomic) IBOutlet UITextField *inputTextField;

@end

@implementation ViewController
- (IBAction)chaxunOnClick {
    
    if (!self.inputTextField.hasText) {
        [MBProgressHUD showError:@"请输入商品条码!"];
        return;
    }
    
    JKGoodsController *gVC = [[JKGoodsController alloc] init];
    BarCodeParam *param = [[BarCodeParam alloc] init];
    param.cityid = self.cityID;
#warning  实际开发这里传入的是文本输入看中的字符串
    param.barcode = @"6923450601822";
    
    //param.barcode = self.inputTextField.text;
    
    gVC.barCodeParam = param;
    [self.navigationController pushViewController:gVC animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [[JHOpenidSupplier shareSupplier] registerJuheAPIByOpenId:JHOpenID];
    
    self.title = @"条码查询器";
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"上海" style:UIBarButtonItemStyleDone target:self action:@selector(openCitiesVC)];
    self.cityID = @"1";
    
    
//    
//    [self test:kJHAPIS_EX_JHBAR_CITY                parameters:@{ @"pname":@"com.jikexueyuan.JKJHBarCode" ,@"v":@"2.0"}];
    [self test:kJHAPIS_EX_JHBAR_BAR                 parameters:@{ @"barcode": @"6923450601822" ,@"cityid":@"1" , @"pname":@"com.jikexueyuan.JKJHBarCode" ,@"v":@"2.0" }];
//    [self test:kJHAPIS_EX_JHBAR_BUY                 parameters:@{  @"barcode":@"6923450601822" , @"dsid":@"5" ,@"pname":@"com.jikexueyuan.JKJHBarCode" ,@"v":@"2.0"}];
}
- (void)test:(NSString *)path  parameters:(NSDictionary *)parameters{
    
    JuheAPI *juheapi = [JuheAPI shareJuheApi];
    [juheapi executeWorkWithAPI:path
                     parameters:parameters
                        success:^(id responseObject){
                            if ([[parameters objectForKey:@"dtype"] isEqualToString:@"xml"]) {
                                NSLog(@"***xml*** \n %@", responseObject);
                            }else{
                                int error_code = [[responseObject objectForKey:@"error_code"] intValue];
                                if (!error_code) {
                                    NSLog(@" %@", responseObject);
                                }else{
                                    NSLog(@" %@", responseObject);
                                }
                            }
                            
                        } failure:^(NSError *error) {
                            NSLog(@"error:   %@",error.description);
                        }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)openCitiesVC
{
    JKCitiesController *cVC = [[JKCitiesController alloc] init];
    cVC.delegate = self;
    [self.navigationController pushViewController:cVC animated:YES];
}

#pragma mark - JKCitiesControllerDelegate

- (void)backToMainVcWithCity:(City *)city
{
    // 1.替换右上角中按钮的 title
    self.navigationItem.rightBarButtonItem.title = city.cityname;
    
    // 2.传递给主控制器一个 cityid 的数据
    self.cityID = [NSString stringWithFormat:@"%@", city.cityid];
    
}


课程地址http://www.jikexueyuan.com/course/324.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics