zoukankan      html  css  js  c++  java
  • 网络工具类

    #import "AFHTTPRequestOperationManager.h"
    
    @interface NetworkTools : AFHTTPRequestOperationManager
    
    + (instancetype)shareNetworkTools;
    @end
    
    #import "NetworkTools.h"
    
    @implementation NetworkTools
    
    + (instancetype)shareNetworkTools
    {
        static id instance;
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            NSURL *url = [NSURL URLWithString:@"http://xxxxxxx/"];
            instance = [[self alloc] initWithBaseURL:url];
        });
        return instance;
    }
    @end
    
    #import "AFHTTPSessionManager.h"
    
    @interface NetworkTools2 : AFHTTPSessionManager
    + (instancetype)shareNetworkTools;
    @end
    
    
    #import "NetworkTools2.h"
    
    @implementation NetworkTools2
    + (instancetype)shareNetworkTools
    {
        static id instance;
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            // 注意: 在指定baseURL的时候, 后面需要加上/
            NSURL *url = [NSURL URLWithString:@"http://xxxxxxxxx/"];
            instance = [[self alloc] initWithBaseURL:url sessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
        });
        return instance;
    }
    @end
    
  • 相关阅读:
    adb
    js百分比
    隐私策略
    JSON.parse&JSON.stringify
    MVC内容backgroundimage: url('')问题
    mvc笔记
    winform路径
    配置
    邮件发送的原理
    如何调试Windows服务
  • 原文地址:https://www.cnblogs.com/yedayi/p/5172871.html
Copyright © 2011-2022 走看看