NetworkManager.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // NetworkManager.h
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/4/6.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. /**
  10. * 网络请求类型
  11. */
  12. typedef NS_ENUM(NSUInteger,HttpRequestType) {
  13. /**
  14. * post请求
  15. */
  16. HttpRequestTypePost = 0,
  17. /**
  18. * get请求
  19. */
  20. HttpRequestTypeGet
  21. };
  22. typedef void (^GetDataHandler)(NSDictionary *successDic, NSString *failureStr);
  23. @interface NetworkManager : NSObject
  24. //判断网络是否连接(已改为固定返回YES)
  25. +(BOOL) connectedToNetWork;
  26. /**
  27. post/get请求
  28. @param method 接口名
  29. @param parameters 请求体
  30. @param type post = 0,get = 1
  31. @param handler 结果回调(数据正常返回successDic;数据为空,数据解析失败,请求失败都返回failureStr)
  32. */
  33. + (void)requestWithMethod:(NSString *)method
  34. parameters:(id)parameters
  35. type:(HttpRequestType)type
  36. handler:(GetDataHandler)handler;
  37. //生成带有签名的URL
  38. + (NSString *)getURLWithDict:(NSDictionary *)dic urlPre:(NSString *)urlP;
  39. @end