MKNetworkKit.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // MKNetworkKit.h
  3. // MKNetworkKit
  4. //
  5. // Created by Mugunth Kumar (@mugunthkumar) on 11/11/11.
  6. // Copyright (C) 2011-2020 by Steinlogic Consulting and Training Pte Ltd
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. #ifndef MKNetworkKit_MKNetworkKit_h
  25. #define MKNetworkKit_MKNetworkKit_h
  26. #ifndef __IPHONE_4_0
  27. #error "MKNetworkKit uses features only available in iOS SDK 4.0 and later."
  28. #endif
  29. #if TARGET_OS_IPHONE
  30. #import <Foundation/Foundation.h>
  31. #import <UIKit/UIKit.h>
  32. #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000
  33. #define DO_GCD_RETAIN_RELEASE 0
  34. #else
  35. #define DO_GCD_RETAIN_RELEASE 1
  36. #endif
  37. #elif TARGET_OS_MAC
  38. #import <Cocoa/Cocoa.h>
  39. #import <AppKit/AppKit.h>
  40. #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
  41. #define DO_GCD_RETAIN_RELEASE 0
  42. #else
  43. #define DO_GCD_RETAIN_RELEASE 1
  44. #endif
  45. #endif
  46. #ifdef DEBUG
  47. # define DLog(fmt, ...) {NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);}
  48. # define ELog(err) {if(err) DLog(@"%@", err)}
  49. #else
  50. # define DLog(...)
  51. # define ELog(err)
  52. #endif
  53. // ALog always displays output regardless of the DEBUG setting
  54. #define ALog(fmt, ...) {NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);};
  55. #import "NSString+MKNetworkKitAdditions.h"
  56. #import "NSDictionary+RequestEncoding.h"
  57. #import "NSDate+RFC1123.h"
  58. #import "NSData+Base64.h"
  59. //#import "Categories/NSString+MKNetworkKitAdditions.h"
  60. //#import "Categories/NSDictionary+RequestEncoding.h"
  61. //#import "Categories/NSDate+RFC1123.h"
  62. //#import "Categories/NSData+Base64.h"
  63. #if TARGET_OS_IPHONE
  64. #import "UIAlertView+MKNetworkKitAdditions.h"
  65. #elif TARGET_OS_MAC
  66. #import "NSAlert+MKNetworkKitAdditions.h"
  67. //#import "Categories/UIAlertView+MKNetworkKitAdditions.h"
  68. //#elif TARGET_OS_MAC
  69. //#import "Categories/NSAlert+MKNetworkKitAdditions.h"
  70. #endif
  71. #import "Reachability/Reachability.h"
  72. #import "MKNetworkOperation.h"
  73. #import "MKNetworkEngine.h"
  74. #define kMKNetworkEngineOperationCountChanged @"kMKNetworkEngineOperationCountChanged"
  75. #define MKNETWORKCACHE_DEFAULT_COST 10
  76. #define MKNETWORKCACHE_DEFAULT_DIRECTORY @"MKNetworkKitCache"
  77. #define kMKNetworkKitDefaultCacheDuration 60 // 1 minute
  78. #define kMKNetworkKitDefaultImageHeadRequestDuration 3600*24*1 // 1 day (HEAD requests with eTag are sent only after expiry of this. Not that these are not RFC compliant, but needed for performance tuning)
  79. #define kMKNetworkKitDefaultImageCacheDuration 3600*24*7 // 1 day
  80. // if your server takes longer than 30 seconds to provide real data,
  81. // you should hire a better server developer.
  82. // on iOS (or any mobile device), 30 seconds is already considered high.
  83. #define kMKNetworkKitRequestTimeOutInSeconds 30
  84. #endif