---
title: "iOS http封装"
author: "374016526"
date: "2015-07-14T16:26:11Z"
tags: ["HTTP", "iOS"]
categories: ["移动开发"]
slug: "ios-http"
draft: false
lastmod: "2015-07-14T16:26:11Z"
id: 2227260
url: "https://374016526.iteye.com/blog/2227260"
---

程序开发避免不了与服务器的交互，这里打包了一个自己写的http交互库。希望可以帮到大家。

 

内置一个basehttp，当我们创建自己的service可以继承实现。

 

KuroAppBaseHttp \*baseHttp = \[\[KuroAppBaseHttp alloc] init];

\[baseHttp setDelegate:self];

\[baseHttp loadHttp:@"http://www.baidu.com" withKey:@"baidu" withData:nil withMethod:KURO\_HTTP\_METHOD\_GET];

 

回调函数:

\- (void)didAppHttpComplate:(id)aObj withKey:(NSString \*)aKey

{

    NSLog(@"akey %@   aobj %@",aKey, aObj);

}

 

\- (void)didAppHttpComplateError:(id)aObj withKey:(NSString \*)aKey

{

    NSLog(@"akey %@   aobj %@",aKey, aObj);

 

}