码迷,mamicode.com
首页 > 其他好文 > 详细

origin connection, 语句对象,结果集,连接对象

时间:2014-06-21 10:41:00      阅读:433      评论:0      收藏:0      [点我收藏+]

标签:des   class   code   http   com   get   

//

//  OriginNetwork.m

//  guligei_AppFactory

//

//  Created by wangyanan on 6/18/14.

//  Copyright (c) 2014 wangyanan. All rights reserved.

//

 

#import "OriginNetwork.h"

 

@interface OriginNetwork()

 

@property(nonatomic,strong) NSURLConnection *connection;

@property(nonatomic,strong) NSMutableURLRequest *request;

@property(nonatomic,strong) NSURLResponse *response;

 

@end

 

@implementation OriginNetwork

 

 

-(IBAction)initwork:(id)sender

{

    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:

                            @"1239806145@qq.com",@"email",

                            @"111111",@"password",nil];

    

    NSMutableData *data = [[NSMutableData alloc] init];

    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];

    [archiver encodeObject:params forKey:@"AAA"];

    [archiver finishEncoding];

    NSString *getUserInfo=[NSString stringWithFormat:@"email=%@&password=%@",@"1239806145@qq.com",@"111111"];

    NSData *dealPostData=[getUserInfo dataUsingEncoding:NSUTF8StringEncoding];

 

    NSURL *url = [NSURL URLWithString:@"http://114.215.107.102/api/login"];

    self.request = [NSMutableURLRequest requestWithURL:url];

    [self.request setTimeoutInterval:60];

    [self.request setHTTPMethod:@"POST"];

    [self.request setHTTPBody:dealPostData];

    NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));

    [self.request setValue:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@", charset] forHTTPHeaderField:@"Content-Type"];

//    [self.request setHTTPBody:data];

 

    

    

    NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];

    NSDictionary *myDictionary = [unarchiver decodeObjectForKey:@"AAA"];

    NSLog(@"%@",myDictionary);

    [unarchiver finishDecoding];

 

 

    

    self.connection = [[NSURLConnection alloc]initWithRequest:self.request delegate:self];

    

}

 

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response

{

    NSLog(@"%@",[response description]);

}

 

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

{

    NSString* newStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    NSLog(@"%@",newStr);

 

}

 

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{

 

}

 

 

@end

origin connection, 语句对象,结果集,连接对象,布布扣,bubuko.com

origin connection, 语句对象,结果集,连接对象

标签:des   class   code   http   com   get   

原文地址:http://www.cnblogs.com/guligei/p/3795081.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!