AFNetworking 2.0 當(dāng)Deployment Target 低于6.0時(shí),AFURLConnectionOperation.h,AFURLSessionManager.h
@property (nonatomic, strong) dispatch_queue_t completionQueue;
由于sdk低于6.0時(shí),dispatch_queue_t ARC沒(méi)有托管,出現(xiàn)提示錯(cuò)誤
Property with 'retain (or strong)' attribute must be of object type
修改為
#if OS_OBJECT_USE_OBJC
@property (nonatomic, strong) dispatch_queue_t completionQueue;
#else
@property (nonatomic, assign) dispatch_queue_t completionQueue;
#endif
使用示例:(不使用官方的自帶的json和xml解析,返回NSData)
1.0兼容版
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer= [AFHTTPResponseSerializer serializer];
[manager GET:@"http://www.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
2.0
AFHTTPSessionManager *httpSessionManager =[AFHTTPSessionManager manager];
httpSessionManager.responseSerializer= [AFHTTPResponseSerializer serializer];
NSURLSessionDataTask*task = [httpSessionManager GET:@"http://www.com" parameters:nil success:^(NSURLSessionDataTask *task, id responseObject)
{
} failure:^(NSURLSessionDataTask *task, NSError *error)
{
}];
IOS SDK 4.3以上兼容版,需要使用AFNetworking-0.10.x版本
AFHTTPClient *httpClient = [AFHTTPClient clientWithBaseURL:nil];
[httpClient getPath:@"http://www.com" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)
{
} failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
}];
文章題目:AFNetworking2.0使用-創(chuàng)新互聯(lián)
分享網(wǎng)址:http://sd-ha.com/article14/dceege.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、用戶(hù)體驗(yàn)、自適應(yīng)網(wǎng)站、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容