AFHTTPClient.m不再在AFNetworking中?

编程入门 行业动态 更新时间:2024-10-23 11:23:18
本文介绍了AFHTTPClient.m不再在AFNetworking中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在关注使用AFNetworking的教程( bit.ly/1dbLaPh )。它说要创建一个从AFHTTPClient子类化的新类。此选项不会显示在字段的子类字段中。我检查了AFNetworking文件夹,并且没有AFHTTPClient.m实现文件。此文件是否已重命名为其他内容?

I am following a tutorial (bit.ly/1dbLaPh) that uses AFNetworking. It says to make a new class that is subclassed from AFHTTPClient. This option does not appear in the SubClass Of" field. I checked the AFNetworking folder and there is no AFHTTPClient.m implementation file. Has this file been renamed to something else?

谢谢,

推荐答案

在AFNetworking 2.0中,AFHTTPClient已被AFHTTPRequestOperationManager / AFHTTPSessionManager取代。我建议你参考示例 .Git克隆并在XCode中打开。它应该对你有帮助。这是最新的例子。

In AFNetworking 2.0 the AFHTTPClient has been replaced by AFHTTPRequestOperationManager / AFHTTPSessionManager. I would suggest you to refer the example. Git clone and open in XCode. It should help you. That has the most updated example.

如果你想使用AFHTTPClient即1.x代码。这是 git链接到分支。该pod的规格将是

If you want to use AFHTTPClient i.e 1.x code. Here is the git link to the branch. The pod spec to that would be

pod 'AFNetworking', '~> 1.3.3'

在2.0 AFNetworking中,您可以像这样创建一个单独的客户端。 / p> interface

In 2.0 AFNetworking, you can create a singleton client like this.

@interface AFAppDotNetAPIClient : AFHTTPSessionManager + (instancetype)sharedClient; @end

实施

Implementation

#import "AFAppDotNetAPIClient.h" static NSString * const AFAppDotNetAPIBaseURLString = @"alpha-api.app/"; @implementation AFAppDotNetAPIClient + (instancetype)sharedClient { static AFAppDotNetAPIClient *_sharedClient = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ _sharedClient = [[AFAppDotNetAPIClient alloc] initWithBaseURL:[NSURL URLWithString:AFAppDotNetAPIBaseURLString]]; [_sharedClient setSecurityPolicy:[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey]]; }); return _sharedClient; } @end

更多推荐

AFHTTPClient.m不再在AFNetworking中?

本文发布于:2023-11-14 13:42:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587371.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:AFHTTPClient   AFNetworking

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!