MKNetworkKit.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #elif TARGET_OS_MAC
  33. #import <Cocoa/Cocoa.h>
  34. #import <AppKit/AppKit.h>
  35. #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
  36. #define DO_GCD_RETAIN_RELEASE 0
  37. #else
  38. #define DO_GCD_RETAIN_RELEASE 1
  39. #endif
  40. #endif
  41. #ifdef DEBUG
  42. # define DLog(fmt, ...) {NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);}
  43. # define ELog(err) {if(err) DLog(@"%@", err)}
  44. #else
  45. # define DLog(...)
  46. # define ELog(err)
  47. #endif
  48. // ALog always displays output regardless of the DEBUG setting
  49. #define ALog(fmt, ...) {NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);};
  50. #import "Categories/NSString+MKNetworkKitAdditions.h"
  51. #import "Categories/NSDictionary+RequestEncoding.h"
  52. #import "Categories/NSDate+RFC1123.h"
  53. #import "Categories/NSData+MKBase64.h"
  54. #if TARGET_OS_IPHONE
  55. #import "Categories/UIAlertView+MKNetworkKitAdditions.h"
  56. #elif TARGET_OS_MAC
  57. #import "Categories/NSAlert+MKNetworkKitAdditions.h"
  58. #endif
  59. #import "Reachability/Reachability.h"
  60. #import "MKNetworkOperation.h"
  61. #import "MKNetworkEngine.h"
  62. #define kMKNetworkEngineOperationCountChanged @"kMKNetworkEngineOperationCountChanged"
  63. #define MKNETWORKCACHE_DEFAULT_COST 10
  64. #define MKNETWORKCACHE_DEFAULT_DIRECTORY @"MKNetworkKitCache"
  65. #define kMKNetworkKitDefaultCacheDuration 60 // 1 minute
  66. #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)
  67. #define kMKNetworkKitDefaultImageCacheDuration 3600*24*7 // 1 day
  68. // if your server takes longer than 30 seconds to provide real data,
  69. // you should hire a better server developer.
  70. // on iOS (or any mobile device), 30 seconds is already considered high.
  71. #define kMKNetworkKitRequestTimeOutInSeconds 30
  72. #endif