接上篇文章 更新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