Skip to content
This repository has been archived by the owner on Aug 13, 2018. It is now read-only.

1、修改上传文件路径读取错误 #65

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions PPNetworkHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
1D5FA55A1F0DE16900CD5B57 /* PPInterfacedConst.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D5FA5591F0DE16900CD5B57 /* PPInterfacedConst.m */; };
22142E2B1D5E096E00EE2C40 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 22142E2A1D5E096E00EE2C40 /* main.m */; };
22142E2E1D5E096E00EE2C40 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 22142E2D1D5E096E00EE2C40 /* AppDelegate.m */; };
22142E311D5E096E00EE2C40 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 22142E301D5E096E00EE2C40 /* ViewController.m */; };
Expand Down Expand Up @@ -53,7 +52,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1D5FA5591F0DE16900CD5B57 /* PPInterfacedConst.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPInterfacedConst.m; sourceTree = "<group>"; };
22142E261D5E096E00EE2C40 /* PPNetworkHelper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PPNetworkHelper.app; sourceTree = BUILT_PRODUCTS_DIR; };
22142E2A1D5E096E00EE2C40 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
22142E2C1D5E096E00EE2C40 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -115,7 +113,6 @@
22BEDC481D64B67100A72128 /* PPNetworkCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPNetworkCache.m; sourceTree = "<group>"; };
22BEDC491D64B67100A72128 /* PPNetworkHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPNetworkHelper.h; sourceTree = "<group>"; };
22BEDC4A1D64B67100A72128 /* PPNetworkHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPNetworkHelper.m; sourceTree = "<group>"; };
35639C3A1E9B616200FEA954 /* PPInterfacedConst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPInterfacedConst.h; sourceTree = "<group>"; };
35639C3D1E9B630C00FEA954 /* PPHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PPHTTPRequest.h; sourceTree = "<group>"; };
35639C3E1E9B630C00FEA954 /* PPHTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PPHTTPRequest.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -290,8 +287,6 @@
35639C401E9B634900FEA954 /* PPHTTPRequestLayer */ = {
isa = PBXGroup;
children = (
35639C3A1E9B616200FEA954 /* PPInterfacedConst.h */,
1D5FA5591F0DE16900CD5B57 /* PPInterfacedConst.m */,
35639C3D1E9B630C00FEA954 /* PPHTTPRequest.h */,
35639C3E1E9B630C00FEA954 /* PPHTTPRequest.m */,
);
Expand Down Expand Up @@ -347,7 +342,7 @@
TargetAttributes = {
22142E251D5E096E00EE2C40 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = YY4NTQ7LN8;
DevelopmentTeam = 77LD5G9JF9;
};
22142E3E1D5E096E00EE2C40 = {
CreatedOnToolsVersion = 7.3.1;
Expand Down Expand Up @@ -411,7 +406,6 @@
22BEDC4C1D64B67100A72128 /* PPNetworkHelper.m in Sources */,
22BEDC4B1D64B67100A72128 /* PPNetworkCache.m in Sources */,
224086591D7074EA007E4E15 /* AFURLSessionManager.m in Sources */,
1D5FA55A1F0DE16900CD5B57 /* PPInterfacedConst.m in Sources */,
224086581D7074EA007E4E15 /* AFURLResponseSerialization.m in Sources */,
224086611D7074EA007E4E15 /* UIImageView+AFNetworking.m in Sources */,
224086711D7074F5007E4E15 /* YYMemoryCache.m in Sources */,
Expand Down Expand Up @@ -562,7 +556,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = YY4NTQ7LN8;
DEVELOPMENT_TEAM = 77LD5G9JF9;
INFOPLIST_FILE = PPNetworkHelper/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -578,7 +572,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEVELOPMENT_TEAM = YY4NTQ7LN8;
DEVELOPMENT_TEAM = 77LD5G9JF9;
INFOPLIST_FILE = PPNetworkHelper/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
scope = "0"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "PPNetworkHelper/PPNetworkHelper/PPNetworkHelper.m"
timestampString = "566450924.146212"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "22"
endingLineNumber = "22"
landmarkName = "NetworkToolsProxy"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>PPNetworkHelper.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>PPNetworkHelper.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
14 changes: 7 additions & 7 deletions PPNetworkHelper/PPHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@
//

#import "PPHTTPRequest.h"
#import "PPInterfacedConst.h"
#import "PPNetworkHelper.h"

@implementation PPHTTPRequest
/** 登录*/
+ (NSURLSessionTask *)getLoginWithParameters:(id)parameters success:(PPRequestSuccess)success failure:(PPRequestFailure)failure
{
// 将请求前缀与请求路径拼接成一个完整的URL
NSString *url = [NSString stringWithFormat:@"%@%@",kApiPrefix,kLogin];
NSString *url = [NSString stringWithFormat:@"%@%@",@"https://www.baidu.com",@"/login"];
return [self requestWithURL:url parameters:parameters success:success failure:failure];
}
/** 退出*/
+ (NSURLSessionTask *)getExitWithParameters:(id)parameters success:(PPRequestSuccess)success failure:(PPRequestFailure)failure
{
NSString *url = [NSString stringWithFormat:@"%@%@",kApiPrefix,kExit];
NSString *url = [NSString stringWithFormat:@"%@%@",@"https://www.baidu.com",@"/exit"];
return [self requestWithURL:url parameters:parameters success:success failure:failure];
}

Expand All @@ -37,19 +36,20 @@ + (NSURLSessionTask *)getExitWithParameters:(id)parameters success:(PPRequestSuc
+ (NSURLSessionTask *)requestWithURL:(NSString *)URL parameters:(NSDictionary *)parameter success:(PPRequestSuccess)success failure:(PPRequestFailure)failure
{
// 在请求之前你可以统一配置你请求的相关参数 ,设置请求头, 请求参数的格式, 返回数据的格式....这样你就不需要每次请求都要设置一遍相关参数
// 设置请求头
[PPNetworkHelper setValue:@"9" forHTTPHeaderField:@"fromType"];

[PPNetworkHelper setResponseSerializer:PPResponseSerializerHTTP];
// 设置请求头
[PPNetworkHelper setValue:@"v1.0.0" forHTTPHeaderField:@"api-version"];
// 发起请求
return [PPNetworkHelper POST:URL parameters:parameter success:^(id responseObject) {

return [PPNetworkHelper request:POST URLString:URL parameters:parameter success:^(id responseObject) {
// 在这里你可以根据项目自定义其他一些重复操作,比如加载页面时候的等待效果, 提醒弹窗....
success(responseObject);

} failure:^(NSError *error) {
// 同上
failure(error);
}];

}

@end
32 changes: 0 additions & 32 deletions PPNetworkHelper/PPInterfacedConst.h

This file was deleted.

25 changes: 0 additions & 25 deletions PPNetworkHelper/PPInterfacedConst.m

This file was deleted.

106 changes: 44 additions & 62 deletions PPNetworkHelper/PPNetworkHelper/PPNetworkHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "PPNetworkCache.h"

#import "AFNetworking.h"
#ifndef kIsNetwork
#define kIsNetwork [PPNetworkHelper isNetwork] // 一次性判断是否有网的宏
#endif
Expand All @@ -41,6 +41,15 @@
#ifndef kIsWiFiNetwork
#define kIsWiFiNetwork [PPNetworkHelper isWiFiNetwork] // 一次性判断是否为WiFi网络的宏
#endif
//请求方式
typedef enum: NSInteger{
GET,//GET请求
POST,
DELETE,
HEAD,
PATCH,
PUT,
}PPRequestMethod;

typedef NS_ENUM(NSUInteger, PPNetworkStatusType) {
/// 未知网络
Expand Down Expand Up @@ -82,10 +91,11 @@ typedef void (^PPHttpProgress)(NSProgress *progress);
/// 网络状态的Block
typedef void(^PPNetworkStatus)(PPNetworkStatusType status);

@class AFHTTPSessionManager;
@interface PPNetworkHelper : NSObject
@interface PPNetworkHelper : AFHTTPSessionManager

/// 有网YES, 无网:NO
/**
有网YES, 无网:NO
*/
+ (BOOL)isNetwork;

/// 手机网络:YES, 反之:NO
Expand All @@ -94,15 +104,9 @@ typedef void(^PPNetworkStatus)(PPNetworkStatusType status);
/// WiFi网络:YES, 反之:NO
+ (BOOL)isWiFiNetwork;

/// 取消所有HTTP请求
+ (void)cancelAllRequest;

/// 实时获取网络状态,通过Block回调实时获取(此方法可多次调用)
+ (void)networkStatusWithBlock:(PPNetworkStatus)networkStatus;

/// 取消指定URL的HTTP请求
+ (void)cancelRequestWithURL:(NSString *)URL;

/// 开启日志打印 (Debug级别)
+ (void)openLog;

Expand All @@ -111,68 +115,46 @@ typedef void(^PPNetworkStatus)(PPNetworkStatusType status);


/**
* GET请求,无缓存
*
* @param URL 请求地址
* @param parameters 请求参数
* @param success 请求成功的回调
* @param failure 请求失败的回调
*
* @return 返回的对象可取消请求,调用cancel方法
取消所有HTTP请求
*/
+ (__kindof NSURLSessionTask *)GET:(NSString *)URL
parameters:(id)parameters
success:(PPHttpRequestSuccess)success
failure:(PPHttpRequestFailed)failure;
+ (void)cancelAllRequest;

/**
* GET请求,自动缓存
*
* @param URL 请求地址
* @param parameters 请求参数
* @param responseCache 缓存数据的回调
* @param success 请求成功的回调
* @param failure 请求失败的回调
*
* @return 返回的对象可取消请求,调用cancel方法
取消指定URL的HTTP请求
*/
+ (__kindof NSURLSessionTask *)GET:(NSString *)URL
parameters:(id)parameters
responseCache:(PPHttpRequestCache)responseCache
success:(PPHttpRequestSuccess)success
failure:(PPHttpRequestFailed)failure;
+ (void)cancelRequestWithURL:(NSString *)URL;


/**
* POST请求,无缓存
*
* @param URL 请求地址
* @param parameters 请求参数
* @param success 请求成功的回调
* @param failure 请求失败的回调
*
* @return 返回的对象可取消请求,调用cancel方法
网络请求,有缓存

@param method 请求方式 GET/POST(可根据枚举自行选择多种请求方式)
@param URLString 请求地址
@param parameters 请求参数
@param responseCache 缓存数据的回调
@param success 请求成功的回调
@param failure 请求失败的回调
@return 返回的对象可取消请求,调用cancel方法
*/
+ (__kindof NSURLSessionTask *)POST:(NSString *)URL
parameters:(id)parameters
success:(PPHttpRequestSuccess)success
failure:(PPHttpRequestFailed)failure;
+(NSURLSessionTask *)request:(PPRequestMethod)method URLString:(NSString *)URLString parameters:(id)parameters
responseCache:(PPHttpRequestCache)responseCache
success:(PPHttpRequestSuccess)success
failure:(PPHttpRequestFailed)failure;


/**
* POST请求,自动缓存
*
* @param URL 请求地址
* @param parameters 请求参数
* @param responseCache 缓存数据的回调
* @param success 请求成功的回调
* @param failure 请求失败的回调
*
* @return 返回的对象可取消请求,调用cancel方法
网络请求,无缓存

@param method 请求方式 GET/POST(可根据枚举自行选择多种请求方式)
@param URLString 请求地址
@param parameters 请求参数
@param success 请求成功的回调
@param failure 请求失败的回调
@return 返回的对象可取消请求,调用cancel方法
*/
+ (__kindof NSURLSessionTask *)POST:(NSString *)URL
parameters:(id)parameters
responseCache:(PPHttpRequestCache)responseCache
success:(PPHttpRequestSuccess)success
failure:(PPHttpRequestFailed)failure;
+(NSURLSessionTask *)request:(PPRequestMethod)method URLString:(NSString *)URLString parameters:(id)parameters
success:(PPHttpRequestSuccess)success
failure:(PPHttpRequestFailed)failure;

/**
* 上传文件
Expand Down
Loading