IOS 简单粗暴的方式 实现H5App

接上篇文章 更新IOS 版本
话不多少直接上代码

1、主ViewController
ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController


@end

ViewController.m


#import "ViewController.h"
#import "AppDelegate.h"
#import "ViewHomePageController.h"
#import <sqlite3.h>
#import "Person.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textCodeId;

@end

@implementation ViewController

- (void)viewDidLoad {
   
    [super viewDidLoad];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    [self performSelectorOnMainThread:@selector(selectLocalId:) withObject:nil waitUntilDone:NO];
}

- (void)didReceiveMemoryWarning {
   
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)successDoAction:(NSDictionary*) dict{
   
        NSLog(@"%@",dict);
        NSLog(@"网址为");
        NSDictionary *dictItem =[dict valueForKey:@"Code"];
        NSLog(@"%@:", [dictItem valueForKey:@"addvalue"] );
    if([[dict valueForKey:@"respState"] isEqualToString:@"00"]){
   
//        NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(createLocalId:) object:[dictItem valueForKey:@"addvalue"]];
//        [thread setName:@"post新的线程"];
//        [thread start];
        [self performSelectorOnMainThread:@selector(createLocalId:) withObject:[dictItem valueForKey:@"addvalue"] waitUntilDone:NO];
    }else{
   
//            提示框
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"激活失败" message:[dict valueForKey:@"respMessage"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                [alert show];
        return;
    }
}
-(void)postHttp:(NSArray*) codeId{
   
    
    //对请求路径的说明
    //http://120.25.226.186:32812/login
    //协议头+主机地址+接口名称
    //协议头(http://)+主机地址(120.25.226.186:32812)+接口名称(login)
    //POST请求需要修改请求方法为POST,并把参数转换为二进制数据设置为请求体
    
    //1.创建会话对象
    NSURLSession *session = [NSURLSession sharedSession];
    
    //2.确立请求路径
    NSURL *url = [NSURL URLWithString:@"你自己的服务接口"];
    
    //3.创建可变的请求对象
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    
    //4.修改请求方法为POST
    request.HTTPMethod = @"POST";
    NSString *data =[[NSString alloc] initWithFormat:@"code=%@&type=JSON", codeId ];
    NSLog(@"___________参数%@",data);
    //5.设置请求体
    request.HTTPBody = [data dataUsingEncoding
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值