diff --git a/.gitignore b/.gitignore index b802c5a..119d46f 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ xcuserdata *.moved-aside *.xcuserstate *.xcscmblueprint +.xcworkspacedata ## Obj-C/Swift specific *.hmap diff --git "a/BATInterview/BAT\351\235\242\350\257\225\346\214\207\345\215\227 PPT.pdf" "b/BATInterview/BAT\351\235\242\350\257\225\346\214\207\345\215\227 PPT.pdf" new file mode 100644 index 0000000..5a5179a Binary files /dev/null and "b/BATInterview/BAT\351\235\242\350\257\225\346\214\207\345\215\227 PPT.pdf" differ diff --git "a/BATInterview/BAT\351\235\242\350\257\225\346\214\207\345\215\227.pdf" "b/BATInterview/BAT\351\235\242\350\257\225\346\214\207\345\215\227.pdf" new file mode 100644 index 0000000..2a2d3bc Binary files /dev/null and "b/BATInterview/BAT\351\235\242\350\257\225\346\214\207\345\215\227.pdf" differ diff --git "a/BATInterview/\345\274\240\346\230\237\345\256\207-\344\270\234\345\214\227\345\244\247\345\255\246-iOS\345\274\200\345\217\221.pdf" "b/BATInterview/\345\274\240\346\230\237\345\256\207-\344\270\234\345\214\227\345\244\247\345\255\246-iOS\345\274\200\345\217\221.pdf" new file mode 100644 index 0000000..5c7e131 Binary files /dev/null and "b/BATInterview/\345\274\240\346\230\237\345\256\207-\344\270\234\345\214\227\345\244\247\345\255\246-iOS\345\274\200\345\217\221.pdf" differ diff --git a/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne.xcodeproj/project.pbxproj b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b8c9d43 --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne.xcodeproj/project.pbxproj @@ -0,0 +1,513 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9B0B718C1E20DD5A005D11BA /* BSStaticLibraryOne.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B718B1E20DD5A005D11BA /* BSStaticLibraryOne.m */; }; + 9B0B718D1E20DD5A005D11BA /* BSStaticLibraryOne.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9B0B718A1E20DD5A005D11BA /* BSStaticLibraryOne.h */; }; + 9B0B71951E20DE7B005D11BA /* BSStaticLibraryOne+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B71941E20DE7B005D11BA /* BSStaticLibraryOne+Extension.m */; }; + 9B0B71BC1E20E3A0005D11BA /* BSStaticLibraryOne.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0B718A1E20DD5A005D11BA /* BSStaticLibraryOne.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9B0B71BD1E20E3A0005D11BA /* BSStaticLibraryOne+Extension.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0B71931E20DE7B005D11BA /* BSStaticLibraryOne+Extension.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9B53E8551E223564005F74C6 /* BSStaticLibraryTwo.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B53E8541E223564005F74C6 /* BSStaticLibraryTwo.m */; }; + 9B53E8561E223564005F74C6 /* BSStaticLibraryTwo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9B53E8531E223564005F74C6 /* BSStaticLibraryTwo.h */; }; + 9B53E85B1E224C62005F74C6 /* BSStaticLibraryTwo.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B53E8531E223564005F74C6 /* BSStaticLibraryTwo.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9B53E8641E226EA4005F74C6 /* Pod.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B53E8631E226EA4005F74C6 /* Pod.m */; }; + 9B53E8651E226EA4005F74C6 /* Pod.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9B53E8621E226EA4005F74C6 /* Pod.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 9B53E8691E226EAD005F74C6 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9B0B717F1E20DD5A005D11BA /* Project object */; + proxyType = 1; + remoteGlobalIDString = 9B0B71861E20DD5A005D11BA; + remoteInfo = BSStaticLibraryOne; + }; + 9B53E86B1E226EAD005F74C6 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 9B0B717F1E20DD5A005D11BA /* Project object */; + proxyType = 1; + remoteGlobalIDString = 9B53E8501E223564005F74C6; + remoteInfo = BSStaticLibraryTwo; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9B0B71851E20DD5A005D11BA /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + 9B0B718D1E20DD5A005D11BA /* BSStaticLibraryOne.h in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9B53E84F1E223564005F74C6 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + 9B53E8561E223564005F74C6 /* BSStaticLibraryTwo.h in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9B53E85E1E226EA4005F74C6 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + 9B53E8651E226EA4005F74C6 /* Pod.h in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 9B0B71871E20DD5A005D11BA /* libBSStaticLibraryOne.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBSStaticLibraryOne.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 9B0B718A1E20DD5A005D11BA /* BSStaticLibraryOne.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSStaticLibraryOne.h; sourceTree = ""; }; + 9B0B718B1E20DD5A005D11BA /* BSStaticLibraryOne.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSStaticLibraryOne.m; sourceTree = ""; }; + 9B0B71931E20DE7B005D11BA /* BSStaticLibraryOne+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BSStaticLibraryOne+Extension.h"; sourceTree = ""; }; + 9B0B71941E20DE7B005D11BA /* BSStaticLibraryOne+Extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BSStaticLibraryOne+Extension.m"; sourceTree = ""; }; + 9B53E8511E223564005F74C6 /* libBSStaticLibraryTwo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBSStaticLibraryTwo.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 9B53E8531E223564005F74C6 /* BSStaticLibraryTwo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSStaticLibraryTwo.h; sourceTree = ""; }; + 9B53E8541E223564005F74C6 /* BSStaticLibraryTwo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSStaticLibraryTwo.m; sourceTree = ""; }; + 9B53E8601E226EA4005F74C6 /* libPod.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPod.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 9B53E8621E226EA4005F74C6 /* Pod.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Pod.h; sourceTree = ""; }; + 9B53E8631E226EA4005F74C6 /* Pod.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Pod.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9B0B71841E20DD5A005D11BA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9B53E84E1E223564005F74C6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9B53E85D1E226EA4005F74C6 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9B0B717E1E20DD5A005D11BA = { + isa = PBXGroup; + children = ( + 9B0B71891E20DD5A005D11BA /* BSStaticLibraryOne */, + 9B53E8521E223564005F74C6 /* BSStaticLibraryTwo */, + 9B53E8611E226EA4005F74C6 /* Pod */, + 9B0B71881E20DD5A005D11BA /* Products */, + ); + sourceTree = ""; + }; + 9B0B71881E20DD5A005D11BA /* Products */ = { + isa = PBXGroup; + children = ( + 9B0B71871E20DD5A005D11BA /* libBSStaticLibraryOne.a */, + 9B53E8511E223564005F74C6 /* libBSStaticLibraryTwo.a */, + 9B53E8601E226EA4005F74C6 /* libPod.a */, + ); + name = Products; + sourceTree = ""; + }; + 9B0B71891E20DD5A005D11BA /* BSStaticLibraryOne */ = { + isa = PBXGroup; + children = ( + 9B0B718A1E20DD5A005D11BA /* BSStaticLibraryOne.h */, + 9B0B718B1E20DD5A005D11BA /* BSStaticLibraryOne.m */, + 9B0B71931E20DE7B005D11BA /* BSStaticLibraryOne+Extension.h */, + 9B0B71941E20DE7B005D11BA /* BSStaticLibraryOne+Extension.m */, + ); + path = BSStaticLibraryOne; + sourceTree = ""; + }; + 9B53E8521E223564005F74C6 /* BSStaticLibraryTwo */ = { + isa = PBXGroup; + children = ( + 9B53E8531E223564005F74C6 /* BSStaticLibraryTwo.h */, + 9B53E8541E223564005F74C6 /* BSStaticLibraryTwo.m */, + ); + path = BSStaticLibraryTwo; + sourceTree = ""; + }; + 9B53E8611E226EA4005F74C6 /* Pod */ = { + isa = PBXGroup; + children = ( + 9B53E8621E226EA4005F74C6 /* Pod.h */, + 9B53E8631E226EA4005F74C6 /* Pod.m */, + ); + path = Pod; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 9B0B71BB1E20E374005D11BA /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B0B71BC1E20E3A0005D11BA /* BSStaticLibraryOne.h in Headers */, + 9B0B71BD1E20E3A0005D11BA /* BSStaticLibraryOne+Extension.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9B53E85A1E224C5B005F74C6 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B53E85B1E224C62005F74C6 /* BSStaticLibraryTwo.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 9B0B71861E20DD5A005D11BA /* BSStaticLibraryOne */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9B0B71901E20DD5A005D11BA /* Build configuration list for PBXNativeTarget "BSStaticLibraryOne" */; + buildPhases = ( + 9B0B71831E20DD5A005D11BA /* Sources */, + 9B0B71841E20DD5A005D11BA /* Frameworks */, + 9B0B71851E20DD5A005D11BA /* CopyFiles */, + 9B0B71BB1E20E374005D11BA /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BSStaticLibraryOne; + productName = BSStaticLibraryOne; + productReference = 9B0B71871E20DD5A005D11BA /* libBSStaticLibraryOne.a */; + productType = "com.apple.product-type.library.static"; + }; + 9B53E8501E223564005F74C6 /* BSStaticLibraryTwo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9B53E8571E223564005F74C6 /* Build configuration list for PBXNativeTarget "BSStaticLibraryTwo" */; + buildPhases = ( + 9B53E84D1E223564005F74C6 /* Sources */, + 9B53E84E1E223564005F74C6 /* Frameworks */, + 9B53E84F1E223564005F74C6 /* CopyFiles */, + 9B53E85A1E224C5B005F74C6 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BSStaticLibraryTwo; + productName = BSStaticLibraryTwo; + productReference = 9B53E8511E223564005F74C6 /* libBSStaticLibraryTwo.a */; + productType = "com.apple.product-type.library.static"; + }; + 9B53E85F1E226EA4005F74C6 /* Pod */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9B53E8661E226EA4005F74C6 /* Build configuration list for PBXNativeTarget "Pod" */; + buildPhases = ( + 9B53E85C1E226EA4005F74C6 /* Sources */, + 9B53E85D1E226EA4005F74C6 /* Frameworks */, + 9B53E85E1E226EA4005F74C6 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 9B53E86A1E226EAD005F74C6 /* PBXTargetDependency */, + 9B53E86C1E226EAD005F74C6 /* PBXTargetDependency */, + ); + name = Pod; + productName = Pod; + productReference = 9B53E8601E226EA4005F74C6 /* libPod.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9B0B717F1E20DD5A005D11BA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = bestswifter; + TargetAttributes = { + 9B0B71861E20DD5A005D11BA = { + CreatedOnToolsVersion = 8.2; + ProvisioningStyle = Automatic; + }; + 9B53E8501E223564005F74C6 = { + CreatedOnToolsVersion = 8.2; + ProvisioningStyle = Automatic; + }; + 9B53E85F1E226EA4005F74C6 = { + CreatedOnToolsVersion = 8.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 9B0B71821E20DD5A005D11BA /* Build configuration list for PBXProject "BSStaticLibraryOne" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 9B0B717E1E20DD5A005D11BA; + productRefGroup = 9B0B71881E20DD5A005D11BA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9B0B71861E20DD5A005D11BA /* BSStaticLibraryOne */, + 9B53E8501E223564005F74C6 /* BSStaticLibraryTwo */, + 9B53E85F1E226EA4005F74C6 /* Pod */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 9B0B71831E20DD5A005D11BA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B0B718C1E20DD5A005D11BA /* BSStaticLibraryOne.m in Sources */, + 9B0B71951E20DE7B005D11BA /* BSStaticLibraryOne+Extension.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9B53E84D1E223564005F74C6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B53E8551E223564005F74C6 /* BSStaticLibraryTwo.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9B53E85C1E226EA4005F74C6 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B53E8641E226EA4005F74C6 /* Pod.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 9B53E86A1E226EAD005F74C6 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 9B0B71861E20DD5A005D11BA /* BSStaticLibraryOne */; + targetProxy = 9B53E8691E226EAD005F74C6 /* PBXContainerItemProxy */; + }; + 9B53E86C1E226EAD005F74C6 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 9B53E8501E223564005F74C6 /* BSStaticLibraryTwo */; + targetProxy = 9B53E86B1E226EAD005F74C6 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 9B0B718E1E20DD5A005D11BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 9B0B718F1E20DD5A005D11BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9B0B71911E20DD5A005D11BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = LibOne; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 9B0B71921E20DD5A005D11BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = LibOne; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 9B53E8581E223564005F74C6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = LibTwo; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 9B53E8591E223564005F74C6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = LibTwo; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 9B53E8671E226EA4005F74C6 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 9B53E8681E226EA4005F74C6 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9B0B71821E20DD5A005D11BA /* Build configuration list for PBXProject "BSStaticLibraryOne" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B0B718E1E20DD5A005D11BA /* Debug */, + 9B0B718F1E20DD5A005D11BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9B0B71901E20DD5A005D11BA /* Build configuration list for PBXNativeTarget "BSStaticLibraryOne" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B0B71911E20DD5A005D11BA /* Debug */, + 9B0B71921E20DD5A005D11BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9B53E8571E223564005F74C6 /* Build configuration list for PBXNativeTarget "BSStaticLibraryTwo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B53E8581E223564005F74C6 /* Debug */, + 9B53E8591E223564005F74C6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9B53E8661E226EA4005F74C6 /* Build configuration list for PBXNativeTarget "Pod" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B53E8671E226EA4005F74C6 /* Debug */, + 9B53E8681E226EA4005F74C6 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9B0B717F1E20DD5A005D11BA /* Project object */; +} diff --git a/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne+Extension.h b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne+Extension.h new file mode 100644 index 0000000..30106df --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne+Extension.h @@ -0,0 +1,15 @@ +// +// BSStaticLibraryOne+Extension.h +// BSStaticLibraryOne +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "BSStaticLibraryOne.h" + +@interface BSStaticLibraryOne (Extension) + +- (void)sayOtherThing; + +@end diff --git a/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne+Extension.m b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne+Extension.m new file mode 100644 index 0000000..d5304ad --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne+Extension.m @@ -0,0 +1,17 @@ +// +// BSStaticLibraryOne+Extension.m +// BSStaticLibraryOne +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "BSStaticLibraryOne+Extension.h" + +@implementation BSStaticLibraryOne (Extension) + +- (void)sayOtherThing { + NSLog(@"In File: BSStaticLibraryOne + Extension"); +} + +@end diff --git a/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne.h b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne.h new file mode 100644 index 0000000..1d02b37 --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne.h @@ -0,0 +1,15 @@ +// +// BSStaticLibraryOne.h +// BSStaticLibraryOne +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import + +@interface BSStaticLibraryOne : NSObject + +- (void)saySomething; + +@end diff --git a/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne.m b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne.m new file mode 100644 index 0000000..915f4c0 --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryOne/BSStaticLibraryOne.m @@ -0,0 +1,17 @@ +// +// BSStaticLibraryOne.m +// BSStaticLibraryOne +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "BSStaticLibraryOne.h" + +@implementation BSStaticLibraryOne + +- (void)saySomething { + NSLog(@"In Library: BSStaticLibraryOne"); +} + +@end diff --git a/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryTwo/BSStaticLibraryTwo.h b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryTwo/BSStaticLibraryTwo.h new file mode 100644 index 0000000..1df0bde --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryTwo/BSStaticLibraryTwo.h @@ -0,0 +1,15 @@ +// +// BSStaticLibraryTwo.h +// BSStaticLibraryTwo +// +// Created by 张星宇 on 2017/1/8. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import + +@interface BSStaticLibraryTwo : NSObject + +- (void)saySomething; + +@end diff --git a/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryTwo/BSStaticLibraryTwo.m b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryTwo/BSStaticLibraryTwo.m new file mode 100644 index 0000000..f0d80f7 --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/BSStaticLibraryTwo/BSStaticLibraryTwo.m @@ -0,0 +1,17 @@ +// +// BSStaticLibraryTwo.m +// BSStaticLibraryTwo +// +// Created by 张星宇 on 2017/1/8. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "BSStaticLibraryTwo.h" + +@implementation BSStaticLibraryTwo + +- (void)saySomething { + NSLog(@"In Library: BSStaticLibraryTwo"); +} + +@end diff --git a/CocoaPodsDemo/BSStaticLibraryOne/Pod/Pod.h b/CocoaPodsDemo/BSStaticLibraryOne/Pod/Pod.h new file mode 100644 index 0000000..2ea3778 --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/Pod/Pod.h @@ -0,0 +1,13 @@ +// +// Pod.h +// Pod +// +// Created by 张星宇 on 2017/1/8. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import + +@interface Pod : NSObject + +@end diff --git a/CocoaPodsDemo/BSStaticLibraryOne/Pod/Pod.m b/CocoaPodsDemo/BSStaticLibraryOne/Pod/Pod.m new file mode 100644 index 0000000..e052073 --- /dev/null +++ b/CocoaPodsDemo/BSStaticLibraryOne/Pod/Pod.m @@ -0,0 +1,13 @@ +// +// Pod.m +// Pod +// +// Created by 张星宇 on 2017/1/8. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "Pod.h" + +@implementation Pod + +@end diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag.xcodeproj/project.pbxproj b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag.xcodeproj/project.pbxproj new file mode 100644 index 0000000..0280a59 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag.xcodeproj/project.pbxproj @@ -0,0 +1,332 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9B0B71A41E20E289005D11BA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B71A31E20E289005D11BA /* main.m */; }; + 9B0B71A71E20E289005D11BA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B71A61E20E289005D11BA /* AppDelegate.m */; }; + 9B0B71AA1E20E289005D11BA /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B71A91E20E289005D11BA /* ViewController.m */; }; + 9B0B71AD1E20E289005D11BA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9B0B71AB1E20E289005D11BA /* Main.storyboard */; }; + 9B0B71AF1E20E289005D11BA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9B0B71AE1E20E289005D11BA /* Assets.xcassets */; }; + 9B0B71B21E20E289005D11BA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9B0B71B01E20E289005D11BA /* LaunchScreen.storyboard */; }; + 9B0B71BA1E20E298005D11BA /* libBSStaticLibraryOne.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B0B71B91E20E298005D11BA /* libBSStaticLibraryOne.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 9B0B719F1E20E289005D11BA /* OtherLinkerFlag.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OtherLinkerFlag.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 9B0B71A31E20E289005D11BA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 9B0B71A51E20E289005D11BA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 9B0B71A61E20E289005D11BA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9B0B71A81E20E289005D11BA /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 9B0B71A91E20E289005D11BA /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 9B0B71AC1E20E289005D11BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 9B0B71AE1E20E289005D11BA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 9B0B71B11E20E289005D11BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 9B0B71B31E20E289005D11BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9B0B71B91E20E298005D11BA /* libBSStaticLibraryOne.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libBSStaticLibraryOne.a; sourceTree = ""; }; + 9B0B71BE1E20E4C1005D11BA /* BSStaticLibraryOne.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSStaticLibraryOne.h; sourceTree = ""; }; + 9B0B71BF1E20E4C1005D11BA /* BSStaticLibraryOne+Extension.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BSStaticLibraryOne+Extension.h"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9B0B719C1E20E289005D11BA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B0B71BA1E20E298005D11BA /* libBSStaticLibraryOne.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9B0B71961E20E289005D11BA = { + isa = PBXGroup; + children = ( + 9B0B71A11E20E289005D11BA /* OtherLinkerFlag */, + 9B0B71A01E20E289005D11BA /* Products */, + ); + sourceTree = ""; + }; + 9B0B71A01E20E289005D11BA /* Products */ = { + isa = PBXGroup; + children = ( + 9B0B719F1E20E289005D11BA /* OtherLinkerFlag.app */, + ); + name = Products; + sourceTree = ""; + }; + 9B0B71A11E20E289005D11BA /* OtherLinkerFlag */ = { + isa = PBXGroup; + children = ( + 9B0B71BE1E20E4C1005D11BA /* BSStaticLibraryOne.h */, + 9B0B71BF1E20E4C1005D11BA /* BSStaticLibraryOne+Extension.h */, + 9B0B71B91E20E298005D11BA /* libBSStaticLibraryOne.a */, + 9B0B71A51E20E289005D11BA /* AppDelegate.h */, + 9B0B71A61E20E289005D11BA /* AppDelegate.m */, + 9B0B71A81E20E289005D11BA /* ViewController.h */, + 9B0B71A91E20E289005D11BA /* ViewController.m */, + 9B0B71AB1E20E289005D11BA /* Main.storyboard */, + 9B0B71AE1E20E289005D11BA /* Assets.xcassets */, + 9B0B71B01E20E289005D11BA /* LaunchScreen.storyboard */, + 9B0B71B31E20E289005D11BA /* Info.plist */, + 9B0B71A21E20E289005D11BA /* Supporting Files */, + ); + path = OtherLinkerFlag; + sourceTree = ""; + }; + 9B0B71A21E20E289005D11BA /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 9B0B71A31E20E289005D11BA /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9B0B719E1E20E289005D11BA /* OtherLinkerFlag */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9B0B71B61E20E289005D11BA /* Build configuration list for PBXNativeTarget "OtherLinkerFlag" */; + buildPhases = ( + 9B0B719B1E20E289005D11BA /* Sources */, + 9B0B719C1E20E289005D11BA /* Frameworks */, + 9B0B719D1E20E289005D11BA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = OtherLinkerFlag; + productName = OtherLinkerFlag; + productReference = 9B0B719F1E20E289005D11BA /* OtherLinkerFlag.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9B0B71971E20E289005D11BA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = bestswifter; + TargetAttributes = { + 9B0B719E1E20E289005D11BA = { + CreatedOnToolsVersion = 8.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 9B0B719A1E20E289005D11BA /* Build configuration list for PBXProject "OtherLinkerFlag" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9B0B71961E20E289005D11BA; + productRefGroup = 9B0B71A01E20E289005D11BA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9B0B719E1E20E289005D11BA /* OtherLinkerFlag */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9B0B719D1E20E289005D11BA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B0B71B21E20E289005D11BA /* LaunchScreen.storyboard in Resources */, + 9B0B71AF1E20E289005D11BA /* Assets.xcassets in Resources */, + 9B0B71AD1E20E289005D11BA /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9B0B719B1E20E289005D11BA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B0B71AA1E20E289005D11BA /* ViewController.m in Sources */, + 9B0B71A71E20E289005D11BA /* AppDelegate.m in Sources */, + 9B0B71A41E20E289005D11BA /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 9B0B71AB1E20E289005D11BA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9B0B71AC1E20E289005D11BA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 9B0B71B01E20E289005D11BA /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9B0B71B11E20E289005D11BA /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 9B0B71B41E20E289005D11BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 9B0B71B51E20E289005D11BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9B0B71B71E20E289005D11BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = OtherLinkerFlag/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/OtherLinkerFlag", + ); + PRODUCT_BUNDLE_IDENTIFIER = bestswifter.OtherLinkerFlag; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 9B0B71B81E20E289005D11BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = OtherLinkerFlag/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/OtherLinkerFlag", + ); + PRODUCT_BUNDLE_IDENTIFIER = bestswifter.OtherLinkerFlag; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9B0B719A1E20E289005D11BA /* Build configuration list for PBXProject "OtherLinkerFlag" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B0B71B41E20E289005D11BA /* Debug */, + 9B0B71B51E20E289005D11BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9B0B71B61E20E289005D11BA /* Build configuration list for PBXNativeTarget "OtherLinkerFlag" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B0B71B71E20E289005D11BA /* Debug */, + 9B0B71B81E20E289005D11BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9B0B71971E20E289005D11BA /* Project object */; +} diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/AppDelegate.h b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/AppDelegate.h new file mode 100644 index 0000000..53ecc60 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// OtherLinkerFlag +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/AppDelegate.m b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/AppDelegate.m new file mode 100644 index 0000000..06cf523 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/AppDelegate.m @@ -0,0 +1,51 @@ +// +// AppDelegate.m +// OtherLinkerFlag +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Assets.xcassets/AppIcon.appiconset/Contents.json b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..36d2c80 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/BSStaticLibraryOne+Extension.h b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/BSStaticLibraryOne+Extension.h new file mode 100644 index 0000000..30106df --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/BSStaticLibraryOne+Extension.h @@ -0,0 +1,15 @@ +// +// BSStaticLibraryOne+Extension.h +// BSStaticLibraryOne +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "BSStaticLibraryOne.h" + +@interface BSStaticLibraryOne (Extension) + +- (void)sayOtherThing; + +@end diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/BSStaticLibraryOne.h b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/BSStaticLibraryOne.h new file mode 100644 index 0000000..1d02b37 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/BSStaticLibraryOne.h @@ -0,0 +1,15 @@ +// +// BSStaticLibraryOne.h +// BSStaticLibraryOne +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import + +@interface BSStaticLibraryOne : NSObject + +- (void)saySomething; + +@end diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Base.lproj/LaunchScreen.storyboard b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Base.lproj/Main.storyboard b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Base.lproj/Main.storyboard new file mode 100644 index 0000000..4529698 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Info.plist b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Info.plist new file mode 100644 index 0000000..d052473 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/ViewController.h b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/ViewController.h new file mode 100644 index 0000000..beda9b9 --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/ViewController.h @@ -0,0 +1,16 @@ +// +// ViewController.h +// OtherLinkerFlag +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import +#import "BSStaticLibraryOne.h" +#import "BSStaticLibraryOne+Extension.h" + +@interface ViewController : UIViewController + +@end + diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/ViewController.m b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/ViewController.m new file mode 100644 index 0000000..b54bdaa --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/ViewController.m @@ -0,0 +1,32 @@ +// +// ViewController.m +// OtherLinkerFlag +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "ViewController.h" +#import "BSStaticLibraryOne.h" +#import "BSStaticLibraryOne+Extension.h" + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [[[BSStaticLibraryOne alloc] init] sayOtherThing]; + // Do any additional setup after loading the view, typically from a nib. +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +@end diff --git a/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/main.m b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/main.m new file mode 100644 index 0000000..3cd80ed --- /dev/null +++ b/CocoaPodsDemo/OtherLinkerFlag/OtherLinkerFlag/main.m @@ -0,0 +1,16 @@ +// +// main.m +// OtherLinkerFlag +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/CocoaPodsDemo/ShellProject.xcworkspace/contents.xcworkspacedata b/CocoaPodsDemo/ShellProject.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..2f100bc --- /dev/null +++ b/CocoaPodsDemo/ShellProject.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/CocoaPodsDemo/ShellProject.xcworkspace/xcshareddata/ShellProject.xcscmblueprint b/CocoaPodsDemo/ShellProject.xcworkspace/xcshareddata/ShellProject.xcscmblueprint new file mode 100644 index 0000000..bb54c97 --- /dev/null +++ b/CocoaPodsDemo/ShellProject.xcworkspace/xcshareddata/ShellProject.xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "054FA612D81390BCA914FF3E911AFB6ED941DB7C", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "054FA612D81390BCA914FF3E911AFB6ED941DB7C" : 9223372036854775807, + "C71A612E55CCF042C9D0404A97F793518FAC0059" : 9223372036854775807 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "374E162E-2A30-4B89-BEBA-6B8FDE39D0C7", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "054FA612D81390BCA914FF3E911AFB6ED941DB7C" : "SampleCode\/", + "C71A612E55CCF042C9D0404A97F793518FAC0059" : "" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "ShellProject", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "CocoaPodsDemo\/ShellProject.xcworkspace", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/649395594\/MySampleCode.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "054FA612D81390BCA914FF3E911AFB6ED941DB7C" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/649395594\/panDoctor-iOS.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "C71A612E55CCF042C9D0404A97F793518FAC0059" + } + ] +} \ No newline at end of file diff --git a/CocoaPodsDemo/ShellProject.xcworkspace/xcuserdata/zxy.xcuserdatad/UserInterfaceState.xcuserstate b/CocoaPodsDemo/ShellProject.xcworkspace/xcuserdata/zxy.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..e79a684 Binary files /dev/null and b/CocoaPodsDemo/ShellProject.xcworkspace/xcuserdata/zxy.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CocoaPodsDemo/ShellProject/ShellProject.xcodeproj/project.pbxproj b/CocoaPodsDemo/ShellProject/ShellProject.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b983f5d --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject.xcodeproj/project.pbxproj @@ -0,0 +1,360 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9B0B71D21E2117A4005D11BA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B71D11E2117A4005D11BA /* main.m */; }; + 9B0B71D51E2117A4005D11BA /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B71D41E2117A4005D11BA /* AppDelegate.m */; }; + 9B0B71D81E2117A4005D11BA /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0B71D71E2117A4005D11BA /* ViewController.m */; }; + 9B0B71DB1E2117A4005D11BA /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9B0B71D91E2117A4005D11BA /* Main.storyboard */; }; + 9B0B71DD1E2117A4005D11BA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9B0B71DC1E2117A4005D11BA /* Assets.xcassets */; }; + 9B0B71E01E2117A4005D11BA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9B0B71DE1E2117A4005D11BA /* LaunchScreen.storyboard */; }; + 9B53E86F1E227340005F74C6 /* libPod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B53E86E1E227340005F74C6 /* libPod.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 9B0B71CD1E2117A4005D11BA /* ShellProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ShellProject.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 9B0B71D11E2117A4005D11BA /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 9B0B71D31E2117A4005D11BA /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 9B0B71D41E2117A4005D11BA /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9B0B71D61E2117A4005D11BA /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 9B0B71D71E2117A4005D11BA /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 9B0B71DA1E2117A4005D11BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 9B0B71DC1E2117A4005D11BA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 9B0B71DF1E2117A4005D11BA /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 9B0B71E11E2117A4005D11BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9B53E86E1E227340005F74C6 /* libPod.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libPod.a; path = "../BSStaticLibraryOne/Build/Products/Debug-iphonesimulator/libPod.a"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9B0B71CA1E2117A4005D11BA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B53E86F1E227340005F74C6 /* libPod.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9B0B71C41E2117A4005D11BA = { + isa = PBXGroup; + children = ( + 9B0B71CF1E2117A4005D11BA /* ShellProject */, + 9B0B71CE1E2117A4005D11BA /* Products */, + 9B53E86D1E227340005F74C6 /* Frameworks */, + ); + sourceTree = ""; + }; + 9B0B71CE1E2117A4005D11BA /* Products */ = { + isa = PBXGroup; + children = ( + 9B0B71CD1E2117A4005D11BA /* ShellProject.app */, + ); + name = Products; + sourceTree = ""; + }; + 9B0B71CF1E2117A4005D11BA /* ShellProject */ = { + isa = PBXGroup; + children = ( + 9B0B71D31E2117A4005D11BA /* AppDelegate.h */, + 9B0B71D41E2117A4005D11BA /* AppDelegate.m */, + 9B0B71D61E2117A4005D11BA /* ViewController.h */, + 9B0B71D71E2117A4005D11BA /* ViewController.m */, + 9B0B71D91E2117A4005D11BA /* Main.storyboard */, + 9B0B71DC1E2117A4005D11BA /* Assets.xcassets */, + 9B0B71DE1E2117A4005D11BA /* LaunchScreen.storyboard */, + 9B0B71E11E2117A4005D11BA /* Info.plist */, + 9B0B71D01E2117A4005D11BA /* Supporting Files */, + ); + path = ShellProject; + sourceTree = ""; + }; + 9B0B71D01E2117A4005D11BA /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 9B0B71D11E2117A4005D11BA /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 9B53E86D1E227340005F74C6 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 9B53E86E1E227340005F74C6 /* libPod.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9B0B71CC1E2117A4005D11BA /* ShellProject */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9B0B71E41E2117A4005D11BA /* Build configuration list for PBXNativeTarget "ShellProject" */; + buildPhases = ( + 9B0B71C91E2117A4005D11BA /* Sources */, + 9B0B71CA1E2117A4005D11BA /* Frameworks */, + 9B0B71CB1E2117A4005D11BA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ShellProject; + productName = ShellProject; + productReference = 9B0B71CD1E2117A4005D11BA /* ShellProject.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9B0B71C51E2117A4005D11BA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = bestswifter; + TargetAttributes = { + 9B0B71CC1E2117A4005D11BA = { + CreatedOnToolsVersion = 8.2; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 9B0B71C81E2117A4005D11BA /* Build configuration list for PBXProject "ShellProject" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9B0B71C41E2117A4005D11BA; + productRefGroup = 9B0B71CE1E2117A4005D11BA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9B0B71CC1E2117A4005D11BA /* ShellProject */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9B0B71CB1E2117A4005D11BA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B0B71E01E2117A4005D11BA /* LaunchScreen.storyboard in Resources */, + 9B0B71DD1E2117A4005D11BA /* Assets.xcassets in Resources */, + 9B0B71DB1E2117A4005D11BA /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9B0B71C91E2117A4005D11BA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B0B71D81E2117A4005D11BA /* ViewController.m in Sources */, + 9B0B71D51E2117A4005D11BA /* AppDelegate.m in Sources */, + 9B0B71D21E2117A4005D11BA /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 9B0B71D91E2117A4005D11BA /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9B0B71DA1E2117A4005D11BA /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 9B0B71DE1E2117A4005D11BA /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9B0B71DF1E2117A4005D11BA /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 9B0B71E21E2117A4005D11BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 9B0B71E31E2117A4005D11BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9B0B71E51E2117A4005D11BA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + HEADER_SEARCH_PATHS = ( + "$PROJECT_DIR/../Build/Products/Debug-iphonesimulator/LibOne", + "$(inherited)", + "$PROJECT_DIR/../Build/Products/Debug-iphonesimulator/LibTwo", + ); + INFOPLIST_FILE = ShellProject/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$PROJECT_DIR/../Build/Products/Debug-iphonesimulator", + "$(inherited)", + ); + ONLY_ACTIVE_ARCH = NO; + ORDER_FILE = ""; + OTHER_LDFLAGS = ( + "-ObjC", + "-l\"BSStaticLibraryOne\"", + "-l\"BSStaticLibraryTwo\"", + ); + PRODUCT_BUNDLE_IDENTIFIER = bestswifter.ShellProject; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 9B0B71E61E2117A4005D11BA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + HEADER_SEARCH_PATHS = ( + "$PROJECT_DIR/../Build/Products/Debug-iphonesimulator/LibOne", + "$(inherited)", + "$PROJECT_DIR/../Build/Products/Debug-iphonesimulator/LibTwo", + ); + INFOPLIST_FILE = ShellProject/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$PROJECT_DIR/../Build/Products/Debug-iphonesimulator", + "$(inherited)", + ); + ORDER_FILE = ""; + OTHER_LDFLAGS = ( + "-ObjC", + "-l\"BSStaticLibraryOne\"", + "-l\"BSStaticLibraryTwo\"", + ); + PRODUCT_BUNDLE_IDENTIFIER = bestswifter.ShellProject; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9B0B71C81E2117A4005D11BA /* Build configuration list for PBXProject "ShellProject" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B0B71E21E2117A4005D11BA /* Debug */, + 9B0B71E31E2117A4005D11BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9B0B71E41E2117A4005D11BA /* Build configuration list for PBXNativeTarget "ShellProject" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9B0B71E51E2117A4005D11BA /* Debug */, + 9B0B71E61E2117A4005D11BA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9B0B71C51E2117A4005D11BA /* Project object */; +} diff --git a/CocoaPodsDemo/ShellProject/ShellProject/AppDelegate.h b/CocoaPodsDemo/ShellProject/ShellProject/AppDelegate.h new file mode 100644 index 0000000..505b34d --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// ShellProject +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/CocoaPodsDemo/ShellProject/ShellProject/AppDelegate.m b/CocoaPodsDemo/ShellProject/ShellProject/AppDelegate.m new file mode 100644 index 0000000..6bc31bb --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/AppDelegate.m @@ -0,0 +1,51 @@ +// +// AppDelegate.m +// ShellProject +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + + +@end diff --git a/CocoaPodsDemo/ShellProject/ShellProject/Assets.xcassets/AppIcon.appiconset/Contents.json b/CocoaPodsDemo/ShellProject/ShellProject/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..36d2c80 --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CocoaPodsDemo/ShellProject/ShellProject/Base.lproj/LaunchScreen.storyboard b/CocoaPodsDemo/ShellProject/ShellProject/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CocoaPodsDemo/ShellProject/ShellProject/Base.lproj/Main.storyboard b/CocoaPodsDemo/ShellProject/ShellProject/Base.lproj/Main.storyboard new file mode 100644 index 0000000..4529698 --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CocoaPodsDemo/ShellProject/ShellProject/Info.plist b/CocoaPodsDemo/ShellProject/ShellProject/Info.plist new file mode 100644 index 0000000..d052473 --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/CocoaPodsDemo/ShellProject/ShellProject/ViewController.h b/CocoaPodsDemo/ShellProject/ShellProject/ViewController.h new file mode 100644 index 0000000..67cb353 --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// ShellProject +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/CocoaPodsDemo/ShellProject/ShellProject/ViewController.m b/CocoaPodsDemo/ShellProject/ShellProject/ViewController.m new file mode 100644 index 0000000..4e9b27e --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/ViewController.m @@ -0,0 +1,34 @@ +// +// ViewController.m +// ShellProject +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import "ViewController.h" +#import +#import +#import + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [[[BSStaticLibraryOne alloc] init] saySomething]; + [[[BSStaticLibraryTwo alloc] init] saySomething]; + // Do any additional setup after loading the view, typically from a nib. +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +@end diff --git a/CocoaPodsDemo/ShellProject/ShellProject/main.m b/CocoaPodsDemo/ShellProject/ShellProject/main.m new file mode 100644 index 0000000..a676aa1 --- /dev/null +++ b/CocoaPodsDemo/ShellProject/ShellProject/main.m @@ -0,0 +1,16 @@ +// +// main.m +// ShellProject +// +// Created by 张星宇 on 2017/1/7. +// Copyright © 2017年 bestswifter. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC.xcodeproj/project.pbxproj b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC.xcodeproj/project.pbxproj new file mode 100644 index 0000000..44dabe8 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC.xcodeproj/project.pbxproj @@ -0,0 +1,315 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9B34C40F1CA836A10048F570 /* EOCErrors.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B34C40E1CA836A10048F570 /* EOCErrors.m */; }; + 9B9116451CA4E15900917FF2 /* HashTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9116441CA4E15900917FF2 /* HashTest.m */; }; + 9B9116481CA4F24A00917FF2 /* EOCEmployeeDeveloper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9116471CA4F24A00917FF2 /* EOCEmployeeDeveloper.m */; }; + 9B91164C1CA4F29600917FF2 /* EOCEmployeeDesigner.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B91164B1CA4F29600917FF2 /* EOCEmployeeDesigner.m */; }; + 9B91164F1CA4F29D00917FF2 /* EOCEmployeeFinance.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B91164E1CA4F29D00917FF2 /* EOCEmployeeFinance.m */; }; + 9BC39BAB1CA3CECE00B04B99 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC39BAA1CA3CECE00B04B99 /* main.m */; }; + 9BC39BB31CA3D17200B04B99 /* EOCPerson.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC39BB21CA3D17200B04B99 /* EOCPerson.m */; }; + 9BC39BB61CA3D18000B04B99 /* EOCEmployee.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC39BB51CA3D18000B04B99 /* EOCEmployee.m */; }; + 9BC39BB91CA3D4C500B04B99 /* Literal.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC39BB81CA3D4C500B04B99 /* Literal.m */; }; + 9BC39BBC1CA3FA6700B04B99 /* Enum.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC39BBB1CA3FA6700B04B99 /* Enum.m */; }; + 9BC39BBF1CA405E900B04B99 /* EOCSmithPerson.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BC39BBE1CA405E900B04B99 /* EOCSmithPerson.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9BC39BA51CA3CECE00B04B99 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 9B34C40D1CA836A10048F570 /* EOCErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EOCErrors.h; sourceTree = ""; }; + 9B34C40E1CA836A10048F570 /* EOCErrors.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EOCErrors.m; sourceTree = ""; }; + 9B9116431CA4E15900917FF2 /* HashTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashTest.h; sourceTree = ""; }; + 9B9116441CA4E15900917FF2 /* HashTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HashTest.m; sourceTree = ""; }; + 9B9116461CA4F24A00917FF2 /* EOCEmployeeDeveloper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EOCEmployeeDeveloper.h; sourceTree = ""; }; + 9B9116471CA4F24A00917FF2 /* EOCEmployeeDeveloper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EOCEmployeeDeveloper.m; sourceTree = ""; }; + 9B91164A1CA4F29600917FF2 /* EOCEmployeeDesigner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EOCEmployeeDesigner.h; sourceTree = ""; }; + 9B91164B1CA4F29600917FF2 /* EOCEmployeeDesigner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EOCEmployeeDesigner.m; sourceTree = ""; }; + 9B91164D1CA4F29D00917FF2 /* EOCEmployeeFinance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EOCEmployeeFinance.h; sourceTree = ""; }; + 9B91164E1CA4F29D00917FF2 /* EOCEmployeeFinance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EOCEmployeeFinance.m; sourceTree = ""; }; + 9BC39BA71CA3CECE00B04B99 /* EffectiveObjectiveC */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = EffectiveObjectiveC; sourceTree = BUILT_PRODUCTS_DIR; }; + 9BC39BAA1CA3CECE00B04B99 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 9BC39BB11CA3D17200B04B99 /* EOCPerson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EOCPerson.h; sourceTree = ""; }; + 9BC39BB21CA3D17200B04B99 /* EOCPerson.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EOCPerson.m; sourceTree = ""; }; + 9BC39BB41CA3D18000B04B99 /* EOCEmployee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EOCEmployee.h; sourceTree = ""; }; + 9BC39BB51CA3D18000B04B99 /* EOCEmployee.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EOCEmployee.m; sourceTree = ""; }; + 9BC39BB71CA3D4C500B04B99 /* Literal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Literal.h; sourceTree = ""; }; + 9BC39BB81CA3D4C500B04B99 /* Literal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Literal.m; sourceTree = ""; }; + 9BC39BBA1CA3FA6700B04B99 /* Enum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Enum.h; sourceTree = ""; }; + 9BC39BBB1CA3FA6700B04B99 /* Enum.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Enum.m; sourceTree = ""; }; + 9BC39BBD1CA405E900B04B99 /* EOCSmithPerson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EOCSmithPerson.h; sourceTree = ""; }; + 9BC39BBE1CA405E900B04B99 /* EOCSmithPerson.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EOCSmithPerson.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9BC39BA41CA3CECE00B04B99 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9B9116491CA4F25000917FF2 /* EOCEmployee */ = { + isa = PBXGroup; + children = ( + 9BC39BB41CA3D18000B04B99 /* EOCEmployee.h */, + 9BC39BB51CA3D18000B04B99 /* EOCEmployee.m */, + 9B9116461CA4F24A00917FF2 /* EOCEmployeeDeveloper.h */, + 9B9116471CA4F24A00917FF2 /* EOCEmployeeDeveloper.m */, + 9B91164A1CA4F29600917FF2 /* EOCEmployeeDesigner.h */, + 9B91164B1CA4F29600917FF2 /* EOCEmployeeDesigner.m */, + 9B91164D1CA4F29D00917FF2 /* EOCEmployeeFinance.h */, + 9B91164E1CA4F29D00917FF2 /* EOCEmployeeFinance.m */, + ); + name = EOCEmployee; + sourceTree = ""; + }; + 9BC39B9E1CA3CECE00B04B99 = { + isa = PBXGroup; + children = ( + 9BC39BA91CA3CECE00B04B99 /* EffectiveObjectiveC */, + 9BC39BA81CA3CECE00B04B99 /* Products */, + ); + sourceTree = ""; + }; + 9BC39BA81CA3CECE00B04B99 /* Products */ = { + isa = PBXGroup; + children = ( + 9BC39BA71CA3CECE00B04B99 /* EffectiveObjectiveC */, + ); + name = Products; + sourceTree = ""; + }; + 9BC39BA91CA3CECE00B04B99 /* EffectiveObjectiveC */ = { + isa = PBXGroup; + children = ( + 9B9116491CA4F25000917FF2 /* EOCEmployee */, + 9BC39BAA1CA3CECE00B04B99 /* main.m */, + 9BC39BB11CA3D17200B04B99 /* EOCPerson.h */, + 9BC39BB21CA3D17200B04B99 /* EOCPerson.m */, + 9BC39BBD1CA405E900B04B99 /* EOCSmithPerson.h */, + 9BC39BBE1CA405E900B04B99 /* EOCSmithPerson.m */, + 9B34C40D1CA836A10048F570 /* EOCErrors.h */, + 9B34C40E1CA836A10048F570 /* EOCErrors.m */, + 9BC39BB71CA3D4C500B04B99 /* Literal.h */, + 9BC39BB81CA3D4C500B04B99 /* Literal.m */, + 9BC39BBA1CA3FA6700B04B99 /* Enum.h */, + 9BC39BBB1CA3FA6700B04B99 /* Enum.m */, + 9B9116431CA4E15900917FF2 /* HashTest.h */, + 9B9116441CA4E15900917FF2 /* HashTest.m */, + ); + path = EffectiveObjectiveC; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9BC39BA61CA3CECE00B04B99 /* EffectiveObjectiveC */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9BC39BAE1CA3CECE00B04B99 /* Build configuration list for PBXNativeTarget "EffectiveObjectiveC" */; + buildPhases = ( + 9BC39BA31CA3CECE00B04B99 /* Sources */, + 9BC39BA41CA3CECE00B04B99 /* Frameworks */, + 9BC39BA51CA3CECE00B04B99 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = EffectiveObjectiveC; + productName = EffectiveObjectiveC; + productReference = 9BC39BA71CA3CECE00B04B99 /* EffectiveObjectiveC */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9BC39B9F1CA3CECE00B04B99 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0730; + ORGANIZATIONNAME = zxy; + TargetAttributes = { + 9BC39BA61CA3CECE00B04B99 = { + CreatedOnToolsVersion = 7.3; + }; + }; + }; + buildConfigurationList = 9BC39BA21CA3CECE00B04B99 /* Build configuration list for PBXProject "EffectiveObjectiveC" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 9BC39B9E1CA3CECE00B04B99; + productRefGroup = 9BC39BA81CA3CECE00B04B99 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9BC39BA61CA3CECE00B04B99 /* EffectiveObjectiveC */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 9BC39BA31CA3CECE00B04B99 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9B34C40F1CA836A10048F570 /* EOCErrors.m in Sources */, + 9BC39BBC1CA3FA6700B04B99 /* Enum.m in Sources */, + 9BC39BB61CA3D18000B04B99 /* EOCEmployee.m in Sources */, + 9B91164F1CA4F29D00917FF2 /* EOCEmployeeFinance.m in Sources */, + 9B9116451CA4E15900917FF2 /* HashTest.m in Sources */, + 9BC39BBF1CA405E900B04B99 /* EOCSmithPerson.m in Sources */, + 9B91164C1CA4F29600917FF2 /* EOCEmployeeDesigner.m in Sources */, + 9BC39BB91CA3D4C500B04B99 /* Literal.m in Sources */, + 9BC39BB31CA3D17200B04B99 /* EOCPerson.m in Sources */, + 9B9116481CA4F24A00917FF2 /* EOCEmployeeDeveloper.m in Sources */, + 9BC39BAB1CA3CECE00B04B99 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 9BC39BAC1CA3CECE00B04B99 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 9BC39BAD1CA3CECE00B04B99 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 9BC39BAF1CA3CECE00B04B99 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 9BC39BB01CA3CECE00B04B99 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9BC39BA21CA3CECE00B04B99 /* Build configuration list for PBXProject "EffectiveObjectiveC" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9BC39BAC1CA3CECE00B04B99 /* Debug */, + 9BC39BAD1CA3CECE00B04B99 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9BC39BAE1CA3CECE00B04B99 /* Build configuration list for PBXNativeTarget "EffectiveObjectiveC" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9BC39BAF1CA3CECE00B04B99 /* Debug */, + 9BC39BB01CA3CECE00B04B99 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9BC39B9F1CA3CECE00B04B99 /* Project object */; +} diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployee.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployee.h new file mode 100644 index 0000000..a2b5f78 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployee.h @@ -0,0 +1,25 @@ +// +// EOCEmployee.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import "EOCPerson.h" + +typedef NS_ENUM(NSUInteger, EOCEmployeeType) { + EOCEmployeeTypeDeveloper, + EOCEmployeeTypeDesigner, + EOCEmployeeTypeFinance, +}; + +@interface EOCEmployee : NSObject + +- (void) addEmployee:(EOCPerson *)person; +- (void) doSomeWork; + ++ (EOCEmployee *)employeeWithType:(EOCEmployeeType)type; + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployee.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployee.m new file mode 100644 index 0000000..3fe8a28 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployee.m @@ -0,0 +1,44 @@ +// +// EOCEmployee.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCEmployee.h" +#import "EOCEmployeeDeveloper.h" +#import "EOCEmployeeFinance.h" +#import "EOCEmployeeDesigner.h" + +int EOCConst = 1; + +@implementation EOCEmployee + +- (void)addEmployee:(EOCPerson *)person { + return; +} + +- (void)doSomeWork { + return; +} + ++ (EOCEmployee *)employeeWithType:(EOCEmployeeType)type { + switch (type) { + case EOCEmployeeTypeDeveloper: + return [EOCEmployeeDeveloper new]; + break; + case EOCEmployeeTypeFinance: + return [EOCEmployeeFinance new]; + break; + case EOCEmployeeTypeDesigner: + return [EOCEmployeeDesigner new]; + break; + } +} + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[EOCEmployee allocWithZone:zone] init]; +} + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDesigner.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDesigner.h new file mode 100644 index 0000000..617b6a3 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDesigner.h @@ -0,0 +1,13 @@ +// +// EOCEmployeeDesigner.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/25. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCEmployee.h" + +@interface EOCEmployeeDesigner : EOCEmployee + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDesigner.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDesigner.m new file mode 100644 index 0000000..4e36cd2 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDesigner.m @@ -0,0 +1,17 @@ +// +// EOCEmployeeDesigner.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/25. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCEmployeeDesigner.h" + +@implementation EOCEmployeeDesigner + +- (void)doSomeWork { + NSLog(@"EOCEmployeeDesigner do some work"); +} + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDeveloper.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDeveloper.h new file mode 100644 index 0000000..e1a98c9 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDeveloper.h @@ -0,0 +1,13 @@ +// +// EOCEmployeeDeveloper.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/25. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCEmployee.h" + +@interface EOCEmployeeDeveloper : EOCEmployee + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDeveloper.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDeveloper.m new file mode 100644 index 0000000..2700932 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeDeveloper.m @@ -0,0 +1,17 @@ +// +// EOCEmployeeDeveloper.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/25. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCEmployeeDeveloper.h" + +@implementation EOCEmployeeDeveloper + +- (void)doSomeWork { + NSLog(@"EOCEmployeeDeveloper do some work"); +} + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeFinance.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeFinance.h new file mode 100644 index 0000000..962d259 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeFinance.h @@ -0,0 +1,13 @@ +// +// EOCEmployeeFinance.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/25. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCEmployee.h" + +@interface EOCEmployeeFinance : EOCEmployee + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeFinance.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeFinance.m new file mode 100644 index 0000000..07fd0a8 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCEmployeeFinance.m @@ -0,0 +1,17 @@ +// +// EOCEmployeeFinance.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/25. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCEmployeeFinance.h" + +@implementation EOCEmployeeFinance + +- (void)doSomeWork { + NSLog(@"EOCEmployeeFinance do some work"); +} + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCErrors.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCErrors.h new file mode 100644 index 0000000..47d0d97 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCErrors.h @@ -0,0 +1,22 @@ +// +// EOCErrors.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/27. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface EOCErrors : NSObject + +extern NSString *const EOCErrorDomain; + +typedef NS_ENUM(NSUInteger, EOCError) { + EOCErrorUnkonwn = -1, + EOCErrorInternalInconsistency = 100, + EOCErrorGeneralFault = 105, + EOCErrorBadInput = 500, +}; + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCErrors.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCErrors.m new file mode 100644 index 0000000..03cffa4 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCErrors.m @@ -0,0 +1,15 @@ +// +// EOCErrors.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/27. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCErrors.h" + +NSString *const EOCErrorDomain = @"EOCErrorDomain"; + +@implementation EOCErrors + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCPerson.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCPerson.h new file mode 100644 index 0000000..fc0ae8a --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCPerson.h @@ -0,0 +1,27 @@ +// +// EOCPerson.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +// 引入这行代码会导致两个头文件互相引用 +//#import "EOCEmployer.h" +@class EOCEmployee; + +// 不要在头文件中使用 static,否则会变成全局变量,放在实现文件里面即可 +static const int ANIMATION_DURATION = 1; +static int ANOTHER_DURATION = 2; +static void * const EOCMyKey = @"EOCMyKey"; + +FOUNDATION_EXPORT NSString *const EOCStringConstant; + +@interface EOCPerson : NSObject + +@property (nonatomic, copy) NSString *firstName; +@property (nonatomic, copy) NSString *lastName; +@property (nonatomic, strong) EOCEmployee *employee; + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCPerson.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCPerson.m new file mode 100644 index 0000000..003b7aa --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCPerson.m @@ -0,0 +1,70 @@ +// +// EOCPerson.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCPerson.h" +#import "EOCEmployee.h" +#import + +// 变量的作用范围只在这个目标文件中,如果不加 static,会产生外部符号,然后报错 +static int EOCConst = 1; + +NSString *const EOCStringConstant = @"StringValue"; + +@implementation EOCPerson + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.firstName = @"EOCPerson-FirstName"; + self.lastName = @"EOCPerson-LastName"; + NSString *associatedString = @"associatedString"; + objc_setAssociatedObject(self, EOCMyKey, associatedString, OBJC_ASSOCIATION_COPY); + } + return self; +} + +- (NSUInteger)hash { + static int hashValue = 0; + return hashValue++; +// return 1337; +// return [self.firstName hash] ^ [self.lastName hash]; +} + +- (BOOL)isEqual:(id)object { + if (self == object) { + return YES; + } + + if ([self class] != [object class]) { + return NO; + } + + EOCPerson *anotherPerson = (EOCPerson *)object; + return [self.firstName isEqualToString:anotherPerson.firstName] && + [self.lastName isEqualToString:anotherPerson.lastName]; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"%@, %@", _firstName, _lastName]; +} + +- (NSString *)debugDescription { + return [NSString stringWithFormat:@"<%@: %p, \"%@ %@\">", [self class], self, _firstName, _lastName]; +} + +- (instancetype)copyWithZone:(NSZone *)zone { + EOCPerson *copy = [[EOCPerson allocWithZone:zone] init]; + copy.lastName = self.lastName; + copy.firstName = self.firstName; + copy.employee= [self.employee copy]; + + return copy; +} + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCSmithPerson.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCSmithPerson.h new file mode 100644 index 0000000..af9a9aa --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCSmithPerson.h @@ -0,0 +1,13 @@ +// +// EOCSmithPerson.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCPerson.h" + +@interface EOCSmithPerson : EOCPerson + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCSmithPerson.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCSmithPerson.m new file mode 100644 index 0000000..a814f01 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/EOCSmithPerson.m @@ -0,0 +1,39 @@ +// +// EOCSmithPerson.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCSmithPerson.h" +#import "EOCErrors.h" + +@implementation EOCSmithPerson + +@synthesize lastName = _lastName; + +- (void)setLastName:(NSString *)lastName { + if (![lastName isEqualToString:@"Smith"]) { + // 会执行到这段代码 +// [NSException raise:NSInvalidArgumentException format:@"Last name must be Smith"]; + } + + _lastName = lastName; +} + +- (bool) doSomething:(NSError **)error { + if (![self.firstName isEqualToString:@""]) { + if (error) { + *error = [NSError errorWithDomain:EOCErrorDomain + code:EOCErrorUnkonwn + userInfo:nil]; + } + return NO; + } + else { + return YES; + } +} + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Enum.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Enum.h new file mode 100644 index 0000000..9de5559 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Enum.h @@ -0,0 +1,13 @@ +// +// Enum.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface Enum : NSObject + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Enum.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Enum.m new file mode 100644 index 0000000..0e254e7 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Enum.m @@ -0,0 +1,45 @@ +// +// Enum.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "Enum.h" + +@implementation Enum + +// 可以声明枚举变量的类型 +enum EOCConnectionState: NSInteger { + ECOConnectStateDisconnected = 1, // 不指定值的时候默认是 0,然后下面的依次递增 + ECOConnectStateConnecting = 2, + ECOConnectStateConnected = 3 +}; + +// 常规写法 +enum EOCConnectionState state = ECOConnectStateConnected; + +// 用了 typedef 简化语法 +typedef enum EOCConnectionState EOCConnectionState; +EOCConnectionState state2 = ECOConnectStateConnecting; + +// 使用 NS_ENUM 宏 +typedef NS_ENUM(NSInteger, EOCEnumType) { + EOCEnumTypeA, + EOCEnumTypeB, + EOCEnumTypeC +}; + +EOCEnumType type = EOCEnumTypeA; + +// 使用 NS_OPTION 宏 +typedef NS_ENUM(NSInteger, EOCOptionType) { + EOCOptionTypeA, + EOCOptionTypeB, + EOCOptionTypeC +}; + +EOCOptionType option = EOCOptionTypeA; + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/HashTest.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/HashTest.h new file mode 100644 index 0000000..58bbe36 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/HashTest.h @@ -0,0 +1,15 @@ +// +// HashTest.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/25. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "EOCPerson.h" + +@interface HashTest : EOCPerson + +- (void)testMutableCollection; + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/HashTest.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/HashTest.m new file mode 100644 index 0000000..b9b139d --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/HashTest.m @@ -0,0 +1,49 @@ +// +// HashTest.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/25. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "HashTest.h" +#import "EOCPerson.h" + +@implementation HashTest + +- (instancetype)init +{ + self = [super init]; + if (self) { + EOCPerson *person1 = [[EOCPerson alloc] init]; + EOCPerson *person2 = [[EOCPerson alloc] init]; + NSLog(@"person1.hashValue = %lu", (unsigned long)[person1 hash]); + NSLog(@"person2.hashValue = %lu", (unsigned long)[person2 hash]); + + if ([person1 isEqual:person2]) { + NSLog(@"Person1 and Person2 is the same"); + } + else { + NSLog(@"Person1 and Person2 is not the same"); + } + } + return self; +} + +- (void)testMutableCollection { + NSMutableSet *set = [NSMutableSet new]; + + NSMutableArray *arrayA = [@[@1, @2] mutableCopy]; + [set addObject:arrayA]; + + NSMutableArray *arrayB = [@[@1, @2] mutableCopy]; + [set addObject:arrayB]; + + NSMutableArray *arrayC = [@[@1] mutableCopy]; + [set addObject:arrayC]; + + [arrayC addObject:@2]; + NSLog(@"set = %@", set); +} + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Literal.h b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Literal.h new file mode 100644 index 0000000..215f6ad --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Literal.h @@ -0,0 +1,16 @@ +// +// Literal.h +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface Literal : NSObject + +@property (nonatomic, strong) NSArray *animals; +@property (nonatomic, strong) NSDictionary *personData; + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Literal.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Literal.m new file mode 100644 index 0000000..4a86e92 --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/Literal.m @@ -0,0 +1,38 @@ +// +// Literal.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "Literal.h" +#import "EOCPerson.h" + +@implementation Literal + +- (instancetype)init +{ + self = [super init]; + if (self) { + EOCPerson *p = nil; + // 如果有变量为 nil,使用字面量语法会导致运行时崩溃 +// self.animals = @[@"dog", @"cat", p, @"mouse"]; + self.animals = [NSArray arrayWithObjects:@"dog", @"cat", p, @"mouse", nil]; + + // 直接写 nil 会导致编译错误,需要注意变量为 nil 的情况 +// self.animals = @[@"dog", @"cat", p, @"mouse"]; + + // 字典与数组同理 + self.personData = [NSDictionary dictionaryWithObjectsAndKeys:@"Matt", @"firstName", + p, @"person", + @"Galloway", @"lastName",nil]; +// self.personData = @{@"Matt" : @"firstName", +// p : @"person", +// @"Galloway" : @"lastName"}; + NSLog(@"%d, %d, %@", ANIMATION_DURATION, ANOTHER_DURATION, EOCStringConstant); + } + return self; +} + +@end diff --git a/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/main.m b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/main.m new file mode 100644 index 0000000..e68e6dc --- /dev/null +++ b/Effective OC/EffectiveObjectiveC/EffectiveObjectiveC/main.m @@ -0,0 +1,40 @@ +// +// main.m +// EffectiveObjectiveC +// +// Created by 张星宇 on 16/3/24. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import + +#import "Literal.h" +#import "EOCPerson.h" +#import "EOCSmithPerson.h" +#import "HashTest.h" +#import "EOCEmployee.h" + +int main(int argc, const char * argv[]) { + @autoreleasepool { + Literal *l = [[Literal alloc] init]; + NSLog(@"%@\n%@", l.animals, l.personData); + + EOCSmithPerson *smith = [[EOCSmithPerson alloc] init]; + NSLog(@"%@", smith.lastName); + + HashTest *test = [[HashTest alloc] init]; + [test testMutableCollection]; + + EOCEmployee *employee = [EOCEmployee employeeWithType:EOCEmployeeTypeDeveloper]; + [employee doSomeWork]; + NSLog(@"%@ member of", [employee isMemberOfClass:[EOCEmployee class]] ? @"is " : @"not"); + NSLog(@"%@ kind of", [employee isKindOfClass:[EOCEmployee class]] ? @"is" : @"not"); + + EOCPerson *person = [[EOCPerson alloc] init]; + NSLog(@"associated string = %@", objc_getAssociatedObject(person, EOCMyKey)); + NSLog(@"person = %@", person); + + } + return 0; +} diff --git "a/Effective OC/\350\257\273\344\271\246\346\200\273\347\273\223.md" "b/Effective OC/\350\257\273\344\271\246\346\200\273\347\273\223.md" new file mode 100644 index 0000000..270ede8 --- /dev/null +++ "b/Effective OC/\350\257\273\344\271\246\346\200\273\347\273\223.md" @@ -0,0 +1,134 @@ +# 熟悉 Objective-C + +## 1. OC 的起源 + +OC 的方法(本质上讲是消息)在运行时决定。使用函数调用的语言,由编译器决定。如果涉及多态,则用到虚函数表。 + +## 2. 少在头文件中引用其他文件 + +1. 两个头文件互相引用会导致编译错误 +2. 引用协议,超类时,无法使用前向声明(`@class`),只能引用头文件 +3. 协议一般放在单独的文件中,委托协议除外 + +## 3. 多用字面量语法 + +1. 向数组中插入 `nil` 时,如果使用字面量会直接报错,如果是使用初始化方法,则 `nil` 以后的对象被忽略 +2. 字典也是同理 + +## 4. 多用常量,少用 #define + +1. 不在头文件里面声明预处理命令,防止被别的文件引用,`static const` 也不能用 +2. 在 `.m` 文件里面声明的变量,需要加上 static,不然会产生外部符号,重复的外部符号会导致编译错误 +3. 用 `static const` 定义只在类内部可见的常量 +4. 用 `extern` 定义全局常量,并使用类名作为前缀 +5. 头文件中使用 `static const` 会在每个编译单元中出现一个字符串对象,而用 `extern` 定义的对象放在全局符号表中。参考链接:[static const Vs extern const](http://stackoverflow.com/questions/23652665/static-const-vs-extern-const) +6. 使用 `FOUNDATION_EXPORT` 比 `extern` 更好,参考链接:[“FOUNDATION_EXPORT” vs “extern”](http://stackoverflow.com/questions/10953221/foundation-export-vs-extern) + +## 5. 用枚举表示状态和选项 + +1. 按位或操作来组合的枚举使用 `NS_OPTIONS` 宏定义,不需要相互组合的用 `NS_ENUM ` 来定义。 +2. 尽可能指定枚举变量的类型 + +# 对象、消息、运行期 + +## 6. 理解“属性”这一概念 + +1. 如果直接使用实例变量,系统会根据偏移量来确定它们的位置。如果后来新增了实例变量,会导致重新编译。 +2. `@property` 的作用是合成存取方法 +3. `@synthesize` 的作用是指定实例变量的名字,目前默认会执行 `@synthesize xxx = _xxx;` +4. `@dynamic` 的作用是不要创建实例变量,也不要创建存取方法 + +## 7. 在对象内部尽量直接访问实例变量 + +1. 直接访问实例变量不会经过方法派发,不会触发内存管理语义,不会触发 KVO,无法调试(加断点)。 +2. 可以考虑通过直接读取实例变量来加快读取速度 +3. 初始化方法中不要调用 setter,这是因为子类有可能重写设置方法。参见 Demo 的 `EOCSmithPerson.m` 文件。 +4. 如果属性是惰性初始化的,必须通过 getter 来读取。 + +## 8. 理解对象等同性 + +1. 应该保证相等的对象具有相等的 `hash` 值,但即使 `hash` 值不同,也不影响判断对象等同性。但是考虑到对象加入集合中的情况,我们总是应该为相同的对象提供相同的哈希值。 +2. 要么确保对象的哈希值不依赖内部可变的状态,要么确保依赖的状态不会改变。 + +## 9. 以“类族模式”隐藏实现细节 + +1. 用类族模式可以将实现细节隐藏,返回基类的对象,并且通过多态完成任务。这其实是一种工厂模式。 +2. 注意此时调用 `isMemberOf: superClass` 的返回结果是 `NO`,因为对象实际上是子类的实例。调用 `isKindOf: superClass` 的返回结果则是 `YES`。 +3. `[arrayInstance class] = [NSArray class]` 的返回结果总是 `NO`,因为左边一定是 `NSArray` 的子类。 + +## 10. 使用关联对象 + +1. 使用静态全局变量作为键,设置好合适的内存管理语义 + +## 11. objc_msgSend + +1. 大部分消息调用使用了 `objc_msgSend` 函数。对于某些边界情况,运行时环境可能使用一些其他的函数来处理:`objc_msgSend_stret`:如果返回的是结构体,调用这个函数。`objc_msgSend_fpret`:如果返回的是浮点数,调用这个函数。`objc_msgSendSuper`:如果给超类发消息,调用这个函数。 + +## 12. 消息转发 + +1. 分为三个步骤,动态方法解析,快速转发和完整转发 +2. 实现一个“字典”对象:TBD + +## 14. 理解“类对象” + +1. 运行期检视对象类型被称为“内省” +2. 因为类对象是单例,所以可以直接通过 `==` 判断类对象是否相等。但应该避免这么做,推荐使用类型信息查询方法(`isMemberOf` 和 `isKindOf`)。TBD:举例说明 + +# 接口与 API 设计 + +## 15. 用前缀避免命名空间冲突 + +1. 前缀至少是三个字母,两个字母的前缀由 Apple 保留 +2. 全局函数和变量需要注意避免冲突 +3. 在自己开发的库中,为用到的第三方库添加前缀 + +## 16. 全能初始化方法 + +1. 设置一个全能初始化方法,别的初始化方法都调用它 + +## 17. 实现 description 方法 + +1. 实现 `description` 方法,改变 `NSLog` 时的输出结果 +2. 实现 `debugDescription` 方法,改变 `po` 时的输出结果 + +## 18. 尽量使用不可变对象 + +1. 不要把可变的 collection 作为属性公开,应该公开一个不可变的 collection 然后提供相关的修改方法 + +## 19. 命名方式 + +1. 如果返回值是新建的,首个词是返回值类型 +2. 不要使用 `str` 这种简称,使用 `string` +3. `get` 前缀仅在由“输出参数”保存返回值的方法中使用 + +## 21. 错误类型 + +1. 严重的错误可以直接抛出异常(比如禁止调用父类的方法,需要子类重写) +2. 一般的错误使用 `NSError`,指定 domain(全局常量)、错误码(枚举类型)和用户细信息。 + +## 22. NSCopying 协议 + +1. 实现 `NSCopying` 协议,重写 `copyWithZone` 方法。 +2. 容器的拷贝总是浅拷贝,`copy` 与 `mutableCopy` 的区别只是返回对象是否可变。 + +# 协议与分类 + +## 23. 使用委托 + +1. 调用 delegate 中的方法时,总是应该传入发起委托的对象。这样代理对象可以判断不同的委托者。 + +## 24. 使用分类 + +1. 可以把所有的私有方法都归入名叫 Private 的分类中 + +## 25. 为第三方分类添加前缀 + +1. 分类中定义的方法可以多次互相覆盖,以最后一个分类为准 +2. 向第三方类中添加分类时,为分类名称和方法名称添加前缀 + +## 26. 分类中不要声明属性 + +1. 分类中无法创建实例变量 +2. 可以定义存取方法,但是不要定义属性 + + diff --git a/GraphicsPerformance-Starter/GraphicsPerformance-Starter.xcodeproj/project.pbxproj b/GraphicsPerformance-Starter/GraphicsPerformance-Starter.xcodeproj/project.pbxproj index 21b1c1a..9ebffac 100644 --- a/GraphicsPerformance-Starter/GraphicsPerformance-Starter.xcodeproj/project.pbxproj +++ b/GraphicsPerformance-Starter/GraphicsPerformance-Starter.xcodeproj/project.pbxproj @@ -207,16 +207,16 @@ TargetAttributes = { 9BEA051B1C50EFAC0075E954 = { CreatedOnToolsVersion = 7.2; - DevelopmentTeam = U2HX3RFD94; + DevelopmentTeam = FQL8675Q6W; }; 9BEA05311C50EFAC0075E954 = { CreatedOnToolsVersion = 7.2; - DevelopmentTeam = U2HX3RFD94; + DevelopmentTeam = FQL8675Q6W; TestTargetID = 9BEA051B1C50EFAC0075E954; }; 9BEA053C1C50EFAC0075E954 = { CreatedOnToolsVersion = 7.2; - DevelopmentTeam = U2HX3RFD94; + DevelopmentTeam = FQL8675Q6W; TestTargetID = 9BEA051B1C50EFAC0075E954; }; }; @@ -416,10 +416,12 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = FQL8675Q6W; INFOPLIST_FILE = "GraphicsPerformance-Starter/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "NEU.GraphicsPerformance-Starter"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -427,10 +429,12 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = FQL8675Q6W; INFOPLIST_FILE = "GraphicsPerformance-Starter/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "NEU.GraphicsPerformance-Starter"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -438,6 +442,7 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = FQL8675Q6W; INFOPLIST_FILE = "GraphicsPerformance-StarterTests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "NEU.GraphicsPerformance-StarterTests"; @@ -450,6 +455,7 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = FQL8675Q6W; INFOPLIST_FILE = "GraphicsPerformance-StarterTests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "NEU.GraphicsPerformance-StarterTests"; @@ -461,6 +467,7 @@ 9BEA054D1C50EFAC0075E954 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + DEVELOPMENT_TEAM = FQL8675Q6W; INFOPLIST_FILE = "GraphicsPerformance-StarterUITests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "NEU.GraphicsPerformance-StarterUITests"; @@ -473,6 +480,7 @@ 9BEA054E1C50EFAC0075E954 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + DEVELOPMENT_TEAM = FQL8675Q6W; INFOPLIST_FILE = "GraphicsPerformance-StarterUITests/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "NEU.GraphicsPerformance-StarterUITests"; diff --git a/GraphicsPerformance-Starter/GraphicsPerformance-Starter.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/GraphicsPerformance-Starter/GraphicsPerformance-Starter.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/GraphicsPerformance-Starter/GraphicsPerformance-Starter.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/GraphicsPerformance-Starter/GraphicsPerformance-Starter/CustomTableCell.swift b/GraphicsPerformance-Starter/GraphicsPerformance-Starter/CustomTableCell.swift index 9f1ea23..12ce946 100644 --- a/GraphicsPerformance-Starter/GraphicsPerformance-Starter/CustomTableCell.swift +++ b/GraphicsPerformance-Starter/GraphicsPerformance-Starter/CustomTableCell.swift @@ -9,16 +9,16 @@ import UIKit class CustomTableCell: UITableViewCell { - let imgView = UIImageView(frame: CGRectMake(10, 10, 180, 180)) - let label = UILabel(frame: CGRectMake(220, 90, 150, 20)) + let imgView = UIImageView(frame: CGRect(x: 10, y: 10, width: 180, height: 180)) + let label = UILabel(frame: CGRect(x: 220, y: 90, width: 150, height: 20)) override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) - imgView.layer.shadowColor = UIColor.blackColor().CGColor + imgView.layer.shadowColor = UIColor.black.cgColor imgView.layer.shadowOpacity = 1 imgView.layer.shadowRadius = 2 - imgView.layer.shadowOffset = CGSizeMake(1, 1) + imgView.layer.shadowOffset = CGSize(width: 1, height: 1) label.layer.shouldRasterize = true diff --git a/GraphicsPerformance-Starter/GraphicsPerformance-Starter/FirstViewController.swift b/GraphicsPerformance-Starter/GraphicsPerformance-Starter/FirstViewController.swift index b666aaf..2fe9d98 100644 --- a/GraphicsPerformance-Starter/GraphicsPerformance-Starter/FirstViewController.swift +++ b/GraphicsPerformance-Starter/GraphicsPerformance-Starter/FirstViewController.swift @@ -10,7 +10,7 @@ import UIKit class FirstViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { - let table = UITableView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height - 49)) + let table = UITableView(frame: CGRect(x: 0, y:0, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height - 49)) let imgArray = Array(1...10) override func viewDidLoad() { @@ -25,24 +25,25 @@ class FirstViewController: UIViewController, UITableViewDelegate, UITableViewDat override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } + - func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let identifier = "tableviewcell" - var cell = table.dequeueReusableCellWithIdentifier(identifier) as? CustomTableCell + var cell = tableView.dequeueReusableCell(withIdentifier: identifier) as? CustomTableCell if cell == nil { - cell = CustomTableCell(style: .Default, reuseIdentifier: identifier) - cell?.selectionStyle = .None + cell = CustomTableCell(style: .default, reuseIdentifier: identifier) + cell?.selectionStyle = .none } - cell?.setupContent(String(imgArray[indexPath.row]), text: "This is a label") - + cell?.setupContent(imgName: String(imgArray[indexPath.row]), text: "This is a label") + return cell! } - func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 200 } - func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 10 } } diff --git a/KtTableView/KtTableView.xcodeproj/project.pbxproj b/KtTableView/KtTableView.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3c9aa7e --- /dev/null +++ b/KtTableView/KtTableView.xcodeproj/project.pbxproj @@ -0,0 +1,741 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 23BEFFC3FD0E6575D5E56B78 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AFDA0B8A1D36740848D30D13 /* libPods.a */; }; + E108B2A71CBE0A2600191E0B /* KtMainTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E108B2A61CBE0A2600191E0B /* KtMainTableViewCell.m */; }; + E108B2AB1CBE14C300191E0B /* KtTableViewDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = E108B2AA1CBE14C300191E0B /* KtTableViewDataSource.m */; }; + E108B2AE1CBE15D800191E0B /* KtTableViewSectionObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E108B2AD1CBE15D800191E0B /* KtTableViewSectionObject.m */; }; + E108B2B11CBE191300191E0B /* KtBaseTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E108B2B01CBE191300191E0B /* KtBaseTableViewCell.m */; }; + E108B2B41CBE1C9100191E0B /* KtMainTableViewDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = E108B2B31CBE1C9100191E0B /* KtMainTableViewDataSource.m */; }; + E108B2B71CBE1F6500191E0B /* KtTableViewBaseItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E108B2B61CBE1F6500191E0B /* KtTableViewBaseItem.m */; }; + E12A4F5E1CE8180E00AB6F35 /* NSDictionary+KtExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = E12A4F5B1CE8180E00AB6F35 /* NSDictionary+KtExtension.m */; }; + E12A4F5F1CE8180E00AB6F35 /* UIView+KtExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = E12A4F5D1CE8180E00AB6F35 /* UIView+KtExtension.m */; }; + E1621E021CBDF265003D9438 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E1621E011CBDF265003D9438 /* main.m */; }; + E1621E051CBDF267003D9438 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E1621E041CBDF267003D9438 /* AppDelegate.m */; }; + E1621E081CBDF267003D9438 /* KTMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1621E071CBDF267003D9438 /* KTMainViewController.m */; }; + E1621E0B1CBDF267003D9438 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E1621E091CBDF267003D9438 /* Main.storyboard */; }; + E1621E0D1CBDF267003D9438 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E1621E0C1CBDF267003D9438 /* Assets.xcassets */; }; + E1621E101CBDF267003D9438 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E1621E0E1CBDF267003D9438 /* LaunchScreen.storyboard */; }; + E1621E1B1CBDF267003D9438 /* KtTableViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E1621E1A1CBDF267003D9438 /* KtTableViewTests.m */; }; + E1621E261CBDF267003D9438 /* KtTableViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = E1621E251CBDF267003D9438 /* KtTableViewUITests.m */; }; + E19B41191CC21555008A3E7F /* KtTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E19B41181CC21555008A3E7F /* KtTableViewController.m */; }; + E1DCC9EF1CE5A61A00CDC83D /* KtBaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E1DCC9EE1CE5A61A00CDC83D /* KtBaseModel.m */; }; + E1DCC9F21CE5A6A000CDC83D /* KtBaseServerAPI.m in Sources */ = {isa = PBXBuildFile; fileRef = E1DCC9F11CE5A6A000CDC83D /* KtBaseServerAPI.m */; }; + E1DCC9F51CE5A76D00CDC83D /* KtMainTableModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E1DCC9F41CE5A76D00CDC83D /* KtMainTableModel.m */; }; + E1DCC9F81CE5A81000CDC83D /* KtBaseItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E1DCC9F71CE5A81000CDC83D /* KtBaseItem.m */; }; + E1DCC9FB1CE5A99C00CDC83D /* KtMainTableItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E1DCC9FA1CE5A99C00CDC83D /* KtMainTableItem.m */; }; + E1EE5C9D1CBE811C0095688B /* KtBaseTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = E1EE5C9C1CBE811C0095688B /* KtBaseTableView.m */; }; + E1F64E7E1CECB048005800E4 /* KtBaseListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E1F64E7D1CECB048005800E4 /* KtBaseListModel.m */; }; + E1F64E811CECB067005800E4 /* KtBaseListItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E1F64E801CECB067005800E4 /* KtBaseListItem.m */; }; + E1F64F1B1CEE956E005800E4 /* KtRefreshTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1F64F1A1CEE956E005800E4 /* KtRefreshTableViewController.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + E1621E171CBDF267003D9438 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E1621DF51CBDF265003D9438 /* Project object */; + proxyType = 1; + remoteGlobalIDString = E1621DFC1CBDF265003D9438; + remoteInfo = KtTableView; + }; + E1621E221CBDF267003D9438 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E1621DF51CBDF265003D9438 /* Project object */; + proxyType = 1; + remoteGlobalIDString = E1621DFC1CBDF265003D9438; + remoteInfo = KtTableView; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 39F19645603938C8EF7DBFD3 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + 74A2D569E414911E7538367E /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + AFDA0B8A1D36740848D30D13 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + E108B2A51CBE0A2600191E0B /* KtMainTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtMainTableViewCell.h; sourceTree = ""; }; + E108B2A61CBE0A2600191E0B /* KtMainTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtMainTableViewCell.m; sourceTree = ""; }; + E108B2A91CBE14C300191E0B /* KtTableViewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtTableViewDataSource.h; sourceTree = ""; }; + E108B2AA1CBE14C300191E0B /* KtTableViewDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtTableViewDataSource.m; sourceTree = ""; }; + E108B2AC1CBE15D800191E0B /* KtTableViewSectionObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtTableViewSectionObject.h; sourceTree = ""; }; + E108B2AD1CBE15D800191E0B /* KtTableViewSectionObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtTableViewSectionObject.m; sourceTree = ""; }; + E108B2AF1CBE191300191E0B /* KtBaseTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtBaseTableViewCell.h; sourceTree = ""; }; + E108B2B01CBE191300191E0B /* KtBaseTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtBaseTableViewCell.m; sourceTree = ""; }; + E108B2B21CBE1C9100191E0B /* KtMainTableViewDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtMainTableViewDataSource.h; sourceTree = ""; }; + E108B2B31CBE1C9100191E0B /* KtMainTableViewDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtMainTableViewDataSource.m; sourceTree = ""; }; + E108B2B51CBE1F6500191E0B /* KtTableViewBaseItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtTableViewBaseItem.h; sourceTree = ""; }; + E108B2B61CBE1F6500191E0B /* KtTableViewBaseItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtTableViewBaseItem.m; sourceTree = ""; }; + E12A4F5A1CE8180E00AB6F35 /* NSDictionary+KtExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+KtExtension.h"; sourceTree = ""; }; + E12A4F5B1CE8180E00AB6F35 /* NSDictionary+KtExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+KtExtension.m"; sourceTree = ""; }; + E12A4F5C1CE8180E00AB6F35 /* UIView+KtExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+KtExtension.h"; sourceTree = ""; }; + E12A4F5D1CE8180E00AB6F35 /* UIView+KtExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+KtExtension.m"; sourceTree = ""; }; + E1621DFD1CBDF265003D9438 /* KtTableView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = KtTableView.app; sourceTree = BUILT_PRODUCTS_DIR; }; + E1621E011CBDF265003D9438 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + E1621E031CBDF267003D9438 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + E1621E041CBDF267003D9438 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + E1621E061CBDF267003D9438 /* KTMainViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KTMainViewController.h; sourceTree = ""; }; + E1621E071CBDF267003D9438 /* KTMainViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KTMainViewController.m; sourceTree = ""; }; + E1621E0A1CBDF267003D9438 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + E1621E0C1CBDF267003D9438 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + E1621E0F1CBDF267003D9438 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + E1621E111CBDF267003D9438 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E1621E161CBDF267003D9438 /* KtTableViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KtTableViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + E1621E1A1CBDF267003D9438 /* KtTableViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KtTableViewTests.m; sourceTree = ""; }; + E1621E1C1CBDF267003D9438 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E1621E211CBDF267003D9438 /* KtTableViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KtTableViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + E1621E251CBDF267003D9438 /* KtTableViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KtTableViewUITests.m; sourceTree = ""; }; + E1621E271CBDF267003D9438 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E19B41171CC21555008A3E7F /* KtTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtTableViewController.h; sourceTree = ""; }; + E19B41181CC21555008A3E7F /* KtTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtTableViewController.m; sourceTree = ""; }; + E1DCC9ED1CE5A61A00CDC83D /* KtBaseModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtBaseModel.h; sourceTree = ""; }; + E1DCC9EE1CE5A61A00CDC83D /* KtBaseModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtBaseModel.m; sourceTree = ""; }; + E1DCC9F01CE5A6A000CDC83D /* KtBaseServerAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtBaseServerAPI.h; sourceTree = ""; }; + E1DCC9F11CE5A6A000CDC83D /* KtBaseServerAPI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtBaseServerAPI.m; sourceTree = ""; }; + E1DCC9F31CE5A76D00CDC83D /* KtMainTableModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtMainTableModel.h; sourceTree = ""; }; + E1DCC9F41CE5A76D00CDC83D /* KtMainTableModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtMainTableModel.m; sourceTree = ""; }; + E1DCC9F61CE5A81000CDC83D /* KtBaseItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtBaseItem.h; sourceTree = ""; }; + E1DCC9F71CE5A81000CDC83D /* KtBaseItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtBaseItem.m; sourceTree = ""; }; + E1DCC9F91CE5A99C00CDC83D /* KtMainTableItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtMainTableItem.h; sourceTree = ""; }; + E1DCC9FA1CE5A99C00CDC83D /* KtMainTableItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtMainTableItem.m; sourceTree = ""; }; + E1EE5C9B1CBE811C0095688B /* KtBaseTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtBaseTableView.h; sourceTree = ""; }; + E1EE5C9C1CBE811C0095688B /* KtBaseTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtBaseTableView.m; sourceTree = ""; }; + E1F64E7C1CECB048005800E4 /* KtBaseListModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtBaseListModel.h; sourceTree = ""; }; + E1F64E7D1CECB048005800E4 /* KtBaseListModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtBaseListModel.m; sourceTree = ""; }; + E1F64E7F1CECB067005800E4 /* KtBaseListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtBaseListItem.h; sourceTree = ""; }; + E1F64E801CECB067005800E4 /* KtBaseListItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtBaseListItem.m; sourceTree = ""; }; + E1F64F191CEE956E005800E4 /* KtRefreshTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KtRefreshTableViewController.h; sourceTree = ""; }; + E1F64F1A1CEE956E005800E4 /* KtRefreshTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KtRefreshTableViewController.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + E1621DFA1CBDF265003D9438 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 23BEFFC3FD0E6575D5E56B78 /* libPods.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E1621E131CBDF267003D9438 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E1621E1E1CBDF267003D9438 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 69E01484FD4E182CB56A5FE6 /* Pods */ = { + isa = PBXGroup; + children = ( + 74A2D569E414911E7538367E /* Pods.debug.xcconfig */, + 39F19645603938C8EF7DBFD3 /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + E108B2A81CBE148200191E0B /* KtBaseTableViewController */ = { + isa = PBXGroup; + children = ( + E108B2A91CBE14C300191E0B /* KtTableViewDataSource.h */, + E108B2AA1CBE14C300191E0B /* KtTableViewDataSource.m */, + E108B2AF1CBE191300191E0B /* KtBaseTableViewCell.h */, + E108B2B01CBE191300191E0B /* KtBaseTableViewCell.m */, + E108B2AC1CBE15D800191E0B /* KtTableViewSectionObject.h */, + E108B2AD1CBE15D800191E0B /* KtTableViewSectionObject.m */, + E108B2B51CBE1F6500191E0B /* KtTableViewBaseItem.h */, + E108B2B61CBE1F6500191E0B /* KtTableViewBaseItem.m */, + E1EE5C9B1CBE811C0095688B /* KtBaseTableView.h */, + E1EE5C9C1CBE811C0095688B /* KtBaseTableView.m */, + E19B41171CC21555008A3E7F /* KtTableViewController.h */, + E19B41181CC21555008A3E7F /* KtTableViewController.m */, + ); + name = KtBaseTableViewController; + sourceTree = ""; + }; + E12A4F591CE8180E00AB6F35 /* KtExtension */ = { + isa = PBXGroup; + children = ( + E12A4F5A1CE8180E00AB6F35 /* NSDictionary+KtExtension.h */, + E12A4F5B1CE8180E00AB6F35 /* NSDictionary+KtExtension.m */, + E12A4F5C1CE8180E00AB6F35 /* UIView+KtExtension.h */, + E12A4F5D1CE8180E00AB6F35 /* UIView+KtExtension.m */, + ); + path = KtExtension; + sourceTree = ""; + }; + E1621DF41CBDF265003D9438 = { + isa = PBXGroup; + children = ( + E1621DFF1CBDF265003D9438 /* KtTableView */, + E1621E191CBDF267003D9438 /* KtTableViewTests */, + E1621E241CBDF267003D9438 /* KtTableViewUITests */, + E1621DFE1CBDF265003D9438 /* Products */, + 69E01484FD4E182CB56A5FE6 /* Pods */, + F71B31402A7F180F563A44F9 /* Frameworks */, + ); + sourceTree = ""; + }; + E1621DFE1CBDF265003D9438 /* Products */ = { + isa = PBXGroup; + children = ( + E1621DFD1CBDF265003D9438 /* KtTableView.app */, + E1621E161CBDF267003D9438 /* KtTableViewTests.xctest */, + E1621E211CBDF267003D9438 /* KtTableViewUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + E1621DFF1CBDF265003D9438 /* KtTableView */ = { + isa = PBXGroup; + children = ( + E12A4F591CE8180E00AB6F35 /* KtExtension */, + E1DCC9EC1CE5A5FA00CDC83D /* KtBaseModel */, + E108B2A81CBE148200191E0B /* KtBaseTableViewController */, + E1621E031CBDF267003D9438 /* AppDelegate.h */, + E1621E041CBDF267003D9438 /* AppDelegate.m */, + E1621E061CBDF267003D9438 /* KTMainViewController.h */, + E1621E071CBDF267003D9438 /* KTMainViewController.m */, + E1DCC9F31CE5A76D00CDC83D /* KtMainTableModel.h */, + E1DCC9F41CE5A76D00CDC83D /* KtMainTableModel.m */, + E1DCC9F91CE5A99C00CDC83D /* KtMainTableItem.h */, + E1DCC9FA1CE5A99C00CDC83D /* KtMainTableItem.m */, + E108B2B21CBE1C9100191E0B /* KtMainTableViewDataSource.h */, + E108B2B31CBE1C9100191E0B /* KtMainTableViewDataSource.m */, + E108B2A51CBE0A2600191E0B /* KtMainTableViewCell.h */, + E108B2A61CBE0A2600191E0B /* KtMainTableViewCell.m */, + E1621E091CBDF267003D9438 /* Main.storyboard */, + E1621E0C1CBDF267003D9438 /* Assets.xcassets */, + E1621E0E1CBDF267003D9438 /* LaunchScreen.storyboard */, + E1621E111CBDF267003D9438 /* Info.plist */, + E1621E001CBDF265003D9438 /* Supporting Files */, + ); + path = KtTableView; + sourceTree = ""; + }; + E1621E001CBDF265003D9438 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + E1621E011CBDF265003D9438 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + E1621E191CBDF267003D9438 /* KtTableViewTests */ = { + isa = PBXGroup; + children = ( + E1621E1A1CBDF267003D9438 /* KtTableViewTests.m */, + E1621E1C1CBDF267003D9438 /* Info.plist */, + ); + path = KtTableViewTests; + sourceTree = ""; + }; + E1621E241CBDF267003D9438 /* KtTableViewUITests */ = { + isa = PBXGroup; + children = ( + E1621E251CBDF267003D9438 /* KtTableViewUITests.m */, + E1621E271CBDF267003D9438 /* Info.plist */, + ); + path = KtTableViewUITests; + sourceTree = ""; + }; + E1DCC9EC1CE5A5FA00CDC83D /* KtBaseModel */ = { + isa = PBXGroup; + children = ( + E1F64E7B1CECB02E005800E4 /* KtBaseListModel */, + E1DCC9ED1CE5A61A00CDC83D /* KtBaseModel.h */, + E1DCC9EE1CE5A61A00CDC83D /* KtBaseModel.m */, + E1DCC9F61CE5A81000CDC83D /* KtBaseItem.h */, + E1DCC9F71CE5A81000CDC83D /* KtBaseItem.m */, + E1DCC9F01CE5A6A000CDC83D /* KtBaseServerAPI.h */, + E1DCC9F11CE5A6A000CDC83D /* KtBaseServerAPI.m */, + ); + path = KtBaseModel; + sourceTree = ""; + }; + E1F64E7B1CECB02E005800E4 /* KtBaseListModel */ = { + isa = PBXGroup; + children = ( + E1F64E7F1CECB067005800E4 /* KtBaseListItem.h */, + E1F64E801CECB067005800E4 /* KtBaseListItem.m */, + E1F64E7C1CECB048005800E4 /* KtBaseListModel.h */, + E1F64E7D1CECB048005800E4 /* KtBaseListModel.m */, + E1F64F191CEE956E005800E4 /* KtRefreshTableViewController.h */, + E1F64F1A1CEE956E005800E4 /* KtRefreshTableViewController.m */, + ); + path = KtBaseListModel; + sourceTree = ""; + }; + F71B31402A7F180F563A44F9 /* Frameworks */ = { + isa = PBXGroup; + children = ( + AFDA0B8A1D36740848D30D13 /* libPods.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + E1621DFC1CBDF265003D9438 /* KtTableView */ = { + isa = PBXNativeTarget; + buildConfigurationList = E1621E2A1CBDF267003D9438 /* Build configuration list for PBXNativeTarget "KtTableView" */; + buildPhases = ( + 6AAF7A2D573159A8A4997064 /* Check Pods Manifest.lock */, + E1621DF91CBDF265003D9438 /* Sources */, + E1621DFA1CBDF265003D9438 /* Frameworks */, + E1621DFB1CBDF265003D9438 /* Resources */, + 9C241BAA28F98CD40C517EAB /* Embed Pods Frameworks */, + F726984500B073E1BC60B240 /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = KtTableView; + productName = KtTableView; + productReference = E1621DFD1CBDF265003D9438 /* KtTableView.app */; + productType = "com.apple.product-type.application"; + }; + E1621E151CBDF267003D9438 /* KtTableViewTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = E1621E2D1CBDF267003D9438 /* Build configuration list for PBXNativeTarget "KtTableViewTests" */; + buildPhases = ( + E1621E121CBDF267003D9438 /* Sources */, + E1621E131CBDF267003D9438 /* Frameworks */, + E1621E141CBDF267003D9438 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + E1621E181CBDF267003D9438 /* PBXTargetDependency */, + ); + name = KtTableViewTests; + productName = KtTableViewTests; + productReference = E1621E161CBDF267003D9438 /* KtTableViewTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + E1621E201CBDF267003D9438 /* KtTableViewUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = E1621E301CBDF267003D9438 /* Build configuration list for PBXNativeTarget "KtTableViewUITests" */; + buildPhases = ( + E1621E1D1CBDF267003D9438 /* Sources */, + E1621E1E1CBDF267003D9438 /* Frameworks */, + E1621E1F1CBDF267003D9438 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + E1621E231CBDF267003D9438 /* PBXTargetDependency */, + ); + name = KtTableViewUITests; + productName = KtTableViewUITests; + productReference = E1621E211CBDF267003D9438 /* KtTableViewUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + E1621DF51CBDF265003D9438 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0730; + ORGANIZATIONNAME = zxy; + TargetAttributes = { + E1621DFC1CBDF265003D9438 = { + CreatedOnToolsVersion = 7.3; + }; + E1621E151CBDF267003D9438 = { + CreatedOnToolsVersion = 7.3; + TestTargetID = E1621DFC1CBDF265003D9438; + }; + E1621E201CBDF267003D9438 = { + CreatedOnToolsVersion = 7.3; + TestTargetID = E1621DFC1CBDF265003D9438; + }; + }; + }; + buildConfigurationList = E1621DF81CBDF265003D9438 /* Build configuration list for PBXProject "KtTableView" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = E1621DF41CBDF265003D9438; + productRefGroup = E1621DFE1CBDF265003D9438 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + E1621DFC1CBDF265003D9438 /* KtTableView */, + E1621E151CBDF267003D9438 /* KtTableViewTests */, + E1621E201CBDF267003D9438 /* KtTableViewUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + E1621DFB1CBDF265003D9438 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E1621E101CBDF267003D9438 /* LaunchScreen.storyboard in Resources */, + E1621E0D1CBDF267003D9438 /* Assets.xcassets in Resources */, + E1621E0B1CBDF267003D9438 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E1621E141CBDF267003D9438 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E1621E1F1CBDF267003D9438 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 6AAF7A2D573159A8A4997064 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 9C241BAA28F98CD40C517EAB /* Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + F726984500B073E1BC60B240 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + E1621DF91CBDF265003D9438 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E12A4F5E1CE8180E00AB6F35 /* NSDictionary+KtExtension.m in Sources */, + E1DCC9F81CE5A81000CDC83D /* KtBaseItem.m in Sources */, + E19B41191CC21555008A3E7F /* KtTableViewController.m in Sources */, + E12A4F5F1CE8180E00AB6F35 /* UIView+KtExtension.m in Sources */, + E108B2B41CBE1C9100191E0B /* KtMainTableViewDataSource.m in Sources */, + E108B2AB1CBE14C300191E0B /* KtTableViewDataSource.m in Sources */, + E108B2B71CBE1F6500191E0B /* KtTableViewBaseItem.m in Sources */, + E108B2B11CBE191300191E0B /* KtBaseTableViewCell.m in Sources */, + E1F64F1B1CEE956E005800E4 /* KtRefreshTableViewController.m in Sources */, + E1F64E811CECB067005800E4 /* KtBaseListItem.m in Sources */, + E1DCC9EF1CE5A61A00CDC83D /* KtBaseModel.m in Sources */, + E1DCC9F21CE5A6A000CDC83D /* KtBaseServerAPI.m in Sources */, + E1621E081CBDF267003D9438 /* KTMainViewController.m in Sources */, + E1DCC9FB1CE5A99C00CDC83D /* KtMainTableItem.m in Sources */, + E1F64E7E1CECB048005800E4 /* KtBaseListModel.m in Sources */, + E1EE5C9D1CBE811C0095688B /* KtBaseTableView.m in Sources */, + E1621E051CBDF267003D9438 /* AppDelegate.m in Sources */, + E108B2AE1CBE15D800191E0B /* KtTableViewSectionObject.m in Sources */, + E1DCC9F51CE5A76D00CDC83D /* KtMainTableModel.m in Sources */, + E1621E021CBDF265003D9438 /* main.m in Sources */, + E108B2A71CBE0A2600191E0B /* KtMainTableViewCell.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E1621E121CBDF267003D9438 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E1621E1B1CBDF267003D9438 /* KtTableViewTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E1621E1D1CBDF267003D9438 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E1621E261CBDF267003D9438 /* KtTableViewUITests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + E1621E181CBDF267003D9438 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = E1621DFC1CBDF265003D9438 /* KtTableView */; + targetProxy = E1621E171CBDF267003D9438 /* PBXContainerItemProxy */; + }; + E1621E231CBDF267003D9438 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = E1621DFC1CBDF265003D9438 /* KtTableView */; + targetProxy = E1621E221CBDF267003D9438 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + E1621E091CBDF267003D9438 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + E1621E0A1CBDF267003D9438 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + E1621E0E1CBDF267003D9438 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + E1621E0F1CBDF267003D9438 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + E1621E281CBDF267003D9438 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + E1621E291CBDF267003D9438 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + E1621E2B1CBDF267003D9438 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 74A2D569E414911E7538367E /* Pods.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = KtTableView/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = kt.bestswifter.KtTableView; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + E1621E2C1CBDF267003D9438 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 39F19645603938C8EF7DBFD3 /* Pods.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = KtTableView/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = kt.bestswifter.KtTableView; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + E1621E2E1CBDF267003D9438 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = KtTableViewTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = kt.bestswifter.KtTableViewTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KtTableView.app/KtTableView"; + }; + name = Debug; + }; + E1621E2F1CBDF267003D9438 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = KtTableViewTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = kt.bestswifter.KtTableViewTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KtTableView.app/KtTableView"; + }; + name = Release; + }; + E1621E311CBDF267003D9438 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = KtTableViewUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = kt.bestswifter.KtTableViewUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_TARGET_NAME = KtTableView; + }; + name = Debug; + }; + E1621E321CBDF267003D9438 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = KtTableViewUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = kt.bestswifter.KtTableViewUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_TARGET_NAME = KtTableView; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + E1621DF81CBDF265003D9438 /* Build configuration list for PBXProject "KtTableView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E1621E281CBDF267003D9438 /* Debug */, + E1621E291CBDF267003D9438 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E1621E2A1CBDF267003D9438 /* Build configuration list for PBXNativeTarget "KtTableView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E1621E2B1CBDF267003D9438 /* Debug */, + E1621E2C1CBDF267003D9438 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E1621E2D1CBDF267003D9438 /* Build configuration list for PBXNativeTarget "KtTableViewTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E1621E2E1CBDF267003D9438 /* Debug */, + E1621E2F1CBDF267003D9438 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E1621E301CBDF267003D9438 /* Build configuration list for PBXNativeTarget "KtTableViewUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E1621E311CBDF267003D9438 /* Debug */, + E1621E321CBDF267003D9438 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = E1621DF51CBDF265003D9438 /* Project object */; +} diff --git a/KtTableView/KtTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/KtTableView/KtTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ea1aed7 --- /dev/null +++ b/KtTableView/KtTableView.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/KtTableView/KtTableView.xcworkspace/contents.xcworkspacedata b/KtTableView/KtTableView.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..91f599a --- /dev/null +++ b/KtTableView/KtTableView.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/KtTableView/KtTableView/AppDelegate.h b/KtTableView/KtTableView/AppDelegate.h new file mode 100644 index 0000000..fd39de6 --- /dev/null +++ b/KtTableView/KtTableView/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/KtTableView/KtTableView/AppDelegate.m b/KtTableView/KtTableView/AppDelegate.m new file mode 100644 index 0000000..877622a --- /dev/null +++ b/KtTableView/KtTableView/AppDelegate.m @@ -0,0 +1,48 @@ +// +// AppDelegate.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "AppDelegate.h" +#import "KTMainViewController.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + KTMainViewController *mainVC = [[KTMainViewController alloc] initWithStyle:UITableViewStylePlain]; + [self.window setRootViewController: mainVC]; + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/KtTableView/KtTableView/Assets.xcassets/AppIcon.appiconset/Contents.json b/KtTableView/KtTableView/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..eeea76c --- /dev/null +++ b/KtTableView/KtTableView/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,73 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/KtTableView/KtTableView/Base.lproj/LaunchScreen.storyboard b/KtTableView/KtTableView/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..2e721e1 --- /dev/null +++ b/KtTableView/KtTableView/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/KtTableView/KtTableView/Base.lproj/Main.storyboard b/KtTableView/KtTableView/Base.lproj/Main.storyboard new file mode 100644 index 0000000..c51943a --- /dev/null +++ b/KtTableView/KtTableView/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/KtTableView/KtTableView/Info.plist b/KtTableView/KtTableView/Info.plist new file mode 100644 index 0000000..028efc3 --- /dev/null +++ b/KtTableView/KtTableView/Info.plist @@ -0,0 +1,52 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/KtTableView/KtTableView/KTMainViewController.h b/KtTableView/KtTableView/KTMainViewController.h new file mode 100644 index 0000000..d1b62a2 --- /dev/null +++ b/KtTableView/KtTableView/KTMainViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import "KtRefreshTableViewController.h" + +@interface KTMainViewController : KtRefreshTableViewController + +@end + diff --git a/KtTableView/KtTableView/KTMainViewController.m b/KtTableView/KtTableView/KTMainViewController.m new file mode 100644 index 0000000..244d187 --- /dev/null +++ b/KtTableView/KtTableView/KTMainViewController.m @@ -0,0 +1,43 @@ +// +// ViewController.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KTMainViewController.h" +#import "KtMainTableViewCell.h" +#import "KtMainTableViewDataSource.h" + +#import "AFNetworking.h" +#import "KtTableViewBaseItem.h" +#import "KtMainTableModel.h" + +#import "MJRefresh.h" + +@implementation KTMainViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self createModel]; +} + +- (void)createModel { + self.listModel = [[KtMainTableModel alloc] initWithAddress:@"/mooclist.php"]; + self.listModel.delegate = self; +} + +- (void)createDataSource { + self.dataSource = [[KtMainTableViewDataSource alloc] init]; // 这一步创建了数据源 +} + +- (void)requestDidSuccess { + for (KtMainTableBookItem *book in ((KtMainTableModel *)self.listModel).tableViewItem.books) { + KtTableViewBaseItem *item = [[KtTableViewBaseItem alloc] init]; + item.itemTitle = book.bookTitle; + [self.dataSource appendItem:item]; + } +} + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseItem.h b/KtTableView/KtTableView/KtBaseModel/KtBaseItem.h new file mode 100644 index 0000000..afe66fa --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseItem.h @@ -0,0 +1,32 @@ +// +// KtBaseItem.h +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface KtBaseItem : NSObject + +- (id)initWithData:(NSDictionary *)data; + +// property中如有包含TBCBaseListItem对象的数组,需要设定此规则 +- (void)addMappingRuleArrayProperty:(NSString*)propertyName class:(Class)cls; +// 所有需要映射的property都需要设定此规则 +- (void)addMappingRuleProperty:(NSString*)propertyName pathInJson:(NSString*)path; + +- (id)setData:(id)data; + +@end + +@interface KtClassHelper : NSObject + ++ (KtClassHelper *)sharedInstance; + +@property (nonatomic, retain) NSMutableDictionary *propertyListCache; + +- (NSDictionary *)propertyList:(Class)cls; + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseItem.m b/KtTableView/KtTableView/KtBaseModel/KtBaseItem.m new file mode 100644 index 0000000..c6aa111 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseItem.m @@ -0,0 +1,228 @@ +// +// KtBaseItem.m +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseItem.h" +#import +#import "NSDictionary+KtExtension.h" + +@interface KtBaseItem () + +@property (strong, nonatomic) NSMutableDictionary *jsonDataMap; +@property (strong, nonatomic) NSMutableDictionary *jsonArrayClassMap; + +@end + +@implementation KtBaseItem + +- (id)init { + if (self = [super init]) { + _jsonDataMap = [[NSMutableDictionary alloc] init]; + _jsonArrayClassMap = [[NSMutableDictionary alloc] init]; + } + return self; +} + +- (id)initWithData:(NSDictionary *)data { + if (self = [self init]) { + [self setData:data]; + } + return self; +} + +- (id)setData:(id)data { + if (nil == data) { + return self; + } + [self parseData:data]; + return self; +} + +- (void)parseData:(NSDictionary *)data { + Class cls = [self class]; + while (cls != [KtBaseItem class]) { + NSDictionary *propertyList = [[KtClassHelper sharedInstance] propertyList:cls]; + for (NSString *key in [propertyList allKeys]) { + NSString *typeString = [propertyList objectForKey:key]; + NSString* path = [self.jsonDataMap objectForKey:key]; + id value = [data objectAtPath:path]; + + [self setfieldName:key fieldClassName:typeString value:value]; + } + cls = class_getSuperclass(cls); + } +} + +- (void)setfieldName:(NSString*)name fieldClassName:(NSString*)className value:(id)value { + if (value == nil) { + return; + } + //如果结构里嵌套了TBCBaseListItem 也解析 + if ([NSClassFromString(className) isSubclassOfClass:[KtBaseItem class]]) { + Class entityClass = NSClassFromString(className); + if ([value isKindOfClass:[NSString class]]) { + NSString *str = (NSString *)value; + if (str && str.length == 0) { + return; + } + } + if ([value isKindOfClass:[NSArray class]]) { + NSArray *arr = (NSArray *)value; + if (arr && [arr count] == 0) { + return; + } + } + if (entityClass) { + KtBaseItem* entityInstance = [[entityClass alloc] init]; + [entityInstance parseData:value]; + [self setValue:entityInstance forKey:name]; + } + } + else if (![value isKindOfClass:NSClassFromString(className)]) + { + if ([value isKindOfClass:[NSString class]] && NSClassFromString(className) == [NSNumber class]) { + [self setValue:[NSNumber numberWithInteger:[(NSString *)value integerValue]] forKey:name]; + }else if ([value isKindOfClass:[NSNumber class]] && NSClassFromString(className) == [NSString class]){ + [self setValue:[(NSNumber *)value stringValue] forKey:name]; + } + return; + } + //如果是array判断array内类型 + else if ([NSClassFromString(className) isSubclassOfClass:[NSArray class]]) + { + NSString* typeName = [_jsonArrayClassMap objectForKey:name]; + if (typeName) + { + //json中不是array 类型错误 + if (![value isKindOfClass:[NSArray class]]) { + return; + } + Class entityClass = NSClassFromString(typeName); + //entiyClass不存在 + if (!entityClass) { + return; + } + //entiyClass不是TBCJsonEntityBase的子类 + if (![entityClass isSubclassOfClass:[KtBaseItem class]]) { + return; + } + NSMutableArray* mutableArr = [[NSMutableArray alloc] initWithCapacity:[(NSArray*)value count]]; + for (NSDictionary*dict in (NSArray*)value ) { + //arry中存的不是dict + if (![dict isKindOfClass:[NSDictionary class]]) { + return; + } + KtBaseItem* entityInstance = [[entityClass alloc] init]; + + [entityInstance parseData:dict]; + if (entityInstance) { + [mutableArr addObject:entityInstance]; + } + } + [self setValue:mutableArr forKey:name]; + } + else + { + [self setValue:value forKey:name]; + } + } + //正常情况 + else + { + [self setValue:value forKey:name]; + } +} + +#pragma -mark 映射规则 +- (void)addMappingRuleProperty:(NSString*)propertyName pathInJson:(NSString*)path { + [_jsonDataMap setObject:path forKey:propertyName]; +} + +- (NSString *)getPahtForDataMapWithKey:(NSString *)aKey { + if (aKey == nil) { + return nil; + } + return [_jsonDataMap objectForKey:aKey]; +} + +- (NSString *)mappingRuleWithKey:(NSString *)aKey { + if (aKey == nil) { + return nil; + } + return [_jsonArrayClassMap objectForKey:aKey]; +} + +- (void)addMappingRuleArrayProperty:(NSString*)propertyName class:(Class)cls { + [_jsonArrayClassMap setObject:NSStringFromClass(cls) forKey:propertyName]; +} + +@end + +@implementation KtClassHelper +{ + NSRecursiveLock *_propertyListCacheLock; +} + ++ (void)load +{ + [self sharedInstance]; +} + + ++ (KtClassHelper *)sharedInstance { + static dispatch_once_t once; + static KtClassHelper * singleton; + dispatch_once( &once, ^{ singleton = [[KtClassHelper alloc] init]; } ); + return singleton; +} + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.propertyListCache = [NSMutableDictionary dictionary]; + _propertyListCacheLock = [[NSRecursiveLock alloc] init]; + } + return self; +} + +- (NSDictionary *)propertyList:(Class)cls +{ + if (cls == NULL){ + return nil; + } + + [_propertyListCacheLock lock]; + + NSString *clsName = NSStringFromClass(cls); + NSDictionary *cachePropertyList = [self.propertyListCache objectForKey:clsName]; + if (cachePropertyList) { + [_propertyListCacheLock unlock]; + return cachePropertyList; + } + + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + unsigned int propertyCount = 0; + objc_property_t *propertyList = class_copyPropertyList(cls, &propertyCount);//获取cls 类成员变量列表 + for (unsigned i = 0; i < propertyCount; i++) { + objc_property_t property = propertyList[i]; + const char *attr = property_getAttributes(property); //取得这个变量的类型 + NSString *attrString = [NSString stringWithUTF8String:attr]; + NSString *typeAttr = [[attrString componentsSeparatedByString:@","] objectAtIndex:0]; + if(typeAttr.length < 8) continue; + NSString *typeString = [typeAttr substringWithRange:NSMakeRange(3, typeAttr.length - 4)]; + NSString *key = [NSString stringWithUTF8String:property_getName(property)];//取得这个变量的名称 + [dict setObject:typeString forKey:key]; + } + free(propertyList); + [self.propertyListCache setObject:dict forKey:clsName]; + + [_propertyListCacheLock unlock]; + return dict; +} + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListItem.h b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListItem.h new file mode 100644 index 0000000..b7c426c --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListItem.h @@ -0,0 +1,17 @@ +// +// KtBaseListItem.h +// KtTableView +// +// Created by bestswifter on 16/5/18. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseItem.h" + +@interface KtBaseListItem : KtBaseItem + +//@property (nonatomic, assign) int hasNext; +//@property (nonatomic, assign) int hasPrev; +@property (nonatomic, assign) int pageNumber; // 为了简化问题,我们让客户端直接传这个值,其实应该用上面两个。 + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListItem.m b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListItem.m new file mode 100644 index 0000000..a2bccea --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListItem.m @@ -0,0 +1,20 @@ +// +// KtBaseListItem.m +// KtTableView +// +// Created by bestswifter on 16/5/18. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseListItem.h" + +@implementation KtBaseListItem + +- (id)initWithData:(NSDictionary *)data { + if (self = [super initWithData:data]) { + self.pageNumber = [[NSString stringWithFormat:@"%@", [data objectForKey:@"page_number"]] intValue]; + } + return self; +} + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListModel.h b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListModel.h new file mode 100644 index 0000000..95f0261 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListModel.h @@ -0,0 +1,35 @@ +// +// KtBaseListModel.h +// KtTableView +// +// Created by bestswifter on 16/5/18. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseModel.h" +#import "KtBaseListItem.h" + +@protocol KtBaseListModelProtocol + +@required +- (void)refreshRequestDidSuccess; +- (void)loadRequestDidSuccess; +- (void)didLoadLastPage; +- (void)handleAfterRequestFinish; // 请求结束后的操作,刷新tableview或关闭动画等。 + +@optional +- (void)didLoadFirstPage; + +@end + +@interface KtBaseListModel : KtBaseModel + +@property (nonatomic, strong) KtBaseListItem *listItem; +@property (nonatomic, weak) id delegate; +@property (nonatomic, assign) BOOL isRefresh; // 如果为是,表示刷新,否则为加载。 + +- (void)loadPage:(int)pageNumber; +- (void)loadNextPage; +- (void)loadPreviousPage; + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListModel.m b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListModel.m new file mode 100644 index 0000000..a2ccd37 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtBaseListModel.m @@ -0,0 +1,96 @@ +// +// KtBaseListModel.m +// KtTableView +// +// Created by bestswifter on 16/5/18. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseListModel.h" + +@interface KtBaseListModel () + +@property (nonatomic, assign) int currentPage; +@property (nonatomic, strong) NSCache *cache; // 目前先用系统的缓存来代替 + +@end + +@implementation KtBaseListModel + +- (id)initWithAddress:(NSString *)address { + self = [super initWithAddress:address]; + if (self) { + self.currentPage = 0; + self.cache = [[NSCache alloc] init]; + } + return self; +} + +- (void)setDelegate:(id)delegate { + _delegate = delegate; + __weak typeof(self)wself = self; + [self setCompletionBlock:^(KtBaseModel *model) { + typeof(self)sself = wself; + if (sself.isRefresh && [sself.delegate respondsToSelector:@selector(refreshRequestDidSuccess)]) { + [sself.delegate refreshRequestDidSuccess]; + } + else if (!sself.isRefresh && [sself.delegate respondsToSelector:@selector(refreshRequestDidSuccess)]) { + [sself.delegate loadRequestDidSuccess]; + } + [sself.delegate handleAfterRequestFinish]; + sself.isRefresh = NO; + }]; +} + +- (void)handleParsedData:(KtBaseItem *)parsedData { + if ([parsedData isKindOfClass:[KtBaseListItem class]]) { + self.listItem = (KtBaseListItem *)parsedData; + [self.cache setObject:self.listItem forKey:[NSString stringWithFormat:@"%d", self.currentPage]]; + } +} + +- (void)loadPage:(int)pageNumber { + NSMutableDictionary *newDic = [NSMutableDictionary dictionaryWithDictionary:self.params]; + [newDic setObject:@(pageNumber) forKey:@"nextPage"]; + self.params = newDic; + + self.currentPage = pageNumber; + KtBaseListItem *cachedItem = [self.cache objectForKey:[NSString stringWithFormat:@"%d", self.currentPage]]; + if (cachedItem) { + [self handleParsedData:cachedItem]; + self.completionBlock(self); + } + else { + [self loadWithShortConnection]; + } +} + +- (void)loadNextPage { + self.isRefresh = NO; + if (self.currentPage < self.listItem.pageNumber) { + ++self.currentPage; + [self loadPage:self.currentPage]; + } + else { + // 没有更多了。 + [self.delegate didLoadLastPage]; + } +} + +- (void)loadPreviousPage { + self.isRefresh = NO; + if (self.currentPage > 0) { + --self.currentPage; + [self loadPage:self.currentPage]; + } + else { + [self refresh]; // 如果现在是第一页,就只刷新 + } +} + +- (void)refresh { + self.isRefresh = YES; + [self loadPage:0]; +} + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtRefreshTableViewController.h b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtRefreshTableViewController.h new file mode 100644 index 0000000..79fcc66 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtRefreshTableViewController.h @@ -0,0 +1,18 @@ +// +// KtRefreshTableViewController.h +// KtTableView +// +// Created by bestswifter on 16/5/20. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtTableViewController.h" +#import "KtBaseListModel.h" + +@interface KtRefreshTableViewController : KtTableViewController + +@property (nonatomic, strong) KtBaseListModel *listModel; + +- (void)requestDidSuccess; // 子类请求完成后的处理方法。 + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtRefreshTableViewController.m b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtRefreshTableViewController.m new file mode 100644 index 0000000..611e4fe --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseListModel/KtRefreshTableViewController.m @@ -0,0 +1,49 @@ +// +// KtRefreshTableViewController.m +// KtTableView +// +// Created by bestswifter on 16/5/20. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtRefreshTableViewController.h" +#import "MJRefresh.h" + +@implementation KtRefreshTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.tableView.isNeedPullUpToRefreshAction = YES; + self.tableView.isNeedPullDownToRefreshAction = YES; +} + +#pragma -mark KtBaseListModelProtocol +- (void)loadRequestDidSuccess { + [self requestDidSuccess]; +} + +- (void)refreshRequestDidSuccess { + [self.dataSource clearAllItems]; + [self requestDidSuccess]; +} + +- (void)handleAfterRequestFinish { + [self.tableView stopRefreshingAnimation]; + [self.tableView reloadData]; +} + +- (void)didLoadLastPage { + [self.tableView.mj_footer endRefreshingWithNoMoreData]; +} + +#pragma -mark KtTableViewDelegate +- (void)pullUpToRefreshAction { + [self.listModel loadNextPage]; +} + +- (void)pullDownToRefreshAction { + [self.listModel refresh]; +} + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseModel.h b/KtTableView/KtTableView/KtBaseModel/KtBaseModel.h new file mode 100644 index 0000000..e0348d1 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseModel.h @@ -0,0 +1,46 @@ +// +// KtBaseModel.h +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +#import "KtBaseServerAPI.h" +#import "KtBaseItem.h" + +@class KtBaseModel; + +/*! + @brief 用于KtBaseModel回调的block定义 + */ +typedef void(^KtModelBlock)(KtBaseModel *); + +@interface KtBaseModel : NSObject + +//自动解析的数据类型 可能在不同线程访问 因此设置为 atomic +@property (assign,atomic) Class parseDataClassType; + +// 回调函数 +@property (nonatomic, copy) KtModelBlock completionBlock; + +//网络请求 +@property (nonatomic,retain) KtBaseServerAPI *serverApi; + +//网络请求参数 +@property (nonatomic,retain) NSDictionary *params; + +//请求地址 需要在子类init中初始化 +@property (nonatomic,copy) NSString *address; + +- (instancetype)initWithAddress:(NSString *)address; +- (void)handleParsedData:(KtBaseItem *)parsedData; + +- (void)loadWithShortConnection; +- (void)loadWithLongConnection; +- (void)refresh; +- (void)cancel; + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseModel.m b/KtTableView/KtTableView/KtBaseModel/KtBaseModel.m new file mode 100644 index 0000000..41879ef --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseModel.m @@ -0,0 +1,110 @@ +// +// KtBaseModel.m +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseModel.h" + +@implementation KtBaseModel + +- (instancetype)initWithAddress:(NSString *)address { + self = [super init]; + if (self) { + _address = address; + _serverApi = [[KtBaseServerAPI alloc] initWithServer:@"http://1.footballapp.sinaapp.com"]; // 这个URL应该是配置文件中的常量 + } + return self; +} + +- (BOOL)isLoading { // 如果将来支持长链接,这里的逻辑会变复杂 + return self.serverApi.state == KT_PROC_STAT_CREATED || self.serverApi.state == KT_PROC_STAT_LOADING; +} + +// 子类重载处理数据的逻辑 +- (void)handleParsedData:(KtBaseItem *)parsedData { + +} + +#pragma -mark 短链接 +- (void)loadWithShortConnection { + assert(self.address != nil && self.params != nil); + if ([self isLoading]) { + return; + } + [self loadInnerWithShortConnection]; +} + +- (void)loadInnerWithShortConnection { + __block KtBaseModel *wself = self; + NSString *requestAddRess = self.address; + + [self.serverApi accessAPI:requestAddRess WithParams:self.params completionBlock:^(KtBaseServerAPI *api) { + KtBaseModel *sself = wself; + [sself handleShortConnectionBlock:api]; + }]; +} + +- (void)handleShortConnectionBlock:(KtBaseServerAPI *)api { + if (api.state == KT_PROC_STAT_SUCCEED && !api.error) { + [self parseData:api.jsonData]; // 解析 JSON 数据 + } + else if((api.state == KT_PROC_STAT_FAILED || api.error) && api.state != KT_PROC_STAT_CANCELLED) { + // 做一些错误弹窗处理 + if (self.completionBlock) { + self.completionBlock(self); + } + } + //取消或其他 + else { + // 做一些弹窗处理 + if ( self.completionBlock) { + self.completionBlock(self); + } + } +} + +#pragma -mark 长链接 +- (void)loadWithLongConnection { + assert(self.address != nil && self.params != nil); + if ([self isLoading]) { + return; + } + [self loadInnerWithShortConnection]; +} + +- (void)loadInnerWithLongConnection { + return; +} + +# pragma -mark 刷新与取消 +- (void)cancel { + [self.serverApi cancel]; +} + +- (void)refresh { + [self.serverApi refresh]; +} + +#pragma -mark 字典转对象 +- (void)parseData:(NSDictionary *)data { + __block NSDictionary* dataCopy = [[NSDictionary alloc] initWithDictionary:data]; + __block KtBaseModel* wself = self; + dispatch_async(dispatch_get_global_queue(0, 0), ^{ + //异步解析数据 + KtBaseModel *sself = wself; + __block KtBaseItem* item = [[sself.parseDataClassType alloc] initWithData:dataCopy] ; + + //同步通知到主线程 + dispatch_async(dispatch_get_main_queue(), ^{ + [sself handleParsedData:item]; + if ( sself.completionBlock) { + sself.completionBlock(wself); + } + }); + }); +} + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseServerAPI.h b/KtTableView/KtTableView/KtBaseModel/KtBaseServerAPI.h new file mode 100644 index 0000000..d9c4238 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseServerAPI.h @@ -0,0 +1,112 @@ +// +// KtBaseServerAPI.h +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import "AFNetworking.h" + +/*! + @brief API访问的处理状态,IDPServerAPI.state + */ +typedef enum { + KT_PROC_STAT_CREATED = 1, + KT_PROC_STAT_LOADING, + KT_PROC_STAT_SUCCEED, + KT_PROC_STAT_FAILED, + KT_PROC_STAT_CANCELLED +} KtProcessStateEnum; + +/*! + @brief Http请求方法 + @discussion POST方法 + @discussion GET方法ß + */ +typedef enum { + KT_REQUEST_POST, // POST方法 + KT_REQUEST_GET, // GET方法 +} KtHttpRequestMethod; + +// ServerAPI 的回调 +@class KtBaseServerAPI; +typedef void(^KtServerAPICompletionBlock)(KtBaseServerAPI *); + +@interface KtBaseServerAPI : NSObject + +@property (nonatomic, strong) AFHTTPSessionManager *manager; + +// request +@property (nonatomic, readonly) NSString *server; // 形如 www.address.of.api,可兼容前面带“http://”、以及后面带“/”的情况 +@property (nonatomic, copy) NSString *api; // 形如 /some/api/to/access,可兼容前面不带“/”的情况 +@property (nonatomic, readonly) NSDictionary *reqParams; // 请求参数 +@property (nonatomic, readonly) NSDictionary *files; // 请求文件 +@property (nonatomic, copy) KtServerAPICompletionBlock userBlock; // serverapi回调的block + +// response +@property (nonatomic, retain) NSError *error; // code为IDPErrorEnum类型,服务器返回存放在userInfo的errno和errmsg里 +@property (nonatomic, retain) NSDictionary *jsonData; // 解析出的JSON +@property (nonatomic, retain) NSData *rawData; // 原始data,用于二进制结果 +@property (nonatomic, readonly, copy) NSString *rawString; // 原始字符串,用于文本结果,lazyloading +@property (nonatomic, retain) id protobufParserData; // 服务器返回的protobuf解析后的数据 + +// state +@property (nonatomic, assign) KtProcessStateEnum state; + +// 性能信息 +@property (nonatomic, readonly) CFTimeInterval startTime; // 请求发起时间 +@property (nonatomic, readonly) CFTimeInterval netCost; // 网络耗时 + +- (id)initWithServer:(NSString *)server; + +/*! + @brief 访问API,子类不需要重载 + @discussion 本方法可重复调用,会自动中止当前请求(但并不调用用户回调) + @discussion 回调调用时机:请求失败、请求被中止、请求成功 + @discussion 回调一般是根据state访问error或者parsedData,并关掉菊花 + + @param api 形如 /some/api/to/access,可兼容前面不带“/”的情况 + @param params 参数 + @param files 文件 + @param requestMethod KtHttpRequestMethod(GET/POST) + @param block KtServerAPICompletionBlock 回调 + + */ +- (void)accessAPI:(NSString *)api + WithParams:(NSDictionary *)params + files:(NSDictionary *)files + requestMethod:(KtHttpRequestMethod)method + completionBlock:(KtServerAPICompletionBlock)block; + +/*! + @brief 访问API,子类不需要重载 (DEFAULT POST METHOD) + + @param api 形如 /some/api/to/access,可兼容前面不带“/”的情况 + @param params 参数 + @param files 文件 + @param block KtServerAPICompletionBlock 回调 + + */ +- (void)accessAPI:(NSString *)api + WithParams:(NSDictionary *)params + files:(NSDictionary *)files + completionBlock:(KtServerAPICompletionBlock)block; + +/*! + @brief 访问API, 省略files参数的版本 + + @param api 形如 /some/api/to/access,可兼容前面不带“/”的情况 + @param params 参数 + @param block KtServerAPICompletionBlock 回调 + + */ +- (void)accessAPI:(NSString *)api + WithParams:(NSDictionary *)params + completionBlock:(KtServerAPICompletionBlock)block; + +- (void)cancel; +- (void)refresh; + +@end diff --git a/KtTableView/KtTableView/KtBaseModel/KtBaseServerAPI.m b/KtTableView/KtTableView/KtBaseModel/KtBaseServerAPI.m new file mode 100644 index 0000000..6c86119 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseModel/KtBaseServerAPI.m @@ -0,0 +1,159 @@ +// +// KtBaseServerAPI.m +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseServerAPI.h" + +@interface KtBaseServerAPI () + +@property (nonatomic, retain) NSString *server; +@property (nonatomic, retain) NSDictionary *reqParams; +@property (nonatomic, retain) NSDictionary *files; +@property (nonatomic, assign) CFTimeInterval startTime; +@property (nonatomic, assign) CFTimeInterval netCost; +@property (nonatomic, strong) NSURLSessionDataTask *task; + +@end + +@implementation KtBaseServerAPI + +@synthesize rawString = _rawString; + +- (id)initWithServer:(NSString *)server { + self = [super init]; + if (self) { + if (![server hasPrefix:@"http://"]) { + server = [@"http://" stringByAppendingString:server]; + } + if ([server hasSuffix:@"/"]) { + server = [server substringToIndex:server.length - 1]; + } + self.server = server; + } + return self; +} + +#pragma -mark accessAPI + +- (void)accessAPI:(NSString *)api + WithParams:(NSDictionary *)params + files:(NSDictionary *)files + requestMethod:(KtHttpRequestMethod)method + completionBlock:(KtServerAPICompletionBlock)block { + if (!self.manager) { + // 应该获取一个全局唯一的 manager + self.manager = [AFHTTPSessionManager manager]; + self.manager.responseSerializer = [AFHTTPResponseSerializer serializer]; + self.manager.responseSerializer.acceptableContentTypes = [self.manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"]; + } + + if (self.state == KT_PROC_STAT_LOADING) { + [self cancel]; + } + + self.netCost = 0; // 网络请求统计 + // 赋值 + if (![api hasPrefix:@"/"]) { + self.api = [@"/" stringByAppendingString:api]; + } else { + self.api = api; + } + self.reqParams = params; + self.files = files; + self.userBlock = block; + + // 重置状态 + self.state = KT_PROC_STAT_CREATED; + self.error = nil; + self.jsonData = nil; + self.rawData = nil; + self.rawString = nil; + + // 统计时间 + self.startTime = CFAbsoluteTimeGetCurrent(); + + // 允许子类调用自己的方法,附加请求参数 + + // 发起请求 + NSString *url = [self.server stringByAppendingString:self.api]; + if (method == KT_REQUEST_POST) { + self.task = [self.manager POST:url parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + self.netCost = CFAbsoluteTimeGetCurrent() - self.startTime; // 统计网络请求时间 + self.rawData = (NSData *)responseObject; + self.jsonData = [NSJSONSerialization JSONObjectWithData:self.rawData options:NSJSONReadingMutableContainers error:nil]; + self.state = KT_PROC_STAT_SUCCEED; + + if (self.userBlock) { + self.userBlock(self); + } + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + self.state = KT_PROC_STAT_FAILED; + }]; + } + else { + // GET + } + self.state = KT_PROC_STAT_LOADING; // 状态设置为开始请求 +} + +- (void)accessAPI:(NSString *)api + WithParams:(NSDictionary *)params + files:(NSDictionary *)files + completionBlock:(KtServerAPICompletionBlock)block { + [self accessAPI:api + WithParams:params + files:files + requestMethod:KT_REQUEST_POST + completionBlock:block]; +} + +- (void)accessAPI:(NSString *)api + WithParams:(NSDictionary *)params + completionBlock:(KtServerAPICompletionBlock)block { + [self accessAPI:api WithParams:params files:nil completionBlock:block]; +} + +#pragma -mark 刷新与取消 +// 刷新请求 +- (void)refresh { + [self accessAPI:self.api + WithParams:self.reqParams + files:self.files + completionBlock:self.userBlock]; +} + +// 中止请求 +- (void)cancel { + if (self.state == KT_PROC_STAT_LOADING) { + self.state = KT_PROC_STAT_CANCELLED; + [self.task cancel]; + } else { + // 提醒 + return; + } +} + +// lazyloading +- (NSString *)rawString { + if (_rawString) { + return _rawString; + } + if (self.rawData) { + _rawString = [[[NSString alloc] initWithData:self.rawData encoding:NSUTF8StringEncoding] copy]; + } + return self->_rawString; +} + +- (void)setRawString:(NSString *)rawString { + if (self->_rawString == rawString) { + return; + } + + self->_rawString = [rawString copy]; +} + +@end diff --git a/KtTableView/KtTableView/KtBaseTableView.h b/KtTableView/KtTableView/KtBaseTableView.h new file mode 100644 index 0000000..f8f0655 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseTableView.h @@ -0,0 +1,51 @@ +// +// KtBaseTableView.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import "KtTableViewDataSource.h" + +@class KtTableViewSectionObject; +@protocol KtTableViewDelegate + +@optional + +/** + * 选择一个cell的回调,并返回被选择cell的数据结构和indexPath + */ +- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath; + +- (UIView *)headerViewForSectionObject:(KtTableViewSectionObject *)sectionObject atSection:(NSInteger)section; + +// 下拉刷新触发的方法 + +- (void)pullDownToRefreshAction; + +// 上拉加载触发的方法 + +- (void)pullUpToRefreshAction; + +// 将来可以有 cell 的编辑,交换,左滑等回调 + +// 这个协议继承了UITableViewDelegate ,所以自己做一层中转,VC 依然需要实现某些代理方法。 + +@end + +@interface KtBaseTableView : UITableView + +@property (nonatomic, assign) id ktDataSource; + +@property (nonatomic, assign) id ktDelegate; + +// 是否需要下拉刷新和上拉加载 +@property (nonatomic, assign) BOOL isNeedPullDownToRefreshAction; +@property (nonatomic, assign) BOOL isNeedPullUpToRefreshAction; + +- (void)stopRefreshingAnimation; +- (void)triggerRefreshing; + +@end diff --git a/KtTableView/KtTableView/KtBaseTableView.m b/KtTableView/KtTableView/KtBaseTableView.m new file mode 100644 index 0000000..8fd3b3e --- /dev/null +++ b/KtTableView/KtTableView/KtBaseTableView.m @@ -0,0 +1,133 @@ +// +// KtBaseTableView.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseTableView.h" +#import "KtBaseTableViewCell.h" +#import "KtTableViewSectionObject.h" +#import "KtTableViewBaseItem.h" +#import "MJRefresh.h" + +@implementation KtBaseTableView + +- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style { + self = [super initWithFrame:frame style:style]; + if (self) { + self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.separatorColor = [UIColor clearColor]; + self.showsVerticalScrollIndicator = YES; + self.showsHorizontalScrollIndicator = NO; + self.sectionHeaderHeight = 0; + self.sectionFooterHeight = 0; + self.delegate = self; + self.isNeedPullDownToRefreshAction = NO; + self.isNeedPullUpToRefreshAction = NO; + } + return self; +} + +- (void)setKtDataSource:(id)ktDataSource { + if (_ktDataSource != ktDataSource) { + _ktDataSource = ktDataSource; + self.dataSource = ktDataSource; + } +} + +#pragma mark - 上拉加载和下拉刷新 +- (void)setIsNeedPullDownToRefreshAction:(BOOL)isEnable { + if (_isNeedPullDownToRefreshAction == isEnable) { + return; + } + _isNeedPullDownToRefreshAction = isEnable; + __block typeof(self) weakSelf = self; + if (_isNeedPullDownToRefreshAction) { + self.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ + if ([weakSelf.ktDelegate respondsToSelector:@selector(pullDownToRefreshAction)]) { + [weakSelf.ktDelegate pullDownToRefreshAction]; + } + }]; + + } +} + +- (void)setIsNeedPullUpToRefreshAction:(BOOL)isEnable +{ + if (_isNeedPullUpToRefreshAction == isEnable) { + return; + } + _isNeedPullUpToRefreshAction = isEnable; + __block typeof(self) weakSelf = self; + if (_isNeedPullUpToRefreshAction) { + self.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ + if ([weakSelf.ktDelegate respondsToSelector:@selector(pullUpToRefreshAction)]) { + [weakSelf.ktDelegate pullUpToRefreshAction]; + } + }]; + } +} + +- (void)stopRefreshingAnimation { + if ([self.mj_header isRefreshing]) { + [self.mj_header endRefreshing]; + } + if ([self.mj_footer isRefreshing]) { + [self.mj_footer endRefreshing]; + } +} + +- (void)triggerRefreshing { + [self.mj_header beginRefreshing]; +} + +#pragma mark - UITableViewDelegate + +- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath { + id dataSource = (id)tableView.dataSource; + + KtTableViewBaseItem *object = [dataSource tableView:tableView objectForRowAtIndexPath:indexPath]; + Class cls = [dataSource tableView:tableView cellClassForObject:object]; + + if (object.cellHeight == CellInvalidHeight) { // 没有高度缓存 + object.cellHeight = [cls tableView:tableView rowHeightForObject:object]; + } + return object.cellHeight; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + if ([self.ktDelegate respondsToSelector:@selector(didSelectObject:atIndexPath:)]) { + id dataSource = (id)tableView.dataSource; + id object = [dataSource tableView:tableView objectForRowAtIndexPath:indexPath]; + [self.ktDelegate didSelectObject:object atIndexPath:indexPath]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + } + else if ([self.ktDelegate respondsToSelector:@selector(tableView:didSelectRowAtIndexPath:)]) { + [self.ktDelegate tableView:tableView didSelectRowAtIndexPath:indexPath]; + } +} + + +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { + if ([self.ktDelegate respondsToSelector:@selector(headerViewForSectionObject:atSection:)]) { + id dataSource = (id)tableView.dataSource; + KtTableViewSectionObject *sectionObject = [((KtTableViewDataSource *)dataSource).sections objectAtIndex:section]; + + return [self.ktDelegate headerViewForSectionObject:sectionObject atSection:section]; + } + else if ([self.ktDelegate respondsToSelector:@selector(tableView:viewForHeaderInSection:)]) { + return [self.ktDelegate tableView:tableView viewForHeaderInSection:section]; + } + return nil; +} + +#pragma mark - 传递原生协议 + +- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { + if ([self.ktDelegate respondsToSelector:@selector(tableView:willDisplayCell:forRowAtIndexPath:)]) { + [self.ktDelegate tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath]; + } +} +@end diff --git a/KtTableView/KtTableView/KtBaseTableViewCell.h b/KtTableView/KtTableView/KtBaseTableViewCell.h new file mode 100644 index 0000000..259ce07 --- /dev/null +++ b/KtTableView/KtTableView/KtBaseTableViewCell.h @@ -0,0 +1,19 @@ +// +// KtBaseTableViewCell.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@class KtTableViewBaseItem; + +@interface KtBaseTableViewCell : UITableViewCell + +@property (nonatomic, retain) id object; + ++ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(KtTableViewBaseItem *)object; + +@end diff --git a/KtTableView/KtTableView/KtBaseTableViewCell.m b/KtTableView/KtTableView/KtBaseTableViewCell.m new file mode 100644 index 0000000..fa6e4ea --- /dev/null +++ b/KtTableView/KtTableView/KtBaseTableViewCell.m @@ -0,0 +1,37 @@ +// +// KtBaseTableViewCell.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseTableViewCell.h" +#import "KtTableViewBaseItem.h" +#import "UIView+KtExtension.h" + +@implementation KtBaseTableViewCell + +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +- (void)setObject:(KtTableViewBaseItem *)object { // 子类在这个方法中解析数据 + self.imageView.image = object.itemImage; + self.textLabel.text = object.itemTitle; + self.detailTextLabel.text = object.itemSubtitle; + self.accessoryView = [[UIImageView alloc] initWithImage:object.itemAccessoryImage]; +} + ++ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(KtTableViewBaseItem *)object { + return 44.0f; +} + +@end diff --git a/KtTableView/KtTableView/KtExtension/NSDictionary+KtExtension.h b/KtTableView/KtTableView/KtExtension/NSDictionary+KtExtension.h new file mode 100644 index 0000000..7fea023 --- /dev/null +++ b/KtTableView/KtTableView/KtExtension/NSDictionary+KtExtension.h @@ -0,0 +1,167 @@ +// +// NSDictionary+KtExtension.h +// KtTableView +// +// Created by bestswifter on 16/5/15. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface NSDictionary (KtExtension) + +/*! + @brief 根据路径获取obj 例如path为test/xxx/vallue, 会从dict中找到key为test的dict, 在test的dict中找到key为xxx的dict 在xxx的dict中找到key为value的对象 + @param path 给定的路径 eg. test/xxx/value + @return 返回obj or nil + */ +- (NSObject *)objectAtPath:(NSString *)path; + +/*! + @brief 根据路径获取obj 如果获取不到返回other + @param path 给定的路径 + @param other 默认值,当找不到给定的obj,返回other + @return 返回obj or other + */ +- (NSObject *)objectAtPath:(NSString *)path otherwise:(NSObject *)other; + +/*! + @brief 判断给定的key值是否为BOOL类型 + @param path 给定的路径 + @return YES or NO + */ +- (BOOL)boolAtPath:(NSString *)path; + +/*! + @brief 判断给定的key值是否为BOOL类型,如果给定的路径中找不到key值,返回other + @param path 给定的路径 @param other 默认值,当找不到给定的obj,返回other + @return 判断结果 + */ +- (BOOL)boolAtPath:(NSString *)path otherwise:(BOOL)other; + +/*! + @brief 获取给定的key值,返回类型为number + @param path 给定的路径 + @return key值 or nil + */ +- (NSNumber *)numberAtPath:(NSString *)path; + + +/*! + @brief 获取给定的key值,返回类型为number + @param path 给定的路径 + @param otherwise 默认值,当找不到给定的obj,返回other + @return key值 or other + */ +- (NSNumber *)numberAtPath:(NSString *)path otherwise:(NSNumber *)other; + + +/*! + @brief 获取给定的key值,返回类型为String + @param path 给定的路径 + @return key值 or nil + */ +- (NSString *)stringAtPath:(NSString *)path; + +/*! + @brief 获取给定的key值,返回类型为string + @param path 给定的路径 + @param otherwise 默认值,当找不到给定的obj,返回otherwise + @return key值 or otherwise + */ +- (NSString *)stringAtPath:(NSString *)path otherwise:(NSString *)other; + +/*! + @brief 获取给定的key值,返回类型为NSArray + @param path:给定的路径 + @return key值 or nil + */ +- (NSArray *)arrayAtPath:(NSString *)path; + +/*! + @brief 获取给定的key值,返回类型为NSArray + @param path 给定的路径 + @param otherwise 默认值,当找不到给定的obj,返回otherwise + @return key值 or otherwise + */ +- (NSArray *)arrayAtPath:(NSString *)path otherwise:(NSArray *)other; + +/*! + @brief 获取给定的key值,返回类型为NSMutableArray + @param path:给定的路径 + @return key值 or nil + */ +- (NSMutableArray *)mutableArrayAtPath:(NSString *)path; + +/*! + @brief 获取给定的key值,返回类型为NSMutableArray + @param path:给定的路径 + @param otherwise:默认值,当找不到给定的obj,返回otherwise + @return key值 or otherwise + */ +- (NSMutableArray *)mutableArrayAtPath:(NSString *)path otherwise:(NSMutableArray *)other; + +//有类型检查的获取NSDictionary类型 否则返回other +/*! + @brief 通过给定的path获取NSDictionary + @param path:给定的路径 + @return key值 or nil + */ +- (NSDictionary *)dictAtPath:(NSString *)path; + +/*! + @brief 通过给定的path获取NSDictionary + @param path:给定的路径 + @param otherwise:默认值,当找不到给定的obj,返回otherwise + @return key值 or otherwise + */ +- (NSDictionary *)dictAtPath:(NSString *)path otherwise:(NSDictionary *)other; + +/*! + @brief 通过给定的path获取NSMutableDictionary + @param path:给定的路径 + @return key值 or nil + */ +- (NSMutableDictionary *)mutableDictAtPath:(NSString *)path; + +/*! + @brief 通过给定的path获取NSMutableDictionary + @param path:给定的路径 + @param otherwise:默认值,当找不到给定的obj,返回otherwise + @return key值 or otherwise + */ +- (NSMutableDictionary *)mutableDictAtPath:(NSString *)path otherwise:(NSMutableDictionary *)other; + +/*! + @brief 将当前数据转换为NSData,包含编码格式 + @return NSData类型的数据 + */ +-(NSData*)data; + +@end + +#pragma mark NSMutableDictionary接口 +///NSMutableDictionary接口 +@interface NSMutableDictionary (IDPExtension) + +/*! + @brief 安全添加键值对 + @param anObject: value + @param forKey:key + */ +- (void)safeSetObject:(id)anObject forKey:(id)aKey; + +/*! + @brief 安全添加键值对 + @param anObject: value + @param forKey:key + */ +- (void)safeSetObject:(id)object forKeyedSubscript:(id < NSCopying >)aKey; + +/*! + @brief 安全移除key + @param forKey:key + */ +- (void)safeRemoveObjectForKey:(id)aKey; + +@end diff --git a/KtTableView/KtTableView/KtExtension/NSDictionary+KtExtension.m b/KtTableView/KtTableView/KtExtension/NSDictionary+KtExtension.m new file mode 100644 index 0000000..5544cac --- /dev/null +++ b/KtTableView/KtTableView/KtExtension/NSDictionary+KtExtension.m @@ -0,0 +1,187 @@ +// +// NSDictionary+KtExtension.m +// KtTableView +// +// Created by bestswifter on 16/5/15. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "NSDictionary+KtExtension.h" + +@implementation NSDictionary (KtExtension) + +- (NSObject *)objectAtPath:(NSString *)path { + NSArray * array = [path componentsSeparatedByString:@"/"]; + if ( 0 == [array count] ) { + return nil; + } + + NSObject * result = nil; + NSDictionary * dict = self; + + for ( NSString * subPath in array ) { + if ( 0 == [subPath length] ) + continue; + + result = [dict objectForKey:subPath]; + if ( nil == result ) { + return nil; + } + if ( [array lastObject] == subPath) { + return result; + } + else if ( NO == [result isKindOfClass:[NSDictionary class]]) { + return nil; + } + + dict = (NSDictionary *)result; + } + + return (result == [NSNull null]) ? nil : result; +} + +- (NSObject *)objectAtPath:(NSString *)path otherwise:(NSObject *)other { + NSObject * obj = [self objectAtPath:path]; + return obj ? obj : other; +} + +- (BOOL)boolAtPath:(NSString *)path { + return [self boolAtPath:path otherwise:NO]; +} + +- (BOOL)boolAtPath:(NSString *)path otherwise:(BOOL)other { + NSObject * obj = [self objectAtPath:path]; + if ( [obj isKindOfClass:[NSNull class]] ) { + return NO; + } + else if ( [obj isKindOfClass:[NSNumber class]] ) { + return [(NSNumber *)obj intValue] ? YES : NO; + } + else if ( [obj isKindOfClass:[NSString class]] ) { + if ( [(NSString *)obj hasPrefix:@"y"] || + [(NSString *)obj hasPrefix:@"Y"] || + [(NSString *)obj hasPrefix:@"T"] || + [(NSString *)obj hasPrefix:@"t"] || + [(NSString *)obj isEqualToString:@"1"] ) { + // YES/Yes/yes/TRUE/Ture/true/1 + return YES; + } + else { + return NO; + } + } + + return other; +} + +- (NSNumber *)numberAtPath:(NSString *)path { + NSObject * obj = [self objectAtPath:path]; + if ( [obj isKindOfClass:[NSNull class]] ) { + return nil; + } + else if ( [obj isKindOfClass:[NSNumber class]] ) { + return (NSNumber *)obj; + } + else if ( [obj isKindOfClass:[NSString class]] ) { + return [NSNumber numberWithDouble:[(NSString *)obj doubleValue]]; + } + + return nil; +} + +- (NSNumber *)numberAtPath:(NSString *)path otherwise:(NSNumber *)other { + NSNumber * obj = [self numberAtPath:path]; + return obj ? obj : other; +} + +- (NSString *)stringAtPath:(NSString *)path { + NSObject * obj = [self objectAtPath:path]; + if ( [obj isKindOfClass:[NSNull class]] ) { + return nil; + } + else if ( [obj isKindOfClass:[NSNumber class]] ) { + return [NSString stringWithFormat:@"%lld", [(NSNumber *)obj longLongValue]]; + } + else if ( [obj isKindOfClass:[NSString class]] ) { + return (NSString *)obj; + } + + return nil; +} + +- (NSString *)stringAtPath:(NSString *)path otherwise:(NSString *)other { + NSString * obj = [self stringAtPath:path]; + return obj ? obj : other; +} + +- (NSArray *)arrayAtPath:(NSString *)path { + NSObject * obj = [self objectAtPath:path]; + return [obj isKindOfClass:[NSArray class]] ? (NSArray *)obj : nil; +} + +- (NSArray *)arrayAtPath:(NSString *)path otherwise:(NSArray *)other { + NSArray * obj = [self arrayAtPath:path]; + return obj ? obj : other; +} + +- (NSMutableArray *)mutableArrayAtPath:(NSString *)path { + NSObject * obj = [self objectAtPath:path]; + return [obj isKindOfClass:[NSMutableArray class]] ? (NSMutableArray *)obj : nil; +} + +- (NSMutableArray *)mutableArrayAtPath:(NSString *)path otherwise:(NSMutableArray *)other { + NSMutableArray * obj = [self mutableArrayAtPath:path]; + return obj ? obj : other; +} + +- (NSDictionary *)dictAtPath:(NSString *)path { + NSObject * obj = [self objectAtPath:path]; + return [obj isKindOfClass:[NSDictionary class]] ? (NSDictionary *)obj : nil; +} + +- (NSDictionary *)dictAtPath:(NSString *)path otherwise:(NSDictionary *)other { + NSDictionary * obj = [self dictAtPath:path]; + return obj ? obj : other; +} + +- (NSMutableDictionary *)mutableDictAtPath:(NSString *)path { + NSObject * obj = [self objectAtPath:path]; + return [obj isKindOfClass:[NSMutableDictionary class]] ? (NSMutableDictionary *)obj : nil; +} + +- (NSMutableDictionary *)mutableDictAtPath:(NSString *)path otherwise:(NSMutableDictionary *)other { + NSMutableDictionary * obj = [self mutableDictAtPath:path]; + return obj ? obj : other; +} + +-(NSData*)data { + NSData* data = [NSKeyedArchiver archivedDataWithRootObject:self]; + return data; +} + +@end + +#pragma mark - + +@implementation NSMutableDictionary (IDPExtension) +- (void)safeSetObject:(id)anObject forKey:(id < NSCopying >)aKey { + if (!anObject || !aKey) { + return ; + } + [self setObject:anObject forKey:aKey]; +} + +- (void)safeSetObject:(id)object forKeyedSubscript:(id < NSCopying >)aKey { + if (!object || !aKey) { + return ; + } + [self setObject:object forKeyedSubscript:aKey]; +} + +- (void)safeRemoveObjectForKey:(id)aKey { + if(!aKey) + return; + [self removeObjectForKey:aKey]; +} + +@end diff --git a/KtTableView/KtTableView/KtExtension/UIView+KtExtension.h b/KtTableView/KtTableView/KtExtension/UIView+KtExtension.h new file mode 100644 index 0000000..5cd6349 --- /dev/null +++ b/KtTableView/KtTableView/KtExtension/UIView+KtExtension.h @@ -0,0 +1,79 @@ +// +// UIView+KtExtension.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface UIView (KtExtension) + +//frame accessors +/*! + @brief 初始坐标 + */ +@property (nonatomic, assign) CGPoint origin; +/*! + @brief View大小 + */ +@property (nonatomic, assign) CGSize size; +/*! + @brief 顶部坐标值 + */ +@property (nonatomic, assign) CGFloat top; +/*! + @brief 左部坐标值 + */ +@property (nonatomic, assign) CGFloat left; +/*! + @brief 底部坐标值 + */ +@property (nonatomic, assign) CGFloat bottom; +/*! + @brief 右部坐标值 + */ +@property (nonatomic, assign) CGFloat right; +/*! + @brief 宽度值 + */ +@property (nonatomic, assign) CGFloat width; +/*! + @brief 高度值 + */ +@property (nonatomic, assign) CGFloat height; +/*! + @brief 中心点X坐标 + */ +@property (nonatomic, assign) CGFloat x; +/*! + @brief 中心点Y坐标 + */ +@property (nonatomic, assign) CGFloat y; + +//bounds accessors +/*! + @brief 边界大小 + */ +@property (nonatomic, assign) CGSize boundsSize; +/*! + @brief 边界宽度 + */ +@property (nonatomic, assign) CGFloat boundsWidth; +/*! + @brief 边界高度 + */ +@property (nonatomic, assign) CGFloat boundsHeight; + +//content getters +/*! + @brief 边界区域 + */ +@property (nonatomic, readonly) CGRect contentBounds; +/*! + @brief 边界中心点 + */ +@property (nonatomic, readonly) CGPoint contentCenter; + +@end diff --git a/KtTableView/KtTableView/KtExtension/UIView+KtExtension.m b/KtTableView/KtTableView/KtExtension/UIView+KtExtension.m new file mode 100644 index 0000000..dec0a1b --- /dev/null +++ b/KtTableView/KtTableView/KtExtension/UIView+KtExtension.m @@ -0,0 +1,179 @@ +// +// UIView+KtExtension.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "UIView+KtExtension.h" + +@implementation UIView (KtExtension) + +- (CGPoint)origin +{ + return self.frame.origin; +} + +- (void)setOrigin:(CGPoint)origin +{ + CGRect frame = self.frame; + frame.origin = origin; + self.frame = frame; +} + +- (CGSize)size +{ + return self.frame.size; +} + +- (void)setSize:(CGSize)size +{ + CGRect frame = self.frame; + frame.size = size; + self.frame = frame; +} + +- (CGFloat)top +{ + return self.origin.y; +} + +- (void)setTop:(CGFloat)top +{ + CGRect frame = self.frame; + frame.origin.y = top; + self.frame = frame; +} + +- (CGFloat)left +{ + return self.origin.x; +} + +- (void)setLeft:(CGFloat)left +{ + CGRect frame = self.frame; + frame.origin.x = left; + self.frame = frame; +} + +- (CGFloat)right +{ + return self.left + self.width; +} + +- (void)setRight:(CGFloat)right +{ + CGRect frame = self.frame; + frame.origin.x = right - frame.size.width; + self.frame = frame; +} + +- (CGFloat)bottom +{ + return self.top + self.height; +} + +- (void)setBottom:(CGFloat)bottom +{ + CGRect frame = self.frame; + frame.origin.y = bottom - frame.size.height; + self.frame = frame; +} + +- (CGFloat)width +{ + return self.size.width; +} + +- (void)setWidth:(CGFloat)width +{ + CGRect frame = self.frame; + frame.size.width = width; + self.frame = frame; +} + +- (CGFloat)height +{ + return self.size.height; +} + +- (void)setHeight:(CGFloat)height +{ + CGRect frame = self.frame; + frame.size.height = height; + self.frame = frame; +} + +- (CGFloat)x +{ + return self.center.x; +} + +- (void)setX:(CGFloat)x +{ + self.center = CGPointMake(x, self.center.y); +} + +- (CGFloat)y +{ + return self.center.y; +} + +- (void)setY:(CGFloat)y +{ + self.center = CGPointMake(self.center.x, y); +} + +//bounds accessors + +- (CGSize)boundsSize +{ + return self.bounds.size; +} + +- (void)setBoundsSize:(CGSize)size +{ + CGRect bounds = self.bounds; + bounds.size = size; + self.bounds = bounds; +} + +- (CGFloat)boundsWidth +{ + return self.boundsSize.width; +} + +- (void)setBoundsWidth:(CGFloat)width +{ + CGRect bounds = self.bounds; + bounds.size.width = width; + self.bounds = bounds; +} + +- (CGFloat)boundsHeight +{ + return self.boundsSize.height; +} + +- (void)setBoundsHeight:(CGFloat)height +{ + CGRect bounds = self.bounds; + bounds.size.height = height; + self.bounds = bounds; +} + +//content getters + +- (CGRect)contentBounds +{ + return CGRectMake(0.0f, 0.0f, self.boundsWidth, self.boundsHeight); +} + +- (CGPoint)contentCenter +{ + return CGPointMake(self.boundsWidth/2.0f, self.boundsHeight/2.0f); +} + +@end diff --git a/KtTableView/KtTableView/KtMainTableItem.h b/KtTableView/KtTableView/KtMainTableItem.h new file mode 100644 index 0000000..6171d7f --- /dev/null +++ b/KtTableView/KtTableView/KtMainTableItem.h @@ -0,0 +1,23 @@ +// +// KtMainTableItem.h +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseListItem.h" + +@interface KtMainTableItem : KtBaseListItem + +@property (strong, nonatomic) NSMutableArray *books; // 存放了每个 cell 的标题 + +@end + +@interface KtMainTableBookItem : KtBaseItem + +@property (copy, nonatomic) NSString *bookTitle; +@property (copy, nonatomic) NSString *url; +@property (copy, nonatomic) NSString *imageUrl; + +@end diff --git a/KtTableView/KtTableView/KtMainTableItem.m b/KtTableView/KtTableView/KtMainTableItem.m new file mode 100644 index 0000000..804e818 --- /dev/null +++ b/KtTableView/KtTableView/KtMainTableItem.m @@ -0,0 +1,36 @@ +// +// KtMainTableItem.m +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtMainTableItem.h" + +@implementation KtMainTableItem + +- (id)init { + self = [super init]; + if (self) { + [self addMappingRuleProperty:@"books" pathInJson:@"data"]; + [self addMappingRuleArrayProperty:@"books" class:[KtMainTableBookItem class]]; + } + return self; +} + +@end + +@implementation KtMainTableBookItem + +- (id)init { + self = [super init]; + if (self) { + [self addMappingRuleProperty:@"bookTitle" pathInJson:@"title"]; + [self addMappingRuleProperty:@"url" pathInJson:@"url"]; + [self addMappingRuleProperty:@"imageUrl" pathInJson:@"imageUrl"]; + } + return self; +} + +@end diff --git a/KtTableView/KtTableView/KtMainTableModel.h b/KtTableView/KtTableView/KtMainTableModel.h new file mode 100644 index 0000000..378b06d --- /dev/null +++ b/KtTableView/KtTableView/KtMainTableModel.h @@ -0,0 +1,16 @@ +// +// KtMainTableModel.h +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtBaseListModel.h" +#import "KtMainTableItem.h" + +@interface KtMainTableModel : KtBaseListModel + +@property (nonatomic, strong) KtMainTableItem *tableViewItem; + +@end diff --git a/KtTableView/KtTableView/KtMainTableModel.m b/KtTableView/KtTableView/KtMainTableModel.m new file mode 100644 index 0000000..334a75b --- /dev/null +++ b/KtTableView/KtTableView/KtMainTableModel.m @@ -0,0 +1,28 @@ +// +// KtMainTableModel.m +// KtTableView +// +// Created by bestswifter on 16/5/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtMainTableModel.h" +#import "KtMainTableItem.h" + +@implementation KtMainTableModel + +- (void)handleParsedData:(KtBaseItem *)parsedData { + [super handleParsedData:parsedData]; + if ([parsedData isKindOfClass:[KtMainTableItem class]]) { + self.tableViewItem = (KtMainTableItem *)parsedData; + } +} + +- (void)loadWithShortConnection { + if (!self.parseDataClassType) { + self.parseDataClassType = [KtMainTableItem class]; + } + [super loadWithShortConnection]; +} + +@end diff --git a/KtTableView/KtTableView/KtMainTableViewCell.h b/KtTableView/KtTableView/KtMainTableViewCell.h new file mode 100644 index 0000000..f57a6dd --- /dev/null +++ b/KtTableView/KtTableView/KtMainTableViewCell.h @@ -0,0 +1,14 @@ +// +// KtMainTableViewCell.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import "KtBaseTableViewCell.h" + +@interface KtMainTableViewCell : KtBaseTableViewCell + +@end diff --git a/KtTableView/KtTableView/KtMainTableViewCell.m b/KtTableView/KtTableView/KtMainTableViewCell.m new file mode 100644 index 0000000..8249d4c --- /dev/null +++ b/KtTableView/KtTableView/KtMainTableViewCell.m @@ -0,0 +1,27 @@ +// +// KtMainTableViewCell.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtMainTableViewCell.h" + +@implementation KtMainTableViewCell + +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + // Configure the view for the selected state +} + ++ (CGFloat)tableView:(UITableView *)tableView rowHeightForObject:(KtTableViewBaseItem *)object { + return 60; +} + +@end diff --git a/KtTableView/KtTableView/KtMainTableViewDataSource.h b/KtTableView/KtTableView/KtMainTableViewDataSource.h new file mode 100644 index 0000000..6663687 --- /dev/null +++ b/KtTableView/KtTableView/KtMainTableViewDataSource.h @@ -0,0 +1,13 @@ +// +// KtMainTableViewDataSource.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtTableViewDataSource.h" + +@interface KtMainTableViewDataSource : KtTableViewDataSource + +@end diff --git a/KtTableView/KtTableView/KtMainTableViewDataSource.m b/KtTableView/KtTableView/KtMainTableViewDataSource.m new file mode 100644 index 0000000..ebdd3b5 --- /dev/null +++ b/KtTableView/KtTableView/KtMainTableViewDataSource.m @@ -0,0 +1,46 @@ +// +// KtMainTableViewDataSource.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtMainTableViewDataSource.h" +#import "KtMainTableViewCell.h" + +#import "KtTableViewSectionObject.h" // 这个实际使用时应该是对应的子类 +#import "KtTableViewBaseItem.h" // 这个实际使用时应该是对应的子类 + +@implementation KtMainTableViewDataSource + +- (instancetype)init +{ + self = [super init]; + if (self) { + KtTableViewSectionObject *firstSectionObject = [[KtTableViewSectionObject alloc] initWithItemArray:[NSMutableArray arrayWithObjects: + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第一条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第二条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第三条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第四条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第五条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第六条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第七条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第八条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第九条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第十条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第十一条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第十二条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第十三条消息" SubTitle:nil AccessoryImage:nil], + [[KtTableViewBaseItem alloc] initWithImage:nil Title:@"第十四条消息" SubTitle:nil AccessoryImage:nil], + nil]]; + self.sections = [NSMutableArray arrayWithObject: firstSectionObject]; + } + return self; +} + +- (Class)tableView:(UITableView *)tableView cellClassForObject:(KtTableViewBaseItem *)object { + return [KtMainTableViewCell class]; +} + +@end diff --git a/KtTableView/KtTableView/KtTableViewBaseItem.h b/KtTableView/KtTableView/KtTableViewBaseItem.h new file mode 100644 index 0000000..450904e --- /dev/null +++ b/KtTableView/KtTableView/KtTableViewBaseItem.h @@ -0,0 +1,26 @@ +// +// KtTableViewBaseItem.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import + +FOUNDATION_EXPORT CGFloat const CellInvalidHeight; + +@interface KtTableViewBaseItem : NSObject + +@property (nonatomic, assign) CGFloat cellHeight; + +@property (nonatomic, retain) NSString *itemIdentifier; +@property (nonatomic, retain) UIImage *itemImage; +@property (nonatomic, retain) NSString *itemTitle; +@property (nonatomic, retain) NSString *itemSubtitle; +@property (nonatomic, retain) UIImage *itemAccessoryImage; + +- (instancetype)initWithImage:(UIImage *)image Title:(NSString *)title SubTitle:(NSString *)subTitle AccessoryImage:(UIImage *)accessoryImage; + +@end diff --git a/KtTableView/KtTableView/KtTableViewBaseItem.m b/KtTableView/KtTableView/KtTableViewBaseItem.m new file mode 100644 index 0000000..b0e874b --- /dev/null +++ b/KtTableView/KtTableView/KtTableViewBaseItem.m @@ -0,0 +1,32 @@ +// +// KtTableViewBaseItem.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtTableViewBaseItem.h" + +CGFloat const CellInvalidHeight = -1; + +@implementation KtTableViewBaseItem + +- (instancetype)init { + self = [self initWithImage:nil Title:nil SubTitle:nil AccessoryImage:nil]; + return self; +} + +- (instancetype)initWithImage:(UIImage *)image Title:(NSString *)title SubTitle:(NSString *)subTitle AccessoryImage:(UIImage *)accessoryImage { + self = [super init]; + if (self) { + _cellHeight = CellInvalidHeight; + _itemImage = image; + _itemTitle = title; + _itemSubtitle = subTitle; + _itemAccessoryImage = accessoryImage; + } + return self; +} + +@end diff --git a/KtTableView/KtTableView/KtTableViewController.h b/KtTableView/KtTableView/KtTableViewController.h new file mode 100644 index 0000000..f6e3569 --- /dev/null +++ b/KtTableView/KtTableView/KtTableViewController.h @@ -0,0 +1,29 @@ +// +// KtTableViewController.h +// KtTableView +// +// Created by bestswifter on 16/4/16. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import "KtBaseTableView.h" + +@class KtTableViewDataSource; + +@protocol KtTableViewControllerDelegate + +@required +- (void)createDataSource; + +@end + +@interface KtTableViewController : UIViewController + +@property (nonatomic, strong) KtBaseTableView *tableView; +@property (nonatomic, strong) KtTableViewDataSource *dataSource; +@property (nonatomic, assign) UITableViewStyle tableViewStyle; // 用来创建 tableView + +- (instancetype)initWithStyle:(UITableViewStyle)style; + +@end diff --git a/KtTableView/KtTableView/KtTableViewController.m b/KtTableView/KtTableView/KtTableViewController.m new file mode 100644 index 0000000..42337d6 --- /dev/null +++ b/KtTableView/KtTableView/KtTableViewController.m @@ -0,0 +1,43 @@ +// +// KtTableViewController.m +// KtTableView +// +// Created by bestswifter on 16/4/16. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtTableViewController.h" +#import "KtTableViewDataSource.h" + +@implementation KtTableViewController + +- (instancetype)initWithStyle:(UITableViewStyle)style { + self = [super init]; + if (self) { + [self createDataSource]; + } + return self; +} + +// 这个方法实际上要被子类重写,生成对应类型的 data source +- (void)createDataSource { + @throw [NSException exceptionWithName:@"Cann't use this method" + reason:@"You can only call this method in subclass" + userInfo:nil]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + [self createTableView]; +} + +- (void)createTableView { + if (!self.tableView) { + self.tableView = [[KtBaseTableView alloc] initWithFrame:self.view.bounds style:self.tableViewStyle]; + self.tableView.ktDelegate = self; + self.tableView.ktDataSource = self.dataSource; + [self.view addSubview:self.tableView]; + } +} + +@end diff --git a/KtTableView/KtTableView/KtTableViewDataSource.h b/KtTableView/KtTableView/KtTableViewDataSource.h new file mode 100644 index 0000000..558c217 --- /dev/null +++ b/KtTableView/KtTableView/KtTableViewDataSource.h @@ -0,0 +1,30 @@ +// +// KtTableViewDataSource.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import + +@class KtTableViewBaseItem; + +@protocol KtTableViewDataSource + +@optional + +- (KtTableViewBaseItem *)tableView:(UITableView *)tableView objectForRowAtIndexPath:(NSIndexPath *)indexPath; +- (Class)tableView:(UITableView*)tableView cellClassForObject:(KtTableViewBaseItem *)object; + +@end + +@interface KtTableViewDataSource : NSObject + +@property (nonatomic, strong) NSMutableArray *sections; // 二维数组,每个元素都是一个 SectionObject + +- (void)clearAllItems; +- (void)appendItem:(KtTableViewBaseItem *)item; + +@end diff --git a/KtTableView/KtTableView/KtTableViewDataSource.m b/KtTableView/KtTableView/KtTableViewDataSource.m new file mode 100644 index 0000000..35d5861 --- /dev/null +++ b/KtTableView/KtTableView/KtTableViewDataSource.m @@ -0,0 +1,89 @@ +// +// KtTableViewDataSource.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtTableViewDataSource.h" +#import "KtTableViewSectionObject.h" +#import "KtBaseTableViewCell.h" +#import "KtTableViewBaseItem.h" + +#import + +@implementation KtTableViewDataSource + +#pragma mark - KtTableViewDataSource +- (KtTableViewBaseItem *)tableView:(UITableView *)tableView objectForRowAtIndexPath:(NSIndexPath *)indexPath { + if (self.sections.count > indexPath.section) { + KtTableViewSectionObject *sectionObject = [self.sections objectAtIndex:indexPath.section]; + if ([sectionObject.items count] > indexPath.row) { + return [sectionObject.items objectAtIndex:indexPath.row]; + } + } + return nil; +} + +- (Class)tableView:(UITableView*)tableView cellClassForObject:(KtTableViewBaseItem *)object { // 这个方法会子类有机会重写,默认的 Cell 类型是 KtBaseTableViewCell + return [KtBaseTableViewCell class]; +} + +- (void)clearAllItems { + self.sections = [NSMutableArray arrayWithObject:[[KtTableViewSectionObject alloc] init]]; +} + +- (void)appendItem:(KtTableViewBaseItem *)item { + KtTableViewSectionObject *firstSectionObject = [self.sections objectAtIndex:0]; + [firstSectionObject.items addObject:item]; +} + +#pragma mark - UITableViewDataSource Required +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + if (self.sections.count > section) { + KtTableViewSectionObject *sectionObject = [self.sections objectAtIndex:section]; + return sectionObject.items.count; + } + return 0; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + KtTableViewBaseItem *object = [self tableView:tableView objectForRowAtIndexPath:indexPath]; + Class cellClass = [self tableView:tableView cellClassForObject:object]; + NSString *className = [NSString stringWithUTF8String:class_getName(cellClass)]; + + KtBaseTableViewCell* cell = (KtBaseTableViewCell*)[tableView dequeueReusableCellWithIdentifier:className]; + if (!cell) { + cell = [[cellClass alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:className]; + } + [cell setObject:object]; + + return cell; +} + +#pragma mark - UITableViewDataSource Optional +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return self.sections ? self.sections.count : 0; +} + +- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { + if (self.sections.count > section) { + KtTableViewSectionObject *sectionObject = [self.sections objectAtIndex:section]; + return sectionObject.headerTitle; + } + return nil; +} + +- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { + if (self.sections.count > section) { + KtTableViewSectionObject *sectionObject = [self.sections objectAtIndex:section]; + if (sectionObject != nil && sectionObject.footerTitle != nil && ![sectionObject.footerTitle isEqualToString:@""]) { + return sectionObject.footerTitle; + } + } + return nil; +} + + +@end diff --git a/KtTableView/KtTableView/KtTableViewSectionObject.h b/KtTableView/KtTableView/KtTableViewSectionObject.h new file mode 100644 index 0000000..48ac8ad --- /dev/null +++ b/KtTableView/KtTableView/KtTableViewSectionObject.h @@ -0,0 +1,20 @@ +// +// KtTableViewSectionObject.h +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface KtTableViewSectionObject : NSObject + +@property (nonatomic, copy) NSString *headerTitle; // UITableDataSource 协议中的 titleForHeaderInSection 方法可能会用到 +@property (nonatomic, copy) NSString *footerTitle; // UITableDataSource 协议中的 titleForFooterInSection 方法可能会用到 + +@property (nonatomic, retain) NSMutableArray *items; + +- (instancetype)initWithItemArray:(NSMutableArray *)items; + +@end diff --git a/KtTableView/KtTableView/KtTableViewSectionObject.m b/KtTableView/KtTableView/KtTableViewSectionObject.m new file mode 100644 index 0000000..8a5125a --- /dev/null +++ b/KtTableView/KtTableView/KtTableViewSectionObject.m @@ -0,0 +1,31 @@ +// +// KtTableViewSectionObject.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import "KtTableViewSectionObject.h" + +@implementation KtTableViewSectionObject + +- (instancetype)init { + self = [super init]; + if (self) { + self.headerTitle = @""; + self.footerTitle = @""; + self.items = [[NSMutableArray alloc] init]; + } + return self; +} + +- (instancetype)initWithItemArray:(NSMutableArray *)items { + self = [self init]; + if (self) { + [self.items addObjectsFromArray:items]; + } + return self; +} + +@end diff --git a/KtTableView/KtTableView/main.m b/KtTableView/KtTableView/main.m new file mode 100644 index 0000000..aa21d0d --- /dev/null +++ b/KtTableView/KtTableView/main.m @@ -0,0 +1,16 @@ +// +// main.m +// KtTableView +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/KtTableView/KtTableViewTests/Info.plist b/KtTableView/KtTableViewTests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/KtTableView/KtTableViewTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/KtTableView/KtTableViewTests/KtTableViewTests.m b/KtTableView/KtTableViewTests/KtTableViewTests.m new file mode 100644 index 0000000..532b1f9 --- /dev/null +++ b/KtTableView/KtTableViewTests/KtTableViewTests.m @@ -0,0 +1,39 @@ +// +// KtTableViewTests.m +// KtTableViewTests +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface KtTableViewTests : XCTestCase + +@end + +@implementation KtTableViewTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/KtTableView/KtTableViewUITests/Info.plist b/KtTableView/KtTableViewUITests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/KtTableView/KtTableViewUITests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/KtTableView/KtTableViewUITests/KtTableViewUITests.m b/KtTableView/KtTableViewUITests/KtTableViewUITests.m new file mode 100644 index 0000000..786578c --- /dev/null +++ b/KtTableView/KtTableViewUITests/KtTableViewUITests.m @@ -0,0 +1,40 @@ +// +// KtTableViewUITests.m +// KtTableViewUITests +// +// Created by bestswifter on 16/4/13. +// Copyright © 2016年 zxy. All rights reserved. +// + +#import + +@interface KtTableViewUITests : XCTestCase + +@end + +@implementation KtTableViewUITests + +- (void)setUp { + [super setUp]; + + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + self.continueAfterFailure = NO; + // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. + [[[XCUIApplication alloc] init] launch]; + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +@end diff --git a/KtTableView/Podfile b/KtTableView/Podfile new file mode 100644 index 0000000..f3d6b36 --- /dev/null +++ b/KtTableView/Podfile @@ -0,0 +1,5 @@ +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' + +pod 'AFNetworking', '~> 3.0' +pod 'MJRefresh' diff --git a/KtTableView/Podfile.lock b/KtTableView/Podfile.lock new file mode 100644 index 0000000..fac681a --- /dev/null +++ b/KtTableView/Podfile.lock @@ -0,0 +1,27 @@ +PODS: + - AFNetworking (3.1.0): + - AFNetworking/NSURLSession (= 3.1.0) + - AFNetworking/Reachability (= 3.1.0) + - AFNetworking/Security (= 3.1.0) + - AFNetworking/Serialization (= 3.1.0) + - AFNetworking/UIKit (= 3.1.0) + - AFNetworking/NSURLSession (3.1.0): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (3.1.0) + - AFNetworking/Security (3.1.0) + - AFNetworking/Serialization (3.1.0) + - AFNetworking/UIKit (3.1.0): + - AFNetworking/NSURLSession + - MJRefresh (3.1.0) + +DEPENDENCIES: + - AFNetworking (~> 3.0) + - MJRefresh + +SPEC CHECKSUMS: + AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 + MJRefresh: 743e6404967d1c2c688472ea3ecfde247d872db4 + +COCOAPODS: 0.39.0 diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h b/KtTableView/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h new file mode 100644 index 0000000..5ce279a --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1,295 @@ +// AFHTTPSessionManager.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#if !TARGET_OS_WATCH +#import +#endif +#import + +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV +#import +#else +#import +#endif + +#import "AFURLSessionManager.h" + +/** + `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFHTTPSessionManager : AFURLSessionManager + +/** + The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong, nullable) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns an `AFHTTPSessionManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + @param configuration The configuration used to create the managed session. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url + sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; + + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param downloadProgress A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(nullable id)parameters + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure DEPRECATED_ATTRIBUTE; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param uploadProgress A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:uploadProgress:downloadProgress:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgress + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m b/KtTableView/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m new file mode 100644 index 0000000..2591070 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m @@ -0,0 +1,361 @@ +// AFHTTPSessionManager.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPSessionManager.h" + +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" + +#import +#import +#import + +#import +#import +#import +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import +#elif TARGET_OS_WATCH +#import +#endif + +@interface AFHTTPSessionManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPSessionManager +@dynamic responseSerializer; + ++ (instancetype)manager { + return [[[self class] alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + return [self initWithBaseURL:url sessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + return [self initWithBaseURL:nil sessionConfiguration:configuration]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration +{ + self = [super initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + return self; +} + +#pragma mark - + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [super setResponseSerializer:responseSerializer]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + + return [self GET:URLString parameters:parameters progress:nil success:success failure:failure]; +} + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + progress:(void (^)(NSProgress * _Nonnull))downloadProgress + success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success + failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET" + URLString:URLString + parameters:parameters + uploadProgress:nil + downloadProgress:downloadProgress + success:success + failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:^(NSURLSessionDataTask *task, __unused id responseObject) { + if (success) { + success(task); + } + } failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + return [self POST:URLString parameters:parameters progress:nil success:success failure:failure]; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + progress:(void (^)(NSProgress * _Nonnull))uploadProgress + success:(void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success + failure:(void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters uploadProgress:uploadProgress downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id _Nonnull))block + success:(nullable void (^)(NSURLSessionDataTask * _Nonnull, id _Nullable))success + failure:(nullable void (^)(NSURLSessionDataTask * _Nullable, NSError * _Nonnull))failure +{ + return [self POST:URLString parameters:parameters constructingBodyWithBlock:block progress:nil success:success failure:failure]; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + progress:(nullable void (^)(NSProgress * _Nonnull))uploadProgress + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:uploadProgress completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(task, error); + } + } else { + if (success) { + success(task, responseObject); + } + } + }]; + + [task resume]; + + return task; +} + +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters uploadProgress:nil downloadProgress:nil success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgress + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgress + success:(void (^)(NSURLSessionDataTask *, id))success + failure:(void (^)(NSURLSessionDataTask *, NSError *))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *dataTask = nil; + dataTask = [self dataTaskWithRequest:request + uploadProgress:uploadProgress + downloadProgress:downloadProgress + completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(dataTask, error); + } + } else { + if (success) { + success(dataTask, responseObject); + } + } + }]; + + return dataTask; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + if (!configuration) { + NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"]; + if (configurationIdentifier) { +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100) + configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier]; +#else + configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier]; +#endif + } + } + + self = [self initWithBaseURL:baseURL sessionConfiguration:configuration]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))]; + if (decodedPolicy) { + self.securityPolicy = decodedPolicy; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; + } else { + [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"]; + } + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; + [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone]; + return HTTPClient; +} + +@end diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h b/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h new file mode 100644 index 0000000..0feb18d --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1,206 @@ +// AFNetworkReachabilityManager.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if !TARGET_OS_WATCH +#import + +typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { + AFNetworkReachabilityStatusUnknown = -1, + AFNetworkReachabilityStatusNotReachable = 0, + AFNetworkReachabilityStatusReachableViaWWAN = 1, + AFNetworkReachabilityStatusReachableViaWiFi = 2, +}; + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + + Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. + + See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ ) + + @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. + */ +@interface AFNetworkReachabilityManager : NSObject + +/** + The current network reachability status. + */ +@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; + +/** + Whether or not the network is currently reachable. + */ +@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; + +/** + Whether or not the network is currently reachable via WWAN. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; + +/** + Whether or not the network is currently reachable via WiFi. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Returns the shared network reachability manager. + */ ++ (instancetype)sharedManager; + +/** + Creates and returns a network reachability manager with the default socket address. + + @return An initialized network reachability manager, actively monitoring the default socket address. + */ ++ (instancetype)manager; + +/** + Creates and returns a network reachability manager for the specified domain. + + @param domain The domain used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified domain. + */ ++ (instancetype)managerForDomain:(NSString *)domain; + +/** + Creates and returns a network reachability manager for the socket address. + + @param address The socket address (`sockaddr_in6`) used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified socket address. + */ ++ (instancetype)managerForAddress:(const void *)address; + +/** + Initializes an instance of a network reachability manager from the specified reachability object. + + @param reachability The reachability object to monitor. + + @return An initialized network reachability manager, actively monitoring the specified reachability. + */ +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; + +///-------------------------------------------------- +/// @name Starting & Stopping Reachability Monitoring +///-------------------------------------------------- + +/** + Starts monitoring for changes in network reachability status. + */ +- (void)startMonitoring; + +/** + Stops monitoring for changes in network reachability status. + */ +- (void)stopMonitoring; + +///------------------------------------------------- +/// @name Getting Localized Reachability Description +///------------------------------------------------- + +/** + Returns a localized string representation of the current network reachability status. + */ +- (NSString *)localizedNetworkReachabilityStatusString; + +///--------------------------------------------------- +/// @name Setting Network Reachability Change Callback +///--------------------------------------------------- + +/** + Sets a callback to be executed when the network availability of the `baseURL` host changes. + + @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. + */ +- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Network Reachability + + The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. + + enum { + AFNetworkReachabilityStatusUnknown, + AFNetworkReachabilityStatusNotReachable, + AFNetworkReachabilityStatusReachableViaWWAN, + AFNetworkReachabilityStatusReachableViaWiFi, + } + + `AFNetworkReachabilityStatusUnknown` + The `baseURL` host reachability is not known. + + `AFNetworkReachabilityStatusNotReachable` + The `baseURL` host cannot be reached. + + `AFNetworkReachabilityStatusReachableViaWWAN` + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. + + `AFNetworkReachabilityStatusReachableViaWiFi` + The `baseURL` host can be reached via a Wi-Fi connection. + + ### Keys for Notification UserInfo Dictionary + + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. + + `AFNetworkingReachabilityNotificationStatusItem` + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. + */ + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when network reachability changes. + This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. + + @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). + */ +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification; +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem; + +///-------------------- +/// @name Functions +///-------------------- + +/** + Returns a localized string representation of an `AFNetworkReachabilityStatus` value. + */ +FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); + +NS_ASSUME_NONNULL_END +#endif diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m b/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m new file mode 100644 index 0000000..d458364 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m @@ -0,0 +1,263 @@ +// AFNetworkReachabilityManager.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkReachabilityManager.h" +#if !TARGET_OS_WATCH + +#import +#import +#import +#import +#import + +NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; +NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; + +typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); + +NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusNotReachable: + return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWWAN: + return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWiFi: + return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); + case AFNetworkReachabilityStatusUnknown: + default: + return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); + } +} + +static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { + BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); + BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); + BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); + BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); + BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); + + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; + if (isNetworkReachable == NO) { + status = AFNetworkReachabilityStatusNotReachable; + } +#if TARGET_OS_IPHONE + else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { + status = AFNetworkReachabilityStatusReachableViaWWAN; + } +#endif + else { + status = AFNetworkReachabilityStatusReachableViaWiFi; + } + + return status; +} + +/** + * Queue a status change notification for the main thread. + * + * This is done to ensure that the notifications are received in the same order + * as they are sent. If notifications are sent directly, it is possible that + * a queued notification (for an earlier status condition) is processed after + * the later update, resulting in the listener being left in the wrong state. + */ +static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) { + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + dispatch_async(dispatch_get_main_queue(), ^{ + if (block) { + block(status); + } + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; + }); +} + +static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { + AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info); +} + + +static const void * AFNetworkReachabilityRetainCallback(const void *info) { + return Block_copy(info); +} + +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + Block_release(info); + } +} + +@interface AFNetworkReachabilityManager () +@property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; +@end + +@implementation AFNetworkReachabilityManager + ++ (instancetype)sharedManager { + static AFNetworkReachabilityManager *_sharedManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _sharedManager = [self manager]; + }); + + return _sharedManager; +} + ++ (instancetype)managerForDomain:(NSString *)domain { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + + CFRelease(reachability); + + return manager; +} + ++ (instancetype)managerForAddress:(const void *)address { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + + CFRelease(reachability); + + return manager; +} + ++ (instancetype)manager +{ +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) + struct sockaddr_in6 address; + bzero(&address, sizeof(address)); + address.sin6_len = sizeof(address); + address.sin6_family = AF_INET6; +#else + struct sockaddr_in address; + bzero(&address, sizeof(address)); + address.sin_len = sizeof(address); + address.sin_family = AF_INET; +#endif + return [self managerForAddress:&address]; +} + +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { + self = [super init]; + if (!self) { + return nil; + } + + _networkReachability = CFRetain(reachability); + self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; + + return self; +} + +- (instancetype)init NS_UNAVAILABLE +{ + return nil; +} + +- (void)dealloc { + [self stopMonitoring]; + + if (_networkReachability != NULL) { + CFRelease(_networkReachability); + } +} + +#pragma mark - + +- (BOOL)isReachable { + return [self isReachableViaWWAN] || [self isReachableViaWiFi]; +} + +- (BOOL)isReachableViaWWAN { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; +} + +- (BOOL)isReachableViaWiFi { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; +} + +#pragma mark - + +- (void)startMonitoring { + [self stopMonitoring]; + + if (!self.networkReachability) { + return; + } + + __weak __typeof(self)weakSelf = self; + AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf.networkReachabilityStatus = status; + if (strongSelf.networkReachabilityStatusBlock) { + strongSelf.networkReachabilityStatusBlock(status); + } + + }; + + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; + SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ + SCNetworkReachabilityFlags flags; + if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) { + AFPostReachabilityStatusChange(flags, callback); + } + }); +} + +- (void)stopMonitoring { + if (!self.networkReachability) { + return; + } + + SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); +} + +#pragma mark - + +- (NSString *)localizedNetworkReachabilityStatusString { + return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); +} + +#pragma mark - + +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { + self.networkReachabilityStatusBlock = block; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { + return [NSSet setWithObject:@"networkReachabilityStatus"]; + } + + return [super keyPathsForValuesAffectingValueForKey:key]; +} + +@end +#endif diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworking.h b/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworking.h new file mode 100644 index 0000000..e2fb2f4 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFNetworking.h @@ -0,0 +1,41 @@ +// AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +#ifndef _AFNETWORKING_ + #define _AFNETWORKING_ + + #import "AFURLRequestSerialization.h" + #import "AFURLResponseSerialization.h" + #import "AFSecurityPolicy.h" + +#if !TARGET_OS_WATCH + #import "AFNetworkReachabilityManager.h" +#endif + + #import "AFURLSessionManager.h" + #import "AFHTTPSessionManager.h" + +#endif /* _AFNETWORKING_ */ diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h b/KtTableView/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h new file mode 100644 index 0000000..c005efa --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1,154 @@ +// AFSecurityPolicy.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, +}; + +/** + `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + + Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFSecurityPolicy : NSObject + +/** + The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. + */ +@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; + +/** + The certificates used to evaluate server trust according to the SSL pinning mode. + + By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`. + + Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. + */ +@property (nonatomic, strong, nullable) NSSet *pinnedCertificates; + +/** + Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowInvalidCertificates; + +/** + Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. + */ +@property (nonatomic, assign) BOOL validatesDomainName; + +///----------------------------------------- +/// @name Getting Certificates from the Bundle +///----------------------------------------- + +/** + Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`. + + @return The certificates included in the given bundle. + */ ++ (NSSet *)certificatesInBundle:(NSBundle *)bundle; + +///----------------------------------------- +/// @name Getting Specific Security Policies +///----------------------------------------- + +/** + Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. + + @return The default security policy. + */ ++ (instancetype)defaultPolicy; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + + @return A new security policy. + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + @param pinnedCertificates The certificates to pin against. + + @return A new security policy. + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates; + +///------------------------------ +/// @name Evaluating Server Trust +///------------------------------ + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + @param domain The domain of serverTrust. If `nil`, the domain will not be validated. + + @return Whether or not to trust the server. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(nullable NSString *)domain; + +@end + +NS_ASSUME_NONNULL_END + +///---------------- +/// @name Constants +///---------------- + +/** + ## SSL Pinning Modes + + The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. + + enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModeNone` + Do not used pinned certificates to validate servers. + + `AFSSLPinningModePublicKey` + Validate host certificates against public keys of pinned certificates. + + `AFSSLPinningModeCertificate` + Validate host certificates against pinned certificates. +*/ diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m b/KtTableView/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m new file mode 100644 index 0000000..ec81d37 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m @@ -0,0 +1,353 @@ +// AFSecurityPolicy.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFSecurityPolicy.h" + +#import + +#if !TARGET_OS_IOS && !TARGET_OS_WATCH && !TARGET_OS_TV +static NSData * AFSecKeyGetData(SecKeyRef key) { + CFDataRef data = NULL; + + __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); + + return (__bridge_transfer NSData *)data; + +_out: + if (data) { + CFRelease(data); + } + + return nil; +} +#endif + +static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV + return [(__bridge id)key1 isEqual:(__bridge id)key2]; +#else + return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; +#endif +} + +static id AFPublicKeyForCertificate(NSData *certificate) { + id allowedPublicKey = nil; + SecCertificateRef allowedCertificate; + SecCertificateRef allowedCertificates[1]; + CFArrayRef tempCertificates = nil; + SecPolicyRef policy = nil; + SecTrustRef allowedTrust = nil; + SecTrustResultType result; + + allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); + __Require_Quiet(allowedCertificate != NULL, _out); + + allowedCertificates[0] = allowedCertificate; + tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); + + policy = SecPolicyCreateBasicX509(); + __Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); + __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); + + allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); + +_out: + if (allowedTrust) { + CFRelease(allowedTrust); + } + + if (policy) { + CFRelease(policy); + } + + if (tempCertificates) { + CFRelease(tempCertificates); + } + + if (allowedCertificate) { + CFRelease(allowedCertificate); + } + + return allowedPublicKey; +} + +static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { + BOOL isValid = NO; + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); + + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + +_out: + return isValid; +} + +static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } + + return [NSArray arrayWithArray:trustChain]; +} + +static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + + SecTrustRef trust; + __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); + + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); + + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + _out: + if (trust) { + CFRelease(trust); + } + + if (certificates) { + CFRelease(certificates); + } + + continue; + } + CFRelease(policy); + + return [NSArray arrayWithArray:trustChain]; +} + +#pragma mark - + +@interface AFSecurityPolicy() +@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; +@property (readwrite, nonatomic, strong) NSSet *pinnedPublicKeys; +@end + +@implementation AFSecurityPolicy + ++ (NSSet *)certificatesInBundle:(NSBundle *)bundle { + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + + NSMutableSet *certificates = [NSMutableSet setWithCapacity:[paths count]]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } + + return [NSSet setWithSet:certificates]; +} + ++ (NSSet *)defaultPinnedCertificates { + static NSSet *_defaultPinnedCertificates = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + _defaultPinnedCertificates = [self certificatesInBundle:bundle]; + }); + + return _defaultPinnedCertificates; +} + ++ (instancetype)defaultPolicy { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = AFSSLPinningModeNone; + + return securityPolicy; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { + return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]]; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = pinningMode; + + [securityPolicy setPinnedCertificates:pinnedCertificates]; + + return securityPolicy; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.validatesDomainName = YES; + + return self; +} + +- (void)setPinnedCertificates:(NSSet *)pinnedCertificates { + _pinnedCertificates = pinnedCertificates; + + if (self.pinnedCertificates) { + NSMutableSet *mutablePinnedPublicKeys = [NSMutableSet setWithCapacity:[self.pinnedCertificates count]]; + for (NSData *certificate in self.pinnedCertificates) { + id publicKey = AFPublicKeyForCertificate(certificate); + if (!publicKey) { + continue; + } + [mutablePinnedPublicKeys addObject:publicKey]; + } + self.pinnedPublicKeys = [NSSet setWithSet:mutablePinnedPublicKeys]; + } else { + self.pinnedPublicKeys = nil; + } +} + +#pragma mark - + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain +{ + if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) { + // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html + // According to the docs, you should only trust your provided certs for evaluation. + // Pinned certificates are added to the trust. Without pinned certificates, + // there is nothing to evaluate against. + // + // From Apple Docs: + // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors). + // Instead, add your own (self-signed) CA certificate to the list of trusted anchors." + NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning."); + return NO; + } + + NSMutableArray *policies = [NSMutableArray array]; + if (self.validatesDomainName) { + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; + } else { + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; + } + + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); + + if (self.SSLPinningMode == AFSSLPinningModeNone) { + return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust); + } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { + return NO; + } + + switch (self.SSLPinningMode) { + case AFSSLPinningModeNone: + default: + return NO; + case AFSSLPinningModeCertificate: { + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + for (NSData *certificateData in self.pinnedCertificates) { + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + } + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + + if (!AFServerTrustIsValid(serverTrust)) { + return NO; + } + + // obtain the chain after being validated, which *should* contain the pinned certificate in the last position (if it's the Root CA) + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); + + for (NSData *trustChainCertificate in [serverCertificates reverseObjectEnumerator]) { + if ([self.pinnedCertificates containsObject:trustChainCertificate]) { + return YES; + } + } + + return NO; + } + case AFSSLPinningModePublicKey: { + NSUInteger trustedPublicKeyCount = 0; + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); + + for (id trustChainPublicKey in publicKeys) { + for (id pinnedPublicKey in self.pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + trustedPublicKeyCount += 1; + } + } + } + return trustedPublicKeyCount > 0; + } + } + + return NO; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { + return [NSSet setWithObject:@"pinnedCertificates"]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + + self = [self init]; + if (!self) { + return nil; + } + + self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue]; + self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; + self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))]; + self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))]; + [coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; + [coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))]; + [coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init]; + securityPolicy.SSLPinningMode = self.SSLPinningMode; + securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates; + securityPolicy.validatesDomainName = self.validatesDomainName; + securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone]; + + return securityPolicy; +} + +@end diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h new file mode 100644 index 0000000..694696b --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1,479 @@ +// AFURLRequestSerialization.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import +#elif TARGET_OS_WATCH +#import +#endif + +NS_ASSUME_NONNULL_BEGIN + +/** + Returns a percent-escaped string following RFC 3986 for a query string key or value. + RFC 3986 states that the following characters are "reserved" characters. + - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + should be percent-escaped in the query string. + + @param string The string to be percent-escaped. + + @return The percent-escaped string. + */ +FOUNDATION_EXPORT NSString * AFPercentEscapedStringFromString(NSString *string); + +/** + A helper method to generate encoded url query parameters for appending to the end of a URL. + + @param parameters A dictionary of key/values to be encoded. + + @return A url encoded query string + */ +FOUNDATION_EXPORT NSString * AFQueryStringFromParameters(NSDictionary *parameters); + +/** + The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary. + + For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`. + */ +@protocol AFURLRequestSerialization + +/** + Returns a request with the specified parameters encoded into a copy of the original request. + + @param request The original request. + @param parameters The parameters to be encoded. + @param error The error that occurred while attempting to encode the request parameters. + + @return A serialized request. + */ +- (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(nullable id)parameters + error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; + +@end + +#pragma mark - + +/** + + */ +typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) { + AFHTTPRequestQueryStringDefaultStyle = 0, +}; + +@protocol AFMultipartFormData; + +/** + `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPRequestSerializer : NSObject + +/** + The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Whether created requests can use the device’s cellular radio (if present). `YES` by default. + + @see NSMutableURLRequest -setAllowsCellularAccess: + */ +@property (nonatomic, assign) BOOL allowsCellularAccess; + +/** + The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default. + + @see NSMutableURLRequest -setCachePolicy: + */ +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; + +/** + Whether created requests should use the default cookie handling. `YES` by default. + + @see NSMutableURLRequest -setHTTPShouldHandleCookies: + */ +@property (nonatomic, assign) BOOL HTTPShouldHandleCookies; + +/** + Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default + + @see NSMutableURLRequest -setHTTPShouldUsePipelining: + */ +@property (nonatomic, assign) BOOL HTTPShouldUsePipelining; + +/** + The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default. + + @see NSMutableURLRequest -setNetworkServiceType: + */ +@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType; + +/** + The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds. + + @see NSMutableURLRequest -setTimeoutInterval: + */ +@property (nonatomic, assign) NSTimeInterval timeoutInterval; + +///--------------------------------------- +/// @name Configuring HTTP Request Headers +///--------------------------------------- + +/** + Default HTTP header field values to be applied to serialized requests. By default, these include the following: + + - `Accept-Language` with the contents of `NSLocale +preferredLanguages` + - `User-Agent` with the contents of various bundle identifiers and OS designations + + @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +/** + Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header. + + @param field The HTTP header to set a default value for + @param value The value set as default for the specified header, or `nil` + */ +- (void)setValue:(nullable NSString *)value +forHTTPHeaderField:(NSString *)field; + +/** + Returns the value for the HTTP headers set in the request serializer. + + @param field The HTTP header to retrieve the default value for + + @return The value set as default for the specified header, or `nil` + */ +- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. + + @param username The HTTP basic auth username + @param password The HTTP basic auth password + */ +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password; + +/** + Clears any existing value for the "Authorization" HTTP header. + */ +- (void)clearAuthorizationHeader; + +///------------------------------------------------------- +/// @name Configuring Query String Parameter Serialization +///------------------------------------------------------- + +/** + HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. + */ +@property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; + +/** + Set the method of query string serialization according to one of the pre-defined styles. + + @param style The serialization style. + + @see AFHTTPRequestQueryStringSerializationStyle + */ +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style; + +/** + Set the a custom method of query string serialization according to the specified block. + + @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request. + */ +- (void)setQueryStringSerializationWithBlock:(nullable NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block; + +///------------------------------- +/// @name Creating Request Objects +///------------------------------- + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. + + If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. + + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable id)parameters + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 + + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. + + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable NSDictionary *)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished. + + @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`. + @param fileURL The file URL to write multipart form contents to. + @param handler A handler block to execute. + + @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request. + + @see https://github.com/AFNetworking/AFNetworking/issues/1398 + */ +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(nullable void (^)(NSError * _Nullable error))handler; + +@end + +#pragma mark - + +/** + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`. + */ +@protocol AFMultipartFormData + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended, otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * _Nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + */ + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name; + + +/** + Appends HTTP headers, followed by the encoded data and the multipart form boundary. + + @param headers The HTTP headers to be appended to the form data. + @param body The data to be encoded and appended to the form data. This parameter must not be `nil`. + */ +- (void)appendPartWithHeaders:(nullable NSDictionary *)headers + body:(NSData *)body; + +/** + Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. + + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb. + @param delay Duration of delay each time a packet is read. By default, no delay is set. + */ +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay; + +@end + +#pragma mark - + +/** + `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`. + */ +@interface AFJSONRequestSerializer : AFHTTPRequestSerializer + +/** + Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONWritingOptions writingOptions; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param writingOptions The specified JSON writing options. + */ ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions; + +@end + +#pragma mark - + +/** + `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`. + */ +@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + @warning The `writeOptions` property is currently unused. + */ +@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param writeOptions The property list write options. + + @warning The `writeOptions` property is currently unused. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions; + +@end + +#pragma mark - + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLRequestSerializationErrorDomain` + + ### Constants + + `AFURLRequestSerializationErrorDomain` + AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLRequestErrorKey` + The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey; + +/** + ## Throttling Bandwidth for HTTP Request Input Streams + + @see -throttleBandwidthWithPacketSize:delay: + + ### Constants + + `kAFUploadStream3GSuggestedPacketSize` + Maximum packet size, in number of bytes. Equal to 16kb. + + `kAFUploadStream3GSuggestedDelay` + Duration of delay each time a packet is read. Equal to 0.2 seconds. + */ +FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize; +FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay; + +NS_ASSUME_NONNULL_END diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m new file mode 100644 index 0000000..9a2ac98 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m @@ -0,0 +1,1376 @@ +// AFURLRequestSerialization.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLRequestSerialization.h" + +#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV +#import +#else +#import +#endif + +NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request"; +NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response"; + +typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error); + +/** + Returns a percent-escaped string following RFC 3986 for a query string key or value. + RFC 3986 states that the following characters are "reserved" characters. + - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + should be percent-escaped in the query string. + - parameter string: The string to be percent-escaped. + - returns: The percent-escaped string. + */ +NSString * AFPercentEscapedStringFromString(NSString *string) { + static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4 + static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;="; + + NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; + [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]]; + + // FIXME: https://github.com/AFNetworking/AFNetworking/pull/3028 + // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + + static NSUInteger const batchSize = 50; + + NSUInteger index = 0; + NSMutableString *escaped = @"".mutableCopy; + + while (index < string.length) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wgnu" + NSUInteger length = MIN(string.length - index, batchSize); +#pragma GCC diagnostic pop + NSRange range = NSMakeRange(index, length); + + // To avoid breaking up character sequences such as 👴🏻👮🏽 + range = [string rangeOfComposedCharacterSequencesForRange:range]; + + NSString *substring = [string substringWithRange:range]; + NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + [escaped appendString:encoded]; + + index += range.length; + } + + return escaped; +} + +#pragma mark - + +@interface AFQueryStringPair : NSObject +@property (readwrite, nonatomic, strong) id field; +@property (readwrite, nonatomic, strong) id value; + +- (instancetype)initWithField:(id)field value:(id)value; + +- (NSString *)URLEncodedStringValue; +@end + +@implementation AFQueryStringPair + +- (instancetype)initWithField:(id)field value:(id)value { + self = [super init]; + if (!self) { + return nil; + } + + self.field = field; + self.value = value; + + return self; +} + +- (NSString *)URLEncodedStringValue { + if (!self.value || [self.value isEqual:[NSNull null]]) { + return AFPercentEscapedStringFromString([self.field description]); + } else { + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedStringFromString([self.field description]), AFPercentEscapedStringFromString([self.value description])]; + } +} + +@end + +#pragma mark - + +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary); +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value); + +NSString * AFQueryStringFromParameters(NSDictionary *parameters) { + NSMutableArray *mutablePairs = [NSMutableArray array]; + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + [mutablePairs addObject:[pair URLEncodedStringValue]]; + } + + return [mutablePairs componentsJoinedByString:@"&"]; +} + +NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) { + return AFQueryStringPairsFromKeyAndValue(nil, dictionary); +} + +NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; + + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)]; + + if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = dictionary[nestedKey]; + if (nestedValue) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; + } + } + } else if ([value isKindOfClass:[NSArray class]]) { + NSArray *array = value; + for (id nestedValue in array) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; + } + } else { + [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; + } + + return mutableQueryStringComponents; +} + +#pragma mark - + +@interface AFStreamingMultipartFormData : NSObject +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding; + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; +@end + +#pragma mark - + +static NSArray * AFHTTPRequestSerializerObservedKeyPaths() { + static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))]; + }); + + return _AFHTTPRequestSerializerObservedKeyPaths; +} + +static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext; + +@interface AFHTTPRequestSerializer () +@property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders; +@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle; +@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization; +@end + +@implementation AFHTTPRequestSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary]; + + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + float q = 1.0f - (idx * 0.1f); + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; + *stop = q <= 0.5f; + }]; + [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; + + NSString *userAgent = nil; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" +#if TARGET_OS_IOS + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif TARGET_OS_WATCH + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]]; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; +#endif +#pragma clang diagnostic pop + if (userAgent) { + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { + NSMutableString *mutableUserAgent = [userAgent mutableCopy]; + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { + userAgent = mutableUserAgent; + } + } + [self setValue:userAgent forHTTPHeaderField:@"User-Agent"]; + } + + // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html + self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil]; + + self.mutableObservedChangedKeyPaths = [NSMutableSet set]; + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext]; + } + } + + return self; +} + +- (void)dealloc { + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext]; + } + } +} + +#pragma mark - + +// Workarounds for crashing behavior using Key-Value Observing with XCTest +// See https://github.com/AFNetworking/AFNetworking/issues/2523 + +- (void)setAllowsCellularAccess:(BOOL)allowsCellularAccess { + [self willChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; + _allowsCellularAccess = allowsCellularAccess; + [self didChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; +} + +- (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy { + [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; + _cachePolicy = cachePolicy; + [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; +} + +- (void)setHTTPShouldHandleCookies:(BOOL)HTTPShouldHandleCookies { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; + _HTTPShouldHandleCookies = HTTPShouldHandleCookies; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; +} + +- (void)setHTTPShouldUsePipelining:(BOOL)HTTPShouldUsePipelining { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; + _HTTPShouldUsePipelining = HTTPShouldUsePipelining; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; +} + +- (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType { + [self willChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; + _networkServiceType = networkServiceType; + [self didChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; +} + +- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval { + [self willChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; + _timeoutInterval = timeoutInterval; + [self didChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; +} + +#pragma mark - + +- (NSDictionary *)HTTPRequestHeaders { + return [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders]; +} + +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field +{ + [self.mutableHTTPRequestHeaders setValue:value forKey:field]; +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + return [self.mutableHTTPRequestHeaders valueForKey:field]; +} + +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password +{ + NSData *basicAuthCredentials = [[NSString stringWithFormat:@"%@:%@", username, password] dataUsingEncoding:NSUTF8StringEncoding]; + NSString *base64AuthCredentials = [basicAuthCredentials base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0]; + [self setValue:[NSString stringWithFormat:@"Basic %@", base64AuthCredentials] forHTTPHeaderField:@"Authorization"]; +} + +- (void)clearAuthorizationHeader { + [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; +} + +#pragma mark - + +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style { + self.queryStringSerializationStyle = style; + self.queryStringSerialization = nil; +} + +- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, id, NSError *__autoreleasing *))block { + self.queryStringSerialization = block; +} + +#pragma mark - + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(URLString); + + NSURL *url = [NSURL URLWithString:URLString]; + + NSParameterAssert(url); + + NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url]; + mutableRequest.HTTPMethod = method; + + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) { + [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath]; + } + } + + mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy]; + + return mutableRequest; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); + + NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error]; + + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding]; + + if (parameters) { + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + NSData *data = nil; + if ([pair.value isKindOfClass:[NSData class]]) { + data = pair.value; + } else if ([pair.value isEqual:[NSNull null]]) { + data = [NSData data]; + } else { + data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; + } + + if (data) { + [formData appendPartWithFormData:data name:[pair.field description]]; + } + } + } + + if (block) { + block(formData); + } + + return [formData requestByFinalizingMultipartFormData]; +} + +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler +{ + NSParameterAssert(request.HTTPBodyStream); + NSParameterAssert([fileURL isFileURL]); + + NSInputStream *inputStream = request.HTTPBodyStream; + NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO]; + __block NSError *error = nil; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputStream open]; + [outputStream open]; + + while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) { + uint8_t buffer[1024]; + + NSInteger bytesRead = [inputStream read:buffer maxLength:1024]; + if (inputStream.streamError || bytesRead < 0) { + error = inputStream.streamError; + break; + } + + NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead]; + if (outputStream.streamError || bytesWritten < 0) { + error = outputStream.streamError; + break; + } + + if (bytesRead == 0 && bytesWritten == 0) { + break; + } + } + + [outputStream close]; + [inputStream close]; + + if (handler) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler(error); + }); + } + }); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + mutableRequest.HTTPBodyStream = nil; + + return mutableRequest; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + NSString *query = nil; + if (parameters) { + if (self.queryStringSerialization) { + NSError *serializationError; + query = self.queryStringSerialization(request, parameters, &serializationError); + + if (serializationError) { + if (error) { + *error = serializationError; + } + + return nil; + } + } else { + switch (self.queryStringSerializationStyle) { + case AFHTTPRequestQueryStringDefaultStyle: + query = AFQueryStringFromParameters(parameters); + break; + } + } + } + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + if (query && query.length > 0) { + mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]]; + } + } else { + // #2864: an empty string is a valid x-www-form-urlencoded payload + if (!query) { + query = @""; + } + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + } + [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]]; + } + + return mutableRequest; +} + +#pragma mark - NSKeyValueObserving + ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key { + if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) { + return NO; + } + + return [super automaticallyNotifiesObserversForKey:key]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(__unused id)object + change:(NSDictionary *)change + context:(void *)context +{ + if (context == AFHTTPRequestSerializerObserverContext) { + if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) { + [self.mutableObservedChangedKeyPaths removeObject:keyPath]; + } else { + [self.mutableObservedChangedKeyPaths addObject:keyPath]; + } + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy]; + self.queryStringSerializationStyle = (AFHTTPRequestQueryStringSerializationStyle)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; + [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; + serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; + serializer.queryStringSerialization = self.queryStringSerialization; + + return serializer; +} + +@end + +#pragma mark - + +static NSString * AFCreateMultipartFormBoundary() { + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; +} + +static NSString * const kAFMultipartFormCRLF = @"\r\n"; + +static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFContentTypeForPathExtension(NSString *extension) { + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } +} + +NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16; +NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; + +@interface AFHTTPBodyPart : NSObject +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSDictionary *headers; +@property (nonatomic, copy) NSString *boundary; +@property (nonatomic, strong) id body; +@property (nonatomic, assign) unsigned long long bodyContentLength; +@property (nonatomic, strong) NSInputStream *inputStream; + +@property (nonatomic, assign) BOOL hasInitialBoundary; +@property (nonatomic, assign) BOOL hasFinalBoundary; + +@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (readonly, nonatomic, assign) unsigned long long contentLength; + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@interface AFMultipartBodyStream : NSInputStream +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (readonly, nonatomic, assign) unsigned long long contentLength; +@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; + +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding; +- (void)setInitialAndFinalBoundaries; +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; +@end + +#pragma mark - + +@interface AFStreamingMultipartFormData () +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, copy) NSString *boundary; +@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; +@end + +@implementation AFStreamingMultipartFormData + +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding +{ + self = [super init]; + if (!self) { + return nil; + } + + self.request = urlRequest; + self.stringEncoding = encoding; + self.boundary = AFCreateMultipartFormBoundary(); + self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; + + return self; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + + NSString *fileName = [fileURL lastPathComponent]; + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + if (![fileURL isFileURL]) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error]; + if (!fileAttributes) { + return NO; + } + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = fileURL; + bodyPart.bodyContentLength = [fileAttributes[NSFileSize] unsignedLongLongValue]; + [self.bodyStream appendHTTPBodyPart:bodyPart]; + + return YES; +} + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = (unsigned long long)length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name +{ + NSParameterAssert(name); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body +{ + NSParameterAssert(body); + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = headers; + bodyPart.boundary = self.boundary; + bodyPart.bodyContentLength = [body length]; + bodyPart.body = body; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay +{ + self.bodyStream.numberOfBytesInPacket = numberOfBytes; + self.bodyStream.delay = delay; +} + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { + if ([self.bodyStream isEmpty]) { + return self.request; + } + + // Reset the initial and final boundaries to ensure correct Content-Length + [self.bodyStream setInitialAndFinalBoundaries]; + [self.request setHTTPBodyStream:self.bodyStream]; + + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; + + return self.request; +} + +@end + +#pragma mark - + +@interface NSStream () +@property (readwrite) NSStreamStatus streamStatus; +@property (readwrite, copy) NSError *streamError; +@end + +@interface AFMultipartBodyStream () +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts; +@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; +@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; +@property (readwrite, nonatomic, strong) NSOutputStream *outputStream; +@property (readwrite, nonatomic, strong) NSMutableData *buffer; +@end + +@implementation AFMultipartBodyStream +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-atomic-properties" +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100) +@synthesize delegate; +#endif +@synthesize streamStatus; +@synthesize streamError; +#pragma clang diagnostic pop + +- (instancetype)initWithStringEncoding:(NSStringEncoding)encoding { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = encoding; + self.HTTPBodyParts = [NSMutableArray array]; + self.numberOfBytesInPacket = NSIntegerMax; + + return self; +} + +- (void)setInitialAndFinalBoundaries { + if ([self.HTTPBodyParts count] > 0) { + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + bodyPart.hasInitialBoundary = NO; + bodyPart.hasFinalBoundary = NO; + } + + [[self.HTTPBodyParts firstObject] setHasInitialBoundary:YES]; + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; + } +} + +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { + [self.HTTPBodyParts addObject:bodyPart]; +} + +- (BOOL)isEmpty { + return [self.HTTPBodyParts count] == 0; +} + +#pragma mark - NSInputStream + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + if ([self streamStatus] == NSStreamStatusClosed) { + return 0; + } + + NSInteger totalNumberOfBytesRead = 0; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) { + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { + break; + } + } else { + NSUInteger maxLength = MIN(length, self.numberOfBytesInPacket) - (NSUInteger)totalNumberOfBytesRead; + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength]; + if (numberOfBytesRead == -1) { + self.streamError = self.currentHTTPBodyPart.inputStream.streamError; + break; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } + } + } + } +#pragma clang diagnostic pop + + return totalNumberOfBytesRead; +} + +- (BOOL)getBuffer:(__unused uint8_t **)buffer + length:(__unused NSUInteger *)len +{ + return NO; +} + +- (BOOL)hasBytesAvailable { + return [self streamStatus] == NSStreamStatusOpen; +} + +#pragma mark - NSStream + +- (void)open { + if (self.streamStatus == NSStreamStatusOpen) { + return; + } + + self.streamStatus = NSStreamStatusOpen; + + [self setInitialAndFinalBoundaries]; + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; +} + +- (void)close { + self.streamStatus = NSStreamStatusClosed; +} + +- (id)propertyForKey:(__unused NSString *)key { + return nil; +} + +- (BOOL)setProperty:(__unused id)property + forKey:(__unused NSString *)key +{ + return NO; +} + +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + length += [bodyPart contentLength]; + } + + return length; +} + +#pragma mark - Undocumented CFReadStream Bridged Methods + +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { + return NO; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + +@end + +#pragma mark - + +typedef enum { + AFEncapsulationBoundaryPhase = 1, + AFHeaderPhase = 2, + AFBodyPhase = 3, + AFFinalBoundaryPhase = 4, +} AFHTTPBodyPartReadPhase; + +@interface AFHTTPBodyPart () { + AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; + unsigned long long _phaseReadOffset; +} + +- (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@implementation AFHTTPBodyPart + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + [self transitionToNextPhase]; + + return self; +} + +- (void)dealloc { + if (_inputStream) { + [_inputStream close]; + _inputStream = nil; + } +} + +- (NSInputStream *)inputStream { + if (!_inputStream) { + if ([self.body isKindOfClass:[NSData class]]) { + _inputStream = [NSInputStream inputStreamWithData:self.body]; + } else if ([self.body isKindOfClass:[NSURL class]]) { + _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } else if ([self.body isKindOfClass:[NSInputStream class]]) { + _inputStream = self.body; + } else { + _inputStream = [NSInputStream inputStreamWithData:[NSData data]]; + } + } + + return _inputStream; +} + +- (NSString *)stringForHeaders { + NSMutableString *headerString = [NSMutableString string]; + for (NSString *field in [self.headers allKeys]) { + [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; + } + [headerString appendString:kAFMultipartFormCRLF]; + + return [NSString stringWithString:headerString]; +} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + length += [encapsulationBoundaryData length]; + + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + length += [headersData length]; + + length += _bodyContentLength; + + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + length += [closingBoundaryData length]; + + return length; +} + +- (BOOL)hasBytesAvailable { + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer + if (_phase == AFFinalBoundaryPhase) { + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (self.inputStream.streamStatus) { + case NSStreamStatusNotOpen: + case NSStreamStatusOpening: + case NSStreamStatusOpen: + case NSStreamStatusReading: + case NSStreamStatusWriting: + return YES; + case NSStreamStatusAtEnd: + case NSStreamStatusClosed: + case NSStreamStatusError: + default: + return NO; + } +#pragma clang diagnostic pop +} + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + NSInteger totalNumberOfBytesRead = 0; + + if (_phase == AFEncapsulationBoundaryPhase) { + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFHeaderPhase) { + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFBodyPhase) { + NSInteger numberOfBytesRead = 0; + + numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + if (numberOfBytesRead == -1) { + return -1; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) { + [self transitionToNextPhase]; + } + } + } + + if (_phase == AFFinalBoundaryPhase) { + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + return totalNumberOfBytesRead; +} + +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); + [data getBytes:buffer range:range]; +#pragma clang diagnostic pop + + _phaseReadOffset += range.length; + + if (((NSUInteger)_phaseReadOffset) >= [data length]) { + [self transitionToNextPhase]; + } + + return (NSInteger)range.length; +} + +- (BOOL)transitionToNextPhase { + if (![[NSThread currentThread] isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self transitionToNextPhase]; + }); + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (_phase) { + case AFEncapsulationBoundaryPhase: + _phase = AFHeaderPhase; + break; + case AFHeaderPhase: + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; + [self.inputStream open]; + _phase = AFBodyPhase; + break; + case AFBodyPhase: + [self.inputStream close]; + _phase = AFFinalBoundaryPhase; + break; + case AFFinalBoundaryPhase: + default: + _phase = AFEncapsulationBoundaryPhase; + break; + } + _phaseReadOffset = 0; +#pragma clang diagnostic pop + + return YES; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + bodyPart.boundary = self.boundary; + + return bodyPart; +} + +@end + +#pragma mark - + +@implementation AFJSONRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithWritingOptions:(NSJSONWritingOptions)0]; +} + ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions +{ + AFJSONRequestSerializer *serializer = [[self alloc] init]; + serializer.writingOptions = writingOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.writingOptions = self.writingOptions; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFPropertyListRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions +{ + AFPropertyListRequestSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.writeOptions = writeOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerializer + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.format = self.format; + serializer.writeOptions = self.writeOptions; + + return serializer; +} + +@end diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h new file mode 100644 index 0000000..a9430ad --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1,311 @@ +// AFURLResponseSerialization.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. + + For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. + */ +@protocol AFURLResponseSerialization + +/** + The response object decoded from the data associated with a specified response. + + @param response The response to be processed. + @param data The response data to be decoded. + @param error The error that occurred while attempting to decode the response data. + + @return The object decoded from the specified response data. + */ +- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response + data:(nullable NSData *)data + error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; + +@end + +#pragma mark - + +/** + `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPResponseSerializer : NSObject + +- (instancetype)init; + +/** + The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +///----------------------------------------- +/// @name Configuring Response Serialization +///----------------------------------------- + +/** + The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. + + See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + */ +@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes; + +/** + The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. + */ +@property (nonatomic, copy, nullable) NSSet *acceptableContentTypes; + +/** + Validates the specified response and data. + + In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. + + @param response The response to be validated. + @param data The data associated with the response. + @param error The error that occurred while attempting to validate the response. + + @return `YES` if the response is valid, otherwise `NO`. + */ +- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response + data:(nullable NSData *)data + error:(NSError * _Nullable __autoreleasing *)error; + +@end + +#pragma mark - + + +/** + `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. + + By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: + + - `application/json` + - `text/json` + - `text/javascript` + */ +@interface AFJSONResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONReadingOptions readingOptions; + +/** + Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL removesKeysWithNullValues; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param readingOptions The specified JSON reading options. + */ ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; + +@end + +#pragma mark - + +/** + `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. + + By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +/** + `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSUInteger options; + +/** + Creates and returns an XML document serializer with the specified options. + + @param mask The XML document options. + */ ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; + +@end + +#endif + +#pragma mark - + +/** + `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFPropertyListResponseSerializer` accepts the following MIME types: + + - `application/x-plist` + */ +@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." + */ +@property (nonatomic, assign) NSPropertyListReadOptions readOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param readOptions The property list reading options. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions; + +@end + +#pragma mark - + +/** + `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. + + By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: + + - `image/tiff` + - `image/jpeg` + - `image/gif` + - `image/png` + - `image/ico` + - `image/x-icon` + - `image/bmp` + - `image/x-bmp` + - `image/x-xbitmap` + - `image/x-win-bitmap` + */ +@interface AFImageResponseSerializer : AFHTTPResponseSerializer + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH +/** + The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. + */ +@property (nonatomic, assign) CGFloat imageScale; + +/** + Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. + */ +@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; +#endif + +@end + +#pragma mark - + +/** + `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. + */ +@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer + +/** + The component response serializers. + */ +@property (readonly, nonatomic, copy) NSArray > *responseSerializers; + +/** + Creates and returns a compound serializer comprised of the specified response serializers. + + @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. + */ ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray > *)responseSerializers; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLResponseSerializationErrorDomain` + + ### Constants + + `AFURLResponseSerializationErrorDomain` + AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` + - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLResponseErrorKey` + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + + `AFNetworkingOperationFailingURLResponseDataErrorKey` + The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey; + +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m new file mode 100755 index 0000000..5e46799 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m @@ -0,0 +1,805 @@ +// AFURLResponseSerialization.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLResponseSerialization.h" + +#import + +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#import +#endif + +NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response"; +NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response"; +NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data"; + +static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) { + if (!error) { + return underlyingError; + } + + if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) { + return error; + } + + NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy]; + mutableUserInfo[NSUnderlyingErrorKey] = underlyingError; + + return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo]; +} + +static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) { + if ([error.domain isEqualToString:domain] && error.code == code) { + return YES; + } else if (error.userInfo[NSUnderlyingErrorKey]) { + return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain); + } + + return NO; +} + +static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { + if ([JSONObject isKindOfClass:[NSArray class]]) { + NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; + for (id value in (NSArray *)JSONObject) { + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; + } else if ([JSONObject isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject]; + for (id key in [(NSDictionary *)JSONObject allKeys]) { + id value = (NSDictionary *)JSONObject[key]; + if (!value || [value isEqual:[NSNull null]]) { + [mutableDictionary removeObjectForKey:key]; + } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) { + mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions); + } + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary]; + } + + return JSONObject; +} + +@implementation AFHTTPResponseSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; + self.acceptableContentTypes = nil; + + return self; +} + +#pragma mark - + +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError * __autoreleasing *)error +{ + BOOL responseIsValid = YES; + NSError *validationError = nil; + + if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) { + if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] && + !([response MIMEType] == nil && [data length] == 0)) { + + if ([data length] > 0 && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError); + } + + responseIsValid = NO; + } + + if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError); + + responseIsValid = NO; + } + } + + if (error && !responseIsValid) { + *error = validationError; + } + + return responseIsValid; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + [self validateResponse:(NSHTTPURLResponse *)response data:data error:error]; + + return data; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; + serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFJSONResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithReadingOptions:(NSJSONReadingOptions)0]; +} + ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions { + AFJSONResponseSerializer *serializer = [[self alloc] init]; + serializer.readingOptions = readingOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + id responseObject = nil; + NSError *serializationError = nil; + // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. + // See https://github.com/rails/rails/issues/1742 + BOOL isSpace = [data isEqualToData:[NSData dataWithBytes:" " length:1]]; + if (data.length > 0 && !isSpace) { + responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError]; + } else { + return nil; + } + + if (self.removesKeysWithNullValues && responseObject) { + responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions); + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue]; + self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))]; + [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.readingOptions = self.readingOptions; + serializer.removesKeysWithNullValues = self.removesKeysWithNullValues; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFXMLParserResponseSerializer + ++ (instancetype)serializer { + AFXMLParserResponseSerializer *serializer = [[self alloc] init]; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + return [[NSXMLParser alloc] initWithData:data]; +} + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +@implementation AFXMLDocumentResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithXMLDocumentOptions:0]; +} + ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask { + AFXMLDocumentResponseSerializer *serializer = [[self alloc] init]; + serializer.options = mask; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + NSError *serializationError = nil; + NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError]; + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return document; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.options = self.options; + + return serializer; +} + +@end + +#endif + +#pragma mark - + +@implementation AFPropertyListResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions +{ + AFPropertyListResponseSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.readOptions = readOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + id responseObject; + NSError *serializationError = nil; + + if (data) { + responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError]; + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.format = self.format; + serializer.readOptions = self.readOptions; + + return serializer; +} + +@end + +#pragma mark - + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH +#import +#import + +@interface UIImage (AFNetworkingSafeImageLoading) ++ (UIImage *)af_safeImageWithData:(NSData *)data; +@end + +static NSLock* imageLock = nil; + +@implementation UIImage (AFNetworkingSafeImageLoading) + ++ (UIImage *)af_safeImageWithData:(NSData *)data { + UIImage* image = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + imageLock = [[NSLock alloc] init]; + }); + + [imageLock lock]; + image = [UIImage imageWithData:data]; + [imageLock unlock]; + return image; +} + +@end + +static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { + UIImage *image = [UIImage af_safeImageWithData:data]; + if (image.images) { + return image; + } + + return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; +} + +static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { + if (!data || [data length] == 0) { + return nil; + } + + CGImageRef imageRef = NULL; + CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); + + if ([response.MIMEType isEqualToString:@"image/png"]) { + imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) { + imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + + if (imageRef) { + CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef); + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace); + + // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale + if (imageColorSpaceModel == kCGColorSpaceModelCMYK) { + CGImageRelease(imageRef); + imageRef = NULL; + } + } + } + + CGDataProviderRelease(dataProvider); + + UIImage *image = AFImageWithDataAtScale(data, scale); + if (!imageRef) { + if (image.images || !image) { + return image; + } + + imageRef = CGImageCreateCopy([image CGImage]); + if (!imageRef) { + return nil; + } + } + + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); + + if (width * height > 1024 * 1024 || bitsPerComponent > 8) { + CGImageRelease(imageRef); + + return image; + } + + // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate + size_t bytesPerRow = 0; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + + if (colorSpaceModel == kCGColorSpaceModelRGB) { + uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" + if (alpha == kCGImageAlphaNone) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaNoneSkipFirst; + } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaPremultipliedFirst; + } +#pragma clang diagnostic pop + } + + CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); + + CGColorSpaceRelease(colorSpace); + + if (!context) { + CGImageRelease(imageRef); + + return image; + } + + CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef); + CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation]; + + CGImageRelease(inflatedImageRef); + CGImageRelease(imageRef); + + return inflatedImage; +} +#endif + + +@implementation AFImageResponseSerializer + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil]; + +#if TARGET_OS_IOS || TARGET_OS_TV + self.imageScale = [[UIScreen mainScreen] scale]; + self.automaticallyInflatesResponseImage = YES; +#elif TARGET_OS_WATCH + self.imageScale = [[WKInterfaceDevice currentDevice] screenScale]; + self.automaticallyInflatesResponseImage = YES; +#endif + + return self; +} + +#pragma mark - AFURLResponseSerializer + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + if (self.automaticallyInflatesResponseImage) { + return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale); + } else { + return AFImageWithDataAtScale(data, self.imageScale); + } +#else + // Ensure that the image is set to it's correct pixel width and height + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data]; + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; + [image addRepresentation:bitimage]; + + return image; +#endif + + return nil; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))]; +#if CGFLOAT_IS_DOUBLE + self.imageScale = [imageScale doubleValue]; +#else + self.imageScale = [imageScale floatValue]; +#endif + + self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))]; + [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + +#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH + serializer.imageScale = self.imageScale; + serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage; +#endif + + return serializer; +} + +@end + +#pragma mark - + +@interface AFCompoundResponseSerializer () +@property (readwrite, nonatomic, copy) NSArray *responseSerializers; +@end + +@implementation AFCompoundResponseSerializer + ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers { + AFCompoundResponseSerializer *serializer = [[self alloc] init]; + serializer.responseSerializers = responseSerializers; + + return serializer; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + for (id serializer in self.responseSerializers) { + if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) { + continue; + } + + NSError *serializerError = nil; + id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError]; + if (responseObject) { + if (error) { + *error = AFErrorWithUnderlyingError(serializerError, *error); + } + + return responseObject; + } + } + + return [super responseObjectForResponse:response data:data error:error]; +} + +#pragma mark - NSSecureCoding + +- (instancetype)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.responseSerializers = self.responseSerializers; + + return serializer; +} + +@end diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h new file mode 100644 index 0000000..89909fe --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h @@ -0,0 +1,500 @@ +// AFURLSessionManager.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import + +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#if !TARGET_OS_WATCH +#import "AFNetworkReachabilityManager.h" +#endif + +/** + `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + + ## Subclassing Notes + + This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead. + + ## NSURLSession & NSURLSessionTask Delegate Methods + + `AFURLSessionManager` implements the following delegate methods: + + ### `NSURLSessionDelegate` + + - `URLSession:didBecomeInvalidWithError:` + - `URLSession:didReceiveChallenge:completionHandler:` + - `URLSessionDidFinishEventsForBackgroundURLSession:` + + ### `NSURLSessionTaskDelegate` + + - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:` + - `URLSession:task:didReceiveChallenge:completionHandler:` + - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` + - `URLSession:task:needNewBodyStream:` + - `URLSession:task:didCompleteWithError:` + + ### `NSURLSessionDataDelegate` + + - `URLSession:dataTask:didReceiveResponse:completionHandler:` + - `URLSession:dataTask:didBecomeDownloadTask:` + - `URLSession:dataTask:didReceiveData:` + - `URLSession:dataTask:willCacheResponse:completionHandler:` + + ### `NSURLSessionDownloadDelegate` + + - `URLSession:downloadTask:didFinishDownloadingToURL:` + - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:` + - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSCoding Caveats + + - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`. + + ## NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original. + - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFURLSessionManager : NSObject + +/** + The managed session. + */ +@property (readonly, nonatomic, strong) NSURLSession *session; + +/** + The operation queue on which delegate callbacks are run. + */ +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) id responseSerializer; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created session to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +#if !TARGET_OS_WATCH +///-------------------------------------- +/// @name Monitoring Network Reachability +///-------------------------------------- + +/** + The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; +#endif + +///---------------------------- +/// @name Getting Session Tasks +///---------------------------- + +/** + The data, upload, and download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *tasks; + +/** + The data tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *dataTasks; + +/** + The upload tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *uploadTasks; + +/** + The download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *downloadTasks; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; + +///--------------------------------- +/// @name Working Around System Bugs +///--------------------------------- + +/** + Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default. + + @bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again. + + @see https://github.com/AFNetworking/AFNetworking/issues/1675 + */ +@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a manager for a session created with the specified configuration. This is the designated initializer. + + @param configuration The configuration used to create the managed session. + + @return A manager for a newly-created session. + */ +- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +/** + Invalidates the managed session, optionally canceling pending tasks. + + @param cancelPendingTasks Whether or not to cancel pending tasks. + */ +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks; + +///------------------------- +/// @name Running Data Tasks +///------------------------- + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + uploadProgress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +///--------------------------- +/// @name Running Upload Tasks +///--------------------------- + +/** + Creates an `NSURLSessionUploadTask` with the specified request for a local file. + + @param request The HTTP request for the request. + @param fileURL A URL to the local file to be uploaded. + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + + @see `attemptsToRecreateUploadTasksForBackgroundSessions` + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body. + + @param request The HTTP request for the request. + @param bodyData A data object containing the HTTP body to be uploaded. + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(nullable NSData *)bodyData + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified streaming request. + + @param request The HTTP request for the request. + @param uploadProgressBlock A block object to be executed when the upload progress is updated. Note this block is called on the session queue, not the main queue. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(nullable void (^)(NSProgress *uploadProgress))uploadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler; + +///----------------------------- +/// @name Running Download Tasks +///----------------------------- + +/** + Creates an `NSURLSessionDownloadTask` with the specified request. + + @param request The HTTP request for the request. + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + + @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler; + +/** + Creates an `NSURLSessionDownloadTask` with the specified resume data. + + @param resumeData The data used to resume downloading. + @param downloadProgressBlock A block object to be executed when the download progress is updated. Note this block is called on the session queue, not the main queue. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(nullable void (^)(NSProgress *downloadProgress))downloadProgressBlock + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * _Nullable filePath, NSError * _Nullable error))completionHandler; + +///--------------------------------- +/// @name Getting Progress for Tasks +///--------------------------------- + +/** + Returns the upload progress of the specified task. + + @param task The session task. Must not be `nil`. + + @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task; + +/** + Returns the download progress of the specified task. + + @param task The session task. Must not be `nil`. + + @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task; + +///----------------------------------------- +/// @name Setting Session Delegate Callbacks +///----------------------------------------- + +/** + Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`. + + @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation. + */ +- (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block; + +/** + Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block; + +///-------------------------------------- +/// @name Setting Task Delegate Callbacks +///-------------------------------------- + +/** + Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`. + + @param block A block object to be executed when a task requires a new request body stream. + */ +- (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block; + +/** + Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`. + + @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response. + */ +- (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block; + +/** + Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block; + +/** + Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block; + +/** + Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`. + + @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task. + */ +- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * _Nullable error))block; + +///------------------------------------------- +/// @name Setting Data Task Delegate Callbacks +///------------------------------------------- + +/** + Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`. + + @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response. + */ +- (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block; + +/** + Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`. + + @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become. + */ +- (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block; + +/** + Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block; + +/** + Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`. + + @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response. + */ +- (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block; + +/** + Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`. + + @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session. + */ +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block; + +///----------------------------------------------- +/// @name Setting Download Task Delegate Callbacks +///----------------------------------------------- + +/** + Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`. + + @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error. + */ +- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * _Nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block; + +/** + Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block; + +/** + Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. + + @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded. + */ +- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; + +@end + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when a task resumes. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification; + +/** + Posted when a task suspends its execution. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification; + +/** + Posted when a session is invalidated. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification; + +/** + Posted when a session download task encountered an error when moving the temporary download file to a specified destination. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if response data exists for the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the response was serialized. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if the task has an associated response serializer. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an the response data has been stored directly to disk. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidCompleteNotification` if an error exists. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/KtTableView/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m new file mode 100644 index 0000000..ef2108c --- /dev/null +++ b/KtTableView/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m @@ -0,0 +1,1244 @@ +// AFURLSessionManager.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLSessionManager.h" +#import + +#ifndef NSFoundationVersionNumber_iOS_8_0 +#define NSFoundationVersionNumber_With_Fixed_5871104061079552_bug 1140.11 +#else +#define NSFoundationVersionNumber_With_Fixed_5871104061079552_bug NSFoundationVersionNumber_iOS_8_0 +#endif + +static dispatch_queue_t url_session_manager_creation_queue() { + static dispatch_queue_t af_url_session_manager_creation_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_creation_queue = dispatch_queue_create("com.alamofire.networking.session.manager.creation", DISPATCH_QUEUE_SERIAL); + }); + + return af_url_session_manager_creation_queue; +} + +static void url_session_manager_create_task_safely(dispatch_block_t block) { + if (NSFoundationVersionNumber < NSFoundationVersionNumber_With_Fixed_5871104061079552_bug) { + // Fix of bug + // Open Radar:http://openradar.appspot.com/radar?id=5871104061079552 (status: Fixed in iOS8) + // Issue about:https://github.com/AFNetworking/AFNetworking/issues/2093 + dispatch_sync(url_session_manager_creation_queue(), block); + } else { + block(); + } +} + +static dispatch_queue_t url_session_manager_processing_queue() { + static dispatch_queue_t af_url_session_manager_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_url_session_manager_processing_queue; +} + +static dispatch_group_t url_session_manager_completion_group() { + static dispatch_group_t af_url_session_manager_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_completion_group = dispatch_group_create(); + }); + + return af_url_session_manager_completion_group; +} + +NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume"; +NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete"; +NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend"; +NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate"; +NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error"; + +NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; +NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; +NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; +NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error"; +NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; + +static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock"; + +static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3; + +static void * AFTaskStateChangedContext = &AFTaskStateChangedContext; + +typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); + +typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); +typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session); + +typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task); +typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend); +typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error); + +typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response); +typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask); +typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data); +typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse); + +typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location); +typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); +typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes); +typedef void (^AFURLSessionTaskProgressBlock)(NSProgress *); + +typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error); + + +#pragma mark - + +@interface AFURLSessionManagerTaskDelegate : NSObject +@property (nonatomic, weak) AFURLSessionManager *manager; +@property (nonatomic, strong) NSMutableData *mutableData; +@property (nonatomic, strong) NSProgress *uploadProgress; +@property (nonatomic, strong) NSProgress *downloadProgress; +@property (nonatomic, copy) NSURL *downloadFileURL; +@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (nonatomic, copy) AFURLSessionTaskProgressBlock uploadProgressBlock; +@property (nonatomic, copy) AFURLSessionTaskProgressBlock downloadProgressBlock; +@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler; +@end + +@implementation AFURLSessionManagerTaskDelegate + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.mutableData = [NSMutableData data]; + self.uploadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil]; + self.uploadProgress.totalUnitCount = NSURLSessionTransferSizeUnknown; + + self.downloadProgress = [[NSProgress alloc] initWithParent:nil userInfo:nil]; + self.downloadProgress.totalUnitCount = NSURLSessionTransferSizeUnknown; + return self; +} + +#pragma mark - NSProgress Tracking + +- (void)setupProgressForTask:(NSURLSessionTask *)task { + __weak __typeof__(task) weakTask = task; + + self.uploadProgress.totalUnitCount = task.countOfBytesExpectedToSend; + self.downloadProgress.totalUnitCount = task.countOfBytesExpectedToReceive; + [self.uploadProgress setCancellable:YES]; + [self.uploadProgress setCancellationHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask cancel]; + }]; + [self.uploadProgress setPausable:YES]; + [self.uploadProgress setPausingHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask suspend]; + }]; + if ([self.uploadProgress respondsToSelector:@selector(setResumingHandler:)]) { + [self.uploadProgress setResumingHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask resume]; + }]; + } + + [self.downloadProgress setCancellable:YES]; + [self.downloadProgress setCancellationHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask cancel]; + }]; + [self.downloadProgress setPausable:YES]; + [self.downloadProgress setPausingHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask suspend]; + }]; + + if ([self.downloadProgress respondsToSelector:@selector(setResumingHandler:)]) { + [self.downloadProgress setResumingHandler:^{ + __typeof__(weakTask) strongTask = weakTask; + [strongTask resume]; + }]; + } + + [task addObserver:self + forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived)) + options:NSKeyValueObservingOptionNew + context:NULL]; + [task addObserver:self + forKeyPath:NSStringFromSelector(@selector(countOfBytesExpectedToReceive)) + options:NSKeyValueObservingOptionNew + context:NULL]; + + [task addObserver:self + forKeyPath:NSStringFromSelector(@selector(countOfBytesSent)) + options:NSKeyValueObservingOptionNew + context:NULL]; + [task addObserver:self + forKeyPath:NSStringFromSelector(@selector(countOfBytesExpectedToSend)) + options:NSKeyValueObservingOptionNew + context:NULL]; + + [self.downloadProgress addObserver:self + forKeyPath:NSStringFromSelector(@selector(fractionCompleted)) + options:NSKeyValueObservingOptionNew + context:NULL]; + [self.uploadProgress addObserver:self + forKeyPath:NSStringFromSelector(@selector(fractionCompleted)) + options:NSKeyValueObservingOptionNew + context:NULL]; +} + +- (void)cleanUpProgressForTask:(NSURLSessionTask *)task { + [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; + [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesExpectedToReceive))]; + [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; + [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesExpectedToSend))]; + [self.downloadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))]; + [self.uploadProgress removeObserver:self forKeyPath:NSStringFromSelector(@selector(fractionCompleted))]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + if ([object isKindOfClass:[NSURLSessionTask class]] || [object isKindOfClass:[NSURLSessionDownloadTask class]]) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { + self.downloadProgress.completedUnitCount = [change[NSKeyValueChangeNewKey] longLongValue]; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesExpectedToReceive))]) { + self.downloadProgress.totalUnitCount = [change[NSKeyValueChangeNewKey] longLongValue]; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { + self.uploadProgress.completedUnitCount = [change[NSKeyValueChangeNewKey] longLongValue]; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesExpectedToSend))]) { + self.uploadProgress.totalUnitCount = [change[NSKeyValueChangeNewKey] longLongValue]; + } + } + else if ([object isEqual:self.downloadProgress]) { + if (self.downloadProgressBlock) { + self.downloadProgressBlock(object); + } + } + else if ([object isEqual:self.uploadProgress]) { + if (self.uploadProgressBlock) { + self.uploadProgressBlock(object); + } + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + __strong AFURLSessionManager *manager = self.manager; + + __block id responseObject = nil; + + __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer; + + //Performance Improvement from #2672 + NSData *data = nil; + if (self.mutableData) { + data = [self.mutableData copy]; + //We no longer need the reference, so nil it out to gain back some memory. + self.mutableData = nil; + } + + if (self.downloadFileURL) { + userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; + } else if (data) { + userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data; + } + + if (error) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = error; + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, error); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + } else { + dispatch_async(url_session_manager_processing_queue(), ^{ + NSError *serializationError = nil; + responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:data error:&serializationError]; + + if (self.downloadFileURL) { + responseObject = self.downloadFileURL; + } + + if (responseObject) { + userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject; + } + + if (serializationError) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError; + } + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, serializationError); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + }); + } +#pragma clang diagnostic pop +} + +#pragma mark - NSURLSessionDataTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + dataTask:(__unused NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + [self.mutableData appendData:data]; +} + +#pragma mark - NSURLSessionDownloadTaskDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + NSError *fileManagerError = nil; + self.downloadFileURL = nil; + + if (self.downloadTaskDidFinishDownloading) { + self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (self.downloadFileURL) { + [[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]; + + if (fileManagerError) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo]; + } + } + } +} + +@end + +#pragma mark - + +/** + * A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`. + * + * See: + * - https://github.com/AFNetworking/AFNetworking/issues/1477 + * - https://github.com/AFNetworking/AFNetworking/issues/2638 + * - https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + +static inline void af_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) { + Method originalMethod = class_getInstanceMethod(theClass, originalSelector); + Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector); + method_exchangeImplementations(originalMethod, swizzledMethod); +} + +static inline BOOL af_addMethod(Class theClass, SEL selector, Method method) { + return class_addMethod(theClass, selector, method_getImplementation(method), method_getTypeEncoding(method)); +} + +static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume"; +static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend"; + +@interface _AFURLSessionTaskSwizzling : NSObject + +@end + +@implementation _AFURLSessionTaskSwizzling + ++ (void)load { + /** + WARNING: Trouble Ahead + https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + + if (NSClassFromString(@"NSURLSessionTask")) { + /** + iOS 7 and iOS 8 differ in NSURLSessionTask implementation, which makes the next bit of code a bit tricky. + Many Unit Tests have been built to validate as much of this behavior has possible. + Here is what we know: + - NSURLSessionTasks are implemented with class clusters, meaning the class you request from the API isn't actually the type of class you will get back. + - Simply referencing `[NSURLSessionTask class]` will not work. You need to ask an `NSURLSession` to actually create an object, and grab the class from there. + - On iOS 7, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `__NSCFURLSessionTask`. + - On iOS 8, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `NSURLSessionTask`. + - On iOS 7, `__NSCFLocalSessionTask` and `__NSCFURLSessionTask` are the only two classes that have their own implementations of `resume` and `suspend`, and `__NSCFLocalSessionTask` DOES NOT CALL SUPER. This means both classes need to be swizzled. + - On iOS 8, `NSURLSessionTask` is the only class that implements `resume` and `suspend`. This means this is the only class that needs to be swizzled. + - Because `NSURLSessionTask` is not involved in the class hierarchy for every version of iOS, its easier to add the swizzled methods to a dummy class and manage them there. + + Some Assumptions: + - No implementations of `resume` or `suspend` call super. If this were to change in a future version of iOS, we'd need to handle it. + - No background task classes override `resume` or `suspend` + + The current solution: + 1) Grab an instance of `__NSCFLocalDataTask` by asking an instance of `NSURLSession` for a data task. + 2) Grab a pointer to the original implementation of `af_resume` + 3) Check to see if the current class has an implementation of resume. If so, continue to step 4. + 4) Grab the super class of the current class. + 5) Grab a pointer for the current class to the current implementation of `resume`. + 6) Grab a pointer for the super class to the current implementation of `resume`. + 7) If the current class implementation of `resume` is not equal to the super class implementation of `resume` AND the current implementation of `resume` is not equal to the original implementation of `af_resume`, THEN swizzle the methods + 8) Set the current class to the super class, and repeat steps 3-8 + */ + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration]; + NSURLSession * session = [NSURLSession sessionWithConfiguration:configuration]; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnonnull" + NSURLSessionDataTask *localDataTask = [session dataTaskWithURL:nil]; +#pragma clang diagnostic pop + IMP originalAFResumeIMP = method_getImplementation(class_getInstanceMethod([self class], @selector(af_resume))); + Class currentClass = [localDataTask class]; + + while (class_getInstanceMethod(currentClass, @selector(resume))) { + Class superClass = [currentClass superclass]; + IMP classResumeIMP = method_getImplementation(class_getInstanceMethod(currentClass, @selector(resume))); + IMP superclassResumeIMP = method_getImplementation(class_getInstanceMethod(superClass, @selector(resume))); + if (classResumeIMP != superclassResumeIMP && + originalAFResumeIMP != classResumeIMP) { + [self swizzleResumeAndSuspendMethodForClass:currentClass]; + } + currentClass = [currentClass superclass]; + } + + [localDataTask cancel]; + [session finishTasksAndInvalidate]; + } +} + ++ (void)swizzleResumeAndSuspendMethodForClass:(Class)theClass { + Method afResumeMethod = class_getInstanceMethod(self, @selector(af_resume)); + Method afSuspendMethod = class_getInstanceMethod(self, @selector(af_suspend)); + + if (af_addMethod(theClass, @selector(af_resume), afResumeMethod)) { + af_swizzleSelector(theClass, @selector(resume), @selector(af_resume)); + } + + if (af_addMethod(theClass, @selector(af_suspend), afSuspendMethod)) { + af_swizzleSelector(theClass, @selector(suspend), @selector(af_suspend)); + } +} + +- (NSURLSessionTaskState)state { + NSAssert(NO, @"State method should never be called in the actual dummy class"); + return NSURLSessionTaskStateCanceling; +} + +- (void)af_resume { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_resume]; + + if (state != NSURLSessionTaskStateRunning) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self]; + } +} + +- (void)af_suspend { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_suspend]; + + if (state != NSURLSessionTaskStateSuspended) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self]; + } +} +@end + +#pragma mark - + +@interface AFURLSessionManager () +@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; +@property (readwrite, nonatomic, strong) NSURLSession *session; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier; +@property (readonly, nonatomic, copy) NSString *taskDescriptionForSessionTasks; +@property (readwrite, nonatomic, strong) NSLock *lock; +@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid; +@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession; +@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume; +@end + +@implementation AFURLSessionManager + +- (instancetype)init { + return [self initWithSessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + self = [super init]; + if (!self) { + return nil; + } + + if (!configuration) { + configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + } + + self.sessionConfiguration = configuration; + + self.operationQueue = [[NSOperationQueue alloc] init]; + self.operationQueue.maxConcurrentOperationCount = 1; + + self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue]; + + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + +#if !TARGET_OS_WATCH + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; +#endif + + self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init]; + + self.lock = [[NSLock alloc] init]; + self.lock.name = AFURLSessionManagerLockName; + + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + for (NSURLSessionDataTask *task in dataTasks) { + [self addDelegateForDataTask:task uploadProgress:nil downloadProgress:nil completionHandler:nil]; + } + + for (NSURLSessionUploadTask *uploadTask in uploadTasks) { + [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil]; + } + + for (NSURLSessionDownloadTask *downloadTask in downloadTasks) { + [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil]; + } + }]; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +#pragma mark - + +- (NSString *)taskDescriptionForSessionTasks { + return [NSString stringWithFormat:@"%p", self]; +} + +- (void)taskDidResume:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task]; + }); + } + } +} + +- (void)taskDidSuspend:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task]; + }); + } + } +} + +#pragma mark - + +- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = nil; + [self.lock lock]; + delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)]; + [self.lock unlock]; + + return delegate; +} + +- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate + forTask:(NSURLSessionTask *)task +{ + NSParameterAssert(task); + NSParameterAssert(delegate); + + [self.lock lock]; + self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate; + [delegate setupProgressForTask:task]; + [self addNotificationObserverForTask:task]; + [self.lock unlock]; +} + +- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + dataTask.taskDescription = self.taskDescriptionForSessionTasks; + [self setDelegate:delegate forTask:dataTask]; + + delegate.uploadProgressBlock = uploadProgressBlock; + delegate.downloadProgressBlock = downloadProgressBlock; +} + +- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + uploadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:uploadTask]; + + delegate.uploadProgressBlock = uploadProgressBlock; +} + +- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + if (destination) { + delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) { + return destination(location, task.response); + }; + } + + downloadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:downloadTask]; + + delegate.downloadProgressBlock = downloadProgressBlock; +} + +- (void)removeDelegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + [self.lock lock]; + [delegate cleanUpProgressForTask:task]; + [self removeNotificationObserverForTask:task]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)]; + [self.lock unlock]; +} + +#pragma mark - + +- (NSArray *)tasksForKeyPath:(NSString *)keyPath { + __block NSArray *tasks = nil; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) { + tasks = dataTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) { + tasks = uploadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) { + tasks = downloadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) { + tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; + } + + dispatch_semaphore_signal(semaphore); + }]; + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + + return tasks; +} + +- (NSArray *)tasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)dataTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)uploadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)downloadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +#pragma mark - + +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks { + dispatch_async(dispatch_get_main_queue(), ^{ + if (cancelPendingTasks) { + [self.session invalidateAndCancel]; + } else { + [self.session finishTasksAndInvalidate]; + } + }); +} + +#pragma mark - + +- (void)setResponseSerializer:(id )responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - +- (void)addNotificationObserverForTask:(NSURLSessionTask *)task { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:task]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:task]; +} + +- (void)removeNotificationObserverForTask:(NSURLSessionTask *)task { + [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidSuspendNotification object:task]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:AFNSURLSessionTaskDidResumeNotification object:task]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + return [self dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:completionHandler]; +} + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + uploadProgress:(nullable void (^)(NSProgress *uploadProgress)) uploadProgressBlock + downloadProgress:(nullable void (^)(NSProgress *downloadProgress)) downloadProgressBlock + completionHandler:(nullable void (^)(NSURLResponse *response, id _Nullable responseObject, NSError * _Nullable error))completionHandler { + + __block NSURLSessionDataTask *dataTask = nil; + url_session_manager_create_task_safely(^{ + dataTask = [self.session dataTaskWithRequest:request]; + }); + + [self addDelegateForDataTask:dataTask uploadProgress:uploadProgressBlock downloadProgress:downloadProgressBlock completionHandler:completionHandler]; + + return dataTask; +} + +#pragma mark - + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + url_session_manager_create_task_safely(^{ + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + }); + + if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) { + for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) { + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + } + } + + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + url_session_manager_create_task_safely(^{ + uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData]; + }); + + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(void (^)(NSProgress *uploadProgress)) uploadProgressBlock + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + url_session_manager_create_task_safely(^{ + uploadTask = [self.session uploadTaskWithStreamedRequest:request]; + }); + + [self addDelegateForUploadTask:uploadTask progress:uploadProgressBlock completionHandler:completionHandler]; + + return uploadTask; +} + +#pragma mark - + +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + url_session_manager_create_task_safely(^{ + downloadTask = [self.session downloadTaskWithRequest:request]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(void (^)(NSProgress *downloadProgress)) downloadProgressBlock + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + url_session_manager_create_task_safely(^{ + downloadTask = [self.session downloadTaskWithResumeData:resumeData]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:downloadProgressBlock destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +#pragma mark - +- (NSProgress *)uploadProgressForTask:(NSURLSessionTask *)task { + return [[self delegateForTask:task] uploadProgress]; +} + +- (NSProgress *)downloadProgressForTask:(NSURLSessionTask *)task { + return [[self delegateForTask:task] downloadProgress]; +} + +#pragma mark - + +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block { + self.sessionDidBecomeInvalid = block; +} + +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.sessionDidReceiveAuthenticationChallenge = block; +} + +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block { + self.didFinishEventsForBackgroundURLSession = block; +} + +#pragma mark - + +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block { + self.taskNeedNewBodyStream = block; +} + +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block { + self.taskWillPerformHTTPRedirection = block; +} + +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.taskDidReceiveAuthenticationChallenge = block; +} + +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block { + self.taskDidSendBodyData = block; +} + +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block { + self.taskDidComplete = block; +} + +#pragma mark - + +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block { + self.dataTaskDidReceiveResponse = block; +} + +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block { + self.dataTaskDidBecomeDownloadTask = block; +} + +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block { + self.dataTaskDidReceiveData = block; +} + +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block { + self.dataTaskWillCacheResponse = block; +} + +#pragma mark - + +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block { + self.downloadTaskDidFinishDownloading = block; +} + +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block { + self.downloadTaskDidWriteData = block; +} + +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block { + self.downloadTaskDidResume = block; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue]; +} + +- (BOOL)respondsToSelector:(SEL)selector { + if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) { + return self.taskWillPerformHTTPRedirection != nil; + } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) { + return self.dataTaskDidReceiveResponse != nil; + } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) { + return self.dataTaskWillCacheResponse != nil; + } else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) { + return self.didFinishEventsForBackgroundURLSession != nil; + } + + return [[self class] instancesRespondToSelector:selector]; +} + +#pragma mark - NSURLSessionDelegate + +- (void)URLSession:(NSURLSession *)session +didBecomeInvalidWithError:(NSError *)error +{ + if (self.sessionDidBecomeInvalid) { + self.sessionDidBecomeInvalid(session, error); + } + + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session]; +} + +- (void)URLSession:(NSURLSession *)session +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.sessionDidReceiveAuthenticationChallenge) { + disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + if (credential) { + disposition = NSURLSessionAuthChallengeUseCredential; + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +willPerformHTTPRedirection:(NSHTTPURLResponse *)response + newRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLRequest *))completionHandler +{ + NSURLRequest *redirectRequest = request; + + if (self.taskWillPerformHTTPRedirection) { + redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request); + } + + if (completionHandler) { + completionHandler(redirectRequest); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.taskDidReceiveAuthenticationChallenge) { + disposition = self.taskDidReceiveAuthenticationChallenge(session, task, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + disposition = NSURLSessionAuthChallengeUseCredential; + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler +{ + NSInputStream *inputStream = nil; + + if (self.taskNeedNewBodyStream) { + inputStream = self.taskNeedNewBodyStream(session, task); + } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + inputStream = [task.originalRequest.HTTPBodyStream copy]; + } + + if (completionHandler) { + completionHandler(inputStream); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + didSendBodyData:(int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + + int64_t totalUnitCount = totalBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t) [contentLength longLongValue]; + } + } + + if (self.taskDidSendBodyData) { + self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + + // delegate may be nil when completing a task in the background + if (delegate) { + [delegate URLSession:session task:task didCompleteWithError:error]; + + [self removeDelegateForTask:task]; + } + + if (self.taskDidComplete) { + self.taskDidComplete(session, task, error); + } +} + +#pragma mark - NSURLSessionDataDelegate + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didReceiveResponse:(NSURLResponse *)response + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler +{ + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; + + if (self.dataTaskDidReceiveResponse) { + disposition = self.dataTaskDidReceiveResponse(session, dataTask, response); + } + + if (completionHandler) { + completionHandler(disposition); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + if (delegate) { + [self removeDelegateForTask:dataTask]; + [self setDelegate:delegate forTask:downloadTask]; + } + + if (self.dataTaskDidBecomeDownloadTask) { + self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + [delegate URLSession:session dataTask:dataTask didReceiveData:data]; + + if (self.dataTaskDidReceiveData) { + self.dataTaskDidReceiveData(session, dataTask, data); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + willCacheResponse:(NSCachedURLResponse *)proposedResponse + completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler +{ + NSCachedURLResponse *cachedResponse = proposedResponse; + + if (self.dataTaskWillCacheResponse) { + cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse); + } + + if (completionHandler) { + completionHandler(cachedResponse); + } +} + +- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { + if (self.didFinishEventsForBackgroundURLSession) { + dispatch_async(dispatch_get_main_queue(), ^{ + self.didFinishEventsForBackgroundURLSession(session); + }); + } +} + +#pragma mark - NSURLSessionDownloadDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + if (self.downloadTaskDidFinishDownloading) { + NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (fileURL) { + delegate.downloadFileURL = fileURL; + NSError *error = nil; + [[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]; + if (error) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo]; + } + + return; + } + } + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location]; + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didWriteData:(int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + if (self.downloadTaskDidWriteData) { + self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes +{ + if (self.downloadTaskDidResume) { + self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes); + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + + self = [self initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; +} + +@end diff --git a/KtTableView/Pods/AFNetworking/LICENSE b/KtTableView/Pods/AFNetworking/LICENSE new file mode 100644 index 0000000..3fbc2c9 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/KtTableView/Pods/AFNetworking/README.md b/KtTableView/Pods/AFNetworking/README.md new file mode 100644 index 0000000..53cb202 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/README.md @@ -0,0 +1,320 @@ +

+ AFNetworking +

+ +[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking) +[![codecov.io](https://codecov.io/github/AFNetworking/AFNetworking/coverage.svg?branch=master)](https://codecov.io/github/AFNetworking/AFNetworking?branch=master) +[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AFNetworking.svg)](https://img.shields.io/cocoapods/v/AFNetworking.svg) +[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) +[![Platform](https://img.shields.io/cocoapods/p/AFNetworking.svg?style=flat)](http://cocoadocs.org/docsets/AFNetworking) +[![Twitter](https://img.shields.io/badge/twitter-@AFNetworking-blue.svg?style=flat)](http://twitter.com/AFNetworking) + +AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. + +Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. + +Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did! + +## How To Get Started + +- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps +- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki) +- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking +- Read the [AFNetworking 3.0 Migration Guide](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-3.0-Migration-Guide) for an overview of the architectural changes from 2.0. + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). +- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + +## Installation +AFNetworking supports multiple methods for installing the library in a project. + +## Installation with CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects. See the ["Getting Started" guide for more information](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking). You can install it with the following command: + +```bash +$ gem install cocoapods +``` + +> CocoaPods 0.39.0+ is required to build AFNetworking 3.0.0+. + +#### Podfile + +To integrate AFNetworking into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '8.0' + +pod 'AFNetworking', '~> 3.0' +``` + +Then, run the following command: + +```bash +$ pod install +``` + +### Installation with Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. + +You can install Carthage with [Homebrew](http://brew.sh/) using the following command: + +```bash +$ brew update +$ brew install carthage +``` + +To integrate AFNetworking into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "AFNetworking/AFNetworking" ~> 3.0 +``` + +Run `carthage` to build the framework and drag the built `AFNetworking.framework` into your Xcode project. + +## Requirements + +| AFNetworking Version | Minimum iOS Target | Minimum OS X Target | Minimum watchOS Target | Minimum tvOS Target | Notes | +|:--------------------:|:---------------------------:|:----------------------------:|:----------------------------:|:----------------------------:|:-------------------------------------------------------------------------:| +| 3.x | iOS 7 | OS X 10.9 | watchOS 2.0 | tvOS 9.0 | Xcode 7+ is required. `NSURLConnectionOperation` support has been removed. | +| 2.6 -> 2.6.3 | iOS 7 | OS X 10.9 | watchOS 2.0 | n/a | Xcode 7+ is required. | +| 2.0 -> 2.5.4 | iOS 6 | OS X 10.8 | n/a | n/a | Xcode 5+ is required. `NSURLSession` subspec requires iOS 7 or OS X 10.9. | +| 1.x | iOS 5 | Mac OS X 10.7 | n/a | n/a | +| 0.10.x | iOS 4 | Mac OS X 10.6 | n/a | n/a | + +(OS X projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)). + +> Programming in Swift? Try [Alamofire](https://github.com/Alamofire/Alamofire) for a more conventional set of APIs. + +## Architecture + +### NSURLSession + +- `AFURLSessionManager` +- `AFHTTPSessionManager` + +### Serialization + +* `` + - `AFHTTPRequestSerializer` + - `AFJSONRequestSerializer` + - `AFPropertyListRequestSerializer` +* `` + - `AFHTTPResponseSerializer` + - `AFJSONResponseSerializer` + - `AFXMLParserResponseSerializer` + - `AFXMLDocumentResponseSerializer` _(Mac OS X)_ + - `AFPropertyListResponseSerializer` + - `AFImageResponseSerializer` + - `AFCompoundResponseSerializer` + +### Additional Functionality + +- `AFSecurityPolicy` +- `AFNetworkReachabilityManager` + +## Usage + +### AFURLSessionManager + +`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + +#### Creating a Download Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { + NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; + return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; +} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) { + NSLog(@"File downloaded to: %@", filePath); +}]; +[downloadTask resume]; +``` + +#### Creating an Upload Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"Success: %@ %@", response, responseObject); + } +}]; +[uploadTask resume]; +``` + +#### Creating an Upload Task for a Multi-Part Request, with Progress + +```objective-c +NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil]; + } error:nil]; + +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; + +NSURLSessionUploadTask *uploadTask; +uploadTask = [manager + uploadTaskWithStreamedRequest:request + progress:^(NSProgress * _Nonnull uploadProgress) { + // This is not called back on the main queue. + // You are responsible for dispatching to the main queue for UI updates + dispatch_async(dispatch_get_main_queue(), ^{ + //Update the progress view + [progressView setProgress:uploadProgress.fractionCompleted]; + }); + } + completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } + }]; + +[uploadTask resume]; +``` + +#### Creating a Data Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; +[dataTask resume]; +``` + +--- + +### Request Serialization + +Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body. + +```objective-c +NSString *URLString = @"http://example.com"; +NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]}; +``` + +#### Query String Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil]; +``` + + GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### URL Form Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil]; +``` + + POST http://example.com/ + Content-Type: application/x-www-form-urlencoded + + foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### JSON Parameter Encoding + +```objective-c +[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters error:nil]; +``` + + POST http://example.com/ + Content-Type: application/json + + {"foo": "bar", "baz": [1,2,3]} + +--- + +### Network Reachability Manager + +`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + +* Do not use Reachability to determine if the original request should be sent. + * You should try to send it. +* You can use Reachability to determine when a request should be automatically retried. + * Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something. +* Network reachability is a useful tool for determining why a request might have failed. + * After a network request has failed, telling the user they're offline is better than giving them a more technical but accurate error, such as "request timed out." + +See also [WWDC 2012 session 706, "Networking Best Practices."](https://developer.apple.com/videos/play/wwdc2012-706/). + +#### Shared Network Reachability + +```objective-c +[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status)); +}]; + +[[AFNetworkReachabilityManager sharedManager] startMonitoring]; +``` + +--- + +### Security Policy + +`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + +Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + +#### Allowing Invalid SSL Certificates + +```objective-c +AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; +manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production +``` + +--- + +## Unit Tests + +AFNetworking includes a suite of unit tests within the Tests subdirectory. These tests can be run simply be executed the test action on the platform framework you would like to test. + +## Credits + +AFNetworking is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org). + +AFNetworking was originally created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla). + +AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/). + +And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors). + +### Security Disclosure + +If you believe you have identified a security vulnerability with AFNetworking, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker. + +## License + +AFNetworking is released under the MIT license. See LICENSE for details. diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h new file mode 100644 index 0000000..9bdc15c --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h @@ -0,0 +1,149 @@ +// AFAutoPurgingImageCache.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#if TARGET_OS_IOS || TARGET_OS_TV +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFImageCache` protocol defines a set of APIs for adding, removing and fetching images from a cache synchronously. + */ +@protocol AFImageCache + +/** + Adds the image to the cache with the given identifier. + + @param image The image to cache. + @param identifier The unique identifier for the image in the cache. + */ +- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier; + +/** + Removes the image from the cache matching the given identifier. + + @param identifier The unique identifier for the image in the cache. + + @return A BOOL indicating whether or not the image was removed from the cache. + */ +- (BOOL)removeImageWithIdentifier:(NSString *)identifier; + +/** + Removes all images from the cache. + + @return A BOOL indicating whether or not all images were removed from the cache. + */ +- (BOOL)removeAllImages; + +/** + Returns the image in the cache associated with the given identifier. + + @param identifier The unique identifier for the image in the cache. + + @return An image for the matching identifier, or nil. + */ +- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier; +@end + + +/** + The `ImageRequestCache` protocol extends the `ImageCache` protocol by adding methods for adding, removing and fetching images from a cache given an `NSURLRequest` and additional identifier. + */ +@protocol AFImageRequestCache + +/** + Adds the image to the cache using an identifier created from the request and additional identifier. + + @param image The image to cache. + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + */ +- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +/** + Removes the image from the cache using an identifier created from the request and additional identifier. + + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + + @return A BOOL indicating whether or not all images were removed from the cache. + */ +- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +/** + Returns the image from the cache associated with an identifier created from the request and additional identifier. + + @param request The unique URL request identifing the image asset. + @param identifier The additional identifier to apply to the URL request to identify the image. + + @return An image for the matching request and identifier, or nil. + */ +- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(nullable NSString *)identifier; + +@end + +/** + The `AutoPurgingImageCache` in an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated. + */ +@interface AFAutoPurgingImageCache : NSObject + +/** + The total memory capacity of the cache in bytes. + */ +@property (nonatomic, assign) UInt64 memoryCapacity; + +/** + The preferred memory usage after purge in bytes. During a purge, images will be purged until the memory capacity drops below this limit. + */ +@property (nonatomic, assign) UInt64 preferredMemoryUsageAfterPurge; + +/** + The current total memory usage in bytes of all images stored within the cache. + */ +@property (nonatomic, assign, readonly) UInt64 memoryUsage; + +/** + Initialies the `AutoPurgingImageCache` instance with default values for memory capacity and preferred memory usage after purge limit. `memoryCapcity` defaults to `100 MB`. `preferredMemoryUsageAfterPurge` defaults to `60 MB`. + + @return The new `AutoPurgingImageCache` instance. + */ +- (instancetype)init; + +/** + Initialies the `AutoPurgingImageCache` instance with the given memory capacity and preferred memory usage + after purge limit. + + @param memoryCapacity The total memory capacity of the cache in bytes. + @param preferredMemoryCapacity The preferred memory usage after purge in bytes. + + @return The new `AutoPurgingImageCache` instance. + */ +- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity; + +@end + +NS_ASSUME_NONNULL_END + +#endif + diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m new file mode 100644 index 0000000..1f40715 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.m @@ -0,0 +1,201 @@ +// AFAutoPurgingImageCache.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFAutoPurgingImageCache.h" + +@interface AFCachedImage : NSObject + +@property (nonatomic, strong) UIImage *image; +@property (nonatomic, strong) NSString *identifier; +@property (nonatomic, assign) UInt64 totalBytes; +@property (nonatomic, strong) NSDate *lastAccessDate; +@property (nonatomic, assign) UInt64 currentMemoryUsage; + +@end + +@implementation AFCachedImage + +-(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier { + if (self = [self init]) { + self.image = image; + self.identifier = identifier; + + CGSize imageSize = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale); + CGFloat bytesPerPixel = 4.0; + CGFloat bytesPerSize = imageSize.width * imageSize.height; + self.totalBytes = (UInt64)bytesPerPixel * (UInt64)bytesPerSize; + self.lastAccessDate = [NSDate date]; + } + return self; +} + +- (UIImage*)accessImage { + self.lastAccessDate = [NSDate date]; + return self.image; +} + +- (NSString *)description { + NSString *descriptionString = [NSString stringWithFormat:@"Idenfitier: %@ lastAccessDate: %@ ", self.identifier, self.lastAccessDate]; + return descriptionString; + +} + +@end + +@interface AFAutoPurgingImageCache () +@property (nonatomic, strong) NSMutableDictionary *cachedImages; +@property (nonatomic, assign) UInt64 currentMemoryUsage; +@property (nonatomic, strong) dispatch_queue_t synchronizationQueue; +@end + +@implementation AFAutoPurgingImageCache + +- (instancetype)init { + return [self initWithMemoryCapacity:100 * 1024 * 1024 preferredMemoryCapacity:60 * 1024 * 1024]; +} + +- (instancetype)initWithMemoryCapacity:(UInt64)memoryCapacity preferredMemoryCapacity:(UInt64)preferredMemoryCapacity { + if (self = [super init]) { + self.memoryCapacity = memoryCapacity; + self.preferredMemoryUsageAfterPurge = preferredMemoryCapacity; + self.cachedImages = [[NSMutableDictionary alloc] init]; + + NSString *queueName = [NSString stringWithFormat:@"com.alamofire.autopurgingimagecache-%@", [[NSUUID UUID] UUIDString]]; + self.synchronizationQueue = dispatch_queue_create([queueName cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT); + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(removeAllImages) + name:UIApplicationDidReceiveMemoryWarningNotification + object:nil]; + + } + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (UInt64)memoryUsage { + __block UInt64 result = 0; + dispatch_sync(self.synchronizationQueue, ^{ + result = self.currentMemoryUsage; + }); + return result; +} + +- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier { + dispatch_barrier_async(self.synchronizationQueue, ^{ + AFCachedImage *cacheImage = [[AFCachedImage alloc] initWithImage:image identifier:identifier]; + + AFCachedImage *previousCachedImage = self.cachedImages[identifier]; + if (previousCachedImage != nil) { + self.currentMemoryUsage -= previousCachedImage.totalBytes; + } + + self.cachedImages[identifier] = cacheImage; + self.currentMemoryUsage += cacheImage.totalBytes; + }); + + dispatch_barrier_async(self.synchronizationQueue, ^{ + if (self.currentMemoryUsage > self.memoryCapacity) { + UInt64 bytesToPurge = self.currentMemoryUsage - self.preferredMemoryUsageAfterPurge; + NSMutableArray *sortedImages = [NSMutableArray arrayWithArray:self.cachedImages.allValues]; + NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"lastAccessDate" + ascending:YES]; + [sortedImages sortUsingDescriptors:@[sortDescriptor]]; + + UInt64 bytesPurged = 0; + + for (AFCachedImage *cachedImage in sortedImages) { + [self.cachedImages removeObjectForKey:cachedImage.identifier]; + bytesPurged += cachedImage.totalBytes; + if (bytesPurged >= bytesToPurge) { + break ; + } + } + self.currentMemoryUsage -= bytesPurged; + } + }); +} + +- (BOOL)removeImageWithIdentifier:(NSString *)identifier { + __block BOOL removed = NO; + dispatch_barrier_sync(self.synchronizationQueue, ^{ + AFCachedImage *cachedImage = self.cachedImages[identifier]; + if (cachedImage != nil) { + [self.cachedImages removeObjectForKey:identifier]; + self.currentMemoryUsage -= cachedImage.totalBytes; + removed = YES; + } + }); + return removed; +} + +- (BOOL)removeAllImages { + __block BOOL removed = NO; + dispatch_barrier_sync(self.synchronizationQueue, ^{ + if (self.cachedImages.count > 0) { + [self.cachedImages removeAllObjects]; + self.currentMemoryUsage = 0; + removed = YES; + } + }); + return removed; +} + +- (nullable UIImage *)imageWithIdentifier:(NSString *)identifier { + __block UIImage *image = nil; + dispatch_sync(self.synchronizationQueue, ^{ + AFCachedImage *cachedImage = self.cachedImages[identifier]; + image = [cachedImage accessImage]; + }); + return image; +} + +- (void)addImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + [self addImage:image withIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (BOOL)removeImageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + return [self removeImageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (nullable UIImage *)imageforRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { + return [self imageWithIdentifier:[self imageCacheKeyFromURLRequest:request withAdditionalIdentifier:identifier]]; +} + +- (NSString *)imageCacheKeyFromURLRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)additionalIdentifier { + NSString *key = request.URL.absoluteString; + if (additionalIdentifier != nil) { + key = [key stringByAppendingString:additionalIdentifier]; + } + return key; +} + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h new file mode 100644 index 0000000..3903eec --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.h @@ -0,0 +1,157 @@ +// AFImageDownloader.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import +#import "AFAutoPurgingImageCache.h" +#import "AFHTTPSessionManager.h" + +NS_ASSUME_NONNULL_BEGIN + +typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) { + AFImageDownloadPrioritizationFIFO, + AFImageDownloadPrioritizationLIFO +}; + +/** + The `AFImageDownloadReceipt` is an object vended by the `AFImageDownloader` when starting a data task. It can be used to cancel active tasks running on the `AFImageDownloader` session. As a general rule, image data tasks should be cancelled using the `AFImageDownloadReceipt` instead of calling `cancel` directly on the `task` itself. The `AFImageDownloader` is optimized to handle duplicate task scenarios as well as pending versus active downloads. + */ +@interface AFImageDownloadReceipt : NSObject + +/** + The data task created by the `AFImageDownloader`. +*/ +@property (nonatomic, strong) NSURLSessionDataTask *task; + +/** + The unique identifier for the success and failure blocks when duplicate requests are made. + */ +@property (nonatomic, strong) NSUUID *receiptID; +@end + +/** The `AFImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. Incoming downloads are added to the front or back of the queue depending on the download prioritization. Each downloaded image is cached in the underlying `NSURLCache` as well as the in-memory image cache. By default, any download request with a cached image equivalent in the image cache will automatically be served the cached image representation. + */ +@interface AFImageDownloader : NSObject + +/** + The image cache used to store all downloaded images in. `AFAutoPurgingImageCache` by default. + */ +@property (nonatomic, strong, nullable) id imageCache; + +/** + The `AFHTTPSessionManager` used to download images. By default, this is configured with an `AFImageResponseSerializer`, and a shared `NSURLCache` for all image downloads. + */ +@property (nonatomic, strong) AFHTTPSessionManager *sessionManager; + +/** + Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default. + */ +@property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton; + +/** + The shared default instance of `AFImageDownloader` initialized with default values. + */ ++ (instancetype)defaultInstance; + +/** + Creates a default `NSURLCache` with common usage parameter values. + + @returns The default `NSURLCache` instance. + */ ++ (NSURLCache *)defaultURLCache; + +/** + Default initializer + + @return An instance of `AFImageDownloader` initialized with default values. + */ +- (instancetype)init; + +/** + Initializes the `AFImageDownloader` instance with the given session manager, download prioritization, maximum active download count and image cache. + + @param sessionManager The session manager to use to download images. + @param downloadPrioritization The download prioritization of the download queue. + @param maximumActiveDownloads The maximum number of active downloads allowed at any given time. Recommend `4`. + @param imageCache The image cache used to store all downloaded images in. + + @return The new `AFImageDownloader` instance. + */ +- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager + downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization + maximumActiveDownloads:(NSInteger)maximumActiveDownloads + imageCache:(nullable id )imageCache; + +/** + Creates a data task using the `sessionManager` instance for the specified URL request. + + If the same data task is already in the queue or currently being downloaded, the success and failure blocks are + appended to the already existing task. Once the task completes, all success or failure blocks attached to the + task are executed in the order they were added. + + @param request The URL request. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + + @return The image download receipt for the data task if available. `nil` if the image is stored in the cache. + cache and the URL request cache policy allows the cache to be used. + */ +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Creates a data task using the `sessionManager` instance for the specified URL request. + + If the same data task is already in the queue or currently being downloaded, the success and failure blocks are + appended to the already existing task. Once the task completes, all success or failure blocks attached to the + task are executed in the order they were added. + + @param request The URL request. + @param receiptID The identifier to use for the download receipt that will be created for this request. This must be a unique identifier that does not represent any other request. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + + @return The image download receipt for the data task if available. `nil` if the image is stored in the cache. + cache and the URL request cache policy allows the cache to be used. + */ +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + withReceiptID:(NSUUID *)receiptID + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Cancels the data task in the receipt by removing the corresponding success and failure blocks and cancelling the data task if necessary. + + If the data task is pending in the queue, it will be cancelled if no other success and failure blocks are registered with the data task. If the data task is currently executing or is already completed, the success and failure blocks are removed and will not be called when the task finishes. + + @param imageDownloadReceipt The image download receipt to cancel. + */ +- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt; + +@end + +#endif + +NS_ASSUME_NONNULL_END diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m new file mode 100644 index 0000000..78477bf --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFImageDownloader.m @@ -0,0 +1,391 @@ +// AFImageDownloader.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFImageDownloader.h" +#import "AFHTTPSessionManager.h" + +@interface AFImageDownloaderResponseHandler : NSObject +@property (nonatomic, strong) NSUUID *uuid; +@property (nonatomic, copy) void (^successBlock)(NSURLRequest*, NSHTTPURLResponse*, UIImage*); +@property (nonatomic, copy) void (^failureBlock)(NSURLRequest*, NSHTTPURLResponse*, NSError*); +@end + +@implementation AFImageDownloaderResponseHandler + +- (instancetype)initWithUUID:(NSUUID *)uuid + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { + if (self = [self init]) { + self.uuid = uuid; + self.successBlock = success; + self.failureBlock = failure; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat: @"UUID: %@", [self.uuid UUIDString]]; +} + +@end + +@interface AFImageDownloaderMergedTask : NSObject +@property (nonatomic, strong) NSString *URLIdentifier; +@property (nonatomic, strong) NSUUID *identifier; +@property (nonatomic, strong) NSURLSessionDataTask *task; +@property (nonatomic, strong) NSMutableArray *responseHandlers; + +@end + +@implementation AFImageDownloaderMergedTask + +- (instancetype)initWithURLIdentifier:(NSString *)URLIdentifier identifier:(NSUUID *)identifier task:(NSURLSessionDataTask *)task { + if (self = [self init]) { + self.URLIdentifier = URLIdentifier; + self.task = task; + self.identifier = identifier; + self.responseHandlers = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void)addResponseHandler:(AFImageDownloaderResponseHandler*)handler { + [self.responseHandlers addObject:handler]; +} + +- (void)removeResponseHandler:(AFImageDownloaderResponseHandler*)handler { + [self.responseHandlers removeObject:handler]; +} + +@end + +@implementation AFImageDownloadReceipt + +- (instancetype)initWithReceiptID:(NSUUID *)receiptID task:(NSURLSessionDataTask *)task { + if (self = [self init]) { + self.receiptID = receiptID; + self.task = task; + } + return self; +} + +@end + +@interface AFImageDownloader () + +@property (nonatomic, strong) dispatch_queue_t synchronizationQueue; +@property (nonatomic, strong) dispatch_queue_t responseQueue; + +@property (nonatomic, assign) NSInteger maximumActiveDownloads; +@property (nonatomic, assign) NSInteger activeRequestCount; + +@property (nonatomic, strong) NSMutableArray *queuedMergedTasks; +@property (nonatomic, strong) NSMutableDictionary *mergedTasks; + +@end + + +@implementation AFImageDownloader + ++ (NSURLCache *)defaultURLCache { + return [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 + diskCapacity:150 * 1024 * 1024 + diskPath:@"com.alamofire.imagedownloader"]; +} + ++ (NSURLSessionConfiguration *)defaultURLSessionConfiguration { + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + + //TODO set the default HTTP headers + + configuration.HTTPShouldSetCookies = YES; + configuration.HTTPShouldUsePipelining = NO; + + configuration.requestCachePolicy = NSURLRequestUseProtocolCachePolicy; + configuration.allowsCellularAccess = YES; + configuration.timeoutIntervalForRequest = 60.0; + configuration.URLCache = [AFImageDownloader defaultURLCache]; + + return configuration; +} + +- (instancetype)init { + NSURLSessionConfiguration *defaultConfiguration = [self.class defaultURLSessionConfiguration]; + AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:defaultConfiguration]; + sessionManager.responseSerializer = [AFImageResponseSerializer serializer]; + + return [self initWithSessionManager:sessionManager + downloadPrioritization:AFImageDownloadPrioritizationFIFO + maximumActiveDownloads:4 + imageCache:[[AFAutoPurgingImageCache alloc] init]]; +} + +- (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager + downloadPrioritization:(AFImageDownloadPrioritization)downloadPrioritization + maximumActiveDownloads:(NSInteger)maximumActiveDownloads + imageCache:(id )imageCache { + if (self = [super init]) { + self.sessionManager = sessionManager; + + self.downloadPrioritizaton = downloadPrioritization; + self.maximumActiveDownloads = maximumActiveDownloads; + self.imageCache = imageCache; + + self.queuedMergedTasks = [[NSMutableArray alloc] init]; + self.mergedTasks = [[NSMutableDictionary alloc] init]; + self.activeRequestCount = 0; + + NSString *name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.synchronizationqueue-%@", [[NSUUID UUID] UUIDString]]; + self.synchronizationQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_SERIAL); + + name = [NSString stringWithFormat:@"com.alamofire.imagedownloader.responsequeue-%@", [[NSUUID UUID] UUIDString]]; + self.responseQueue = dispatch_queue_create([name cStringUsingEncoding:NSASCIIStringEncoding], DISPATCH_QUEUE_CONCURRENT); + } + + return self; +} + ++ (instancetype)defaultInstance { + static AFImageDownloader *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; +} + +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + success:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, UIImage * _Nonnull))success + failure:(void (^)(NSURLRequest * _Nonnull, NSHTTPURLResponse * _Nullable, NSError * _Nonnull))failure { + return [self downloadImageForURLRequest:request withReceiptID:[NSUUID UUID] success:success failure:failure]; +} + +- (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *)request + withReceiptID:(nonnull NSUUID *)receiptID + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *responseObject))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { + __block NSURLSessionDataTask *task = nil; + dispatch_sync(self.synchronizationQueue, ^{ + NSString *URLIdentifier = request.URL.absoluteString; + if (URLIdentifier == nil) { + if (failure) { + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorBadURL userInfo:nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + failure(request, nil, error); + }); + } + return; + } + + // 1) Append the success and failure blocks to a pre-existing request if it already exists + AFImageDownloaderMergedTask *existingMergedTask = self.mergedTasks[URLIdentifier]; + if (existingMergedTask != nil) { + AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID success:success failure:failure]; + [existingMergedTask addResponseHandler:handler]; + task = existingMergedTask.task; + return; + } + + // 2) Attempt to load the image from the image cache if the cache policy allows it + switch (request.cachePolicy) { + case NSURLRequestUseProtocolCachePolicy: + case NSURLRequestReturnCacheDataElseLoad: + case NSURLRequestReturnCacheDataDontLoad: { + UIImage *cachedImage = [self.imageCache imageforRequest:request withAdditionalIdentifier:nil]; + if (cachedImage != nil) { + if (success) { + dispatch_async(dispatch_get_main_queue(), ^{ + success(request, nil, cachedImage); + }); + } + return; + } + break; + } + default: + break; + } + + // 3) Create the request and set up authentication, validation and response serialization + NSUUID *mergedTaskIdentifier = [NSUUID UUID]; + NSURLSessionDataTask *createdTask; + __weak __typeof__(self) weakSelf = self; + + createdTask = [self.sessionManager + dataTaskWithRequest:request + completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { + dispatch_async(self.responseQueue, ^{ + __strong __typeof__(weakSelf) strongSelf = weakSelf; + AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier]; + if ([mergedTask.identifier isEqual:mergedTaskIdentifier]) { + mergedTask = [strongSelf safelyRemoveMergedTaskWithURLIdentifier:URLIdentifier]; + if (error) { + for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { + if (handler.failureBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.failureBlock(request, (NSHTTPURLResponse*)response, error); + }); + } + } + } else { + [strongSelf.imageCache addImage:responseObject forRequest:request withAdditionalIdentifier:nil]; + + for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { + if (handler.successBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.successBlock(request, (NSHTTPURLResponse*)response, responseObject); + }); + } + } + + } + } + [strongSelf safelyDecrementActiveTaskCount]; + [strongSelf safelyStartNextTaskIfNecessary]; + }); + }]; + + // 4) Store the response handler for use when the request completes + AFImageDownloaderResponseHandler *handler = [[AFImageDownloaderResponseHandler alloc] initWithUUID:receiptID + success:success + failure:failure]; + AFImageDownloaderMergedTask *mergedTask = [[AFImageDownloaderMergedTask alloc] + initWithURLIdentifier:URLIdentifier + identifier:mergedTaskIdentifier + task:createdTask]; + [mergedTask addResponseHandler:handler]; + self.mergedTasks[URLIdentifier] = mergedTask; + + // 5) Either start the request or enqueue it depending on the current active request count + if ([self isActiveRequestCountBelowMaximumLimit]) { + [self startMergedTask:mergedTask]; + } else { + [self enqueueMergedTask:mergedTask]; + } + + task = mergedTask.task; + }); + if (task) { + return [[AFImageDownloadReceipt alloc] initWithReceiptID:receiptID task:task]; + } else { + return nil; + } +} + +- (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt { + dispatch_sync(self.synchronizationQueue, ^{ + NSString *URLIdentifier = imageDownloadReceipt.task.originalRequest.URL.absoluteString; + AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier]; + NSUInteger index = [mergedTask.responseHandlers indexOfObjectPassingTest:^BOOL(AFImageDownloaderResponseHandler * _Nonnull handler, __unused NSUInteger idx, __unused BOOL * _Nonnull stop) { + return handler.uuid == imageDownloadReceipt.receiptID; + }]; + + if (index != NSNotFound) { + AFImageDownloaderResponseHandler *handler = mergedTask.responseHandlers[index]; + [mergedTask removeResponseHandler:handler]; + NSString *failureReason = [NSString stringWithFormat:@"ImageDownloader cancelled URL request: %@",imageDownloadReceipt.task.originalRequest.URL.absoluteString]; + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey:failureReason}; + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + if (handler.failureBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler.failureBlock(imageDownloadReceipt.task.originalRequest, nil, error); + }); + } + } + + if (mergedTask.responseHandlers.count == 0 && mergedTask.task.state == NSURLSessionTaskStateSuspended) { + [mergedTask.task cancel]; + [self removeMergedTaskWithURLIdentifier:URLIdentifier]; + } + }); +} + +- (AFImageDownloaderMergedTask*)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier { + __block AFImageDownloaderMergedTask *mergedTask = nil; + dispatch_sync(self.synchronizationQueue, ^{ + mergedTask = [self removeMergedTaskWithURLIdentifier:URLIdentifier]; + }); + return mergedTask; +} + +//This method should only be called from safely within the synchronizationQueue +- (AFImageDownloaderMergedTask *)removeMergedTaskWithURLIdentifier:(NSString *)URLIdentifier { + AFImageDownloaderMergedTask *mergedTask = self.mergedTasks[URLIdentifier]; + [self.mergedTasks removeObjectForKey:URLIdentifier]; + return mergedTask; +} + +- (void)safelyDecrementActiveTaskCount { + dispatch_sync(self.synchronizationQueue, ^{ + if (self.activeRequestCount > 0) { + self.activeRequestCount -= 1; + } + }); +} + +- (void)safelyStartNextTaskIfNecessary { + dispatch_sync(self.synchronizationQueue, ^{ + if ([self isActiveRequestCountBelowMaximumLimit]) { + while (self.queuedMergedTasks.count > 0) { + AFImageDownloaderMergedTask *mergedTask = [self dequeueMergedTask]; + if (mergedTask.task.state == NSURLSessionTaskStateSuspended) { + [self startMergedTask:mergedTask]; + break; + } + } + } + }); +} + +- (void)startMergedTask:(AFImageDownloaderMergedTask *)mergedTask { + [mergedTask.task resume]; + ++self.activeRequestCount; +} + +- (void)enqueueMergedTask:(AFImageDownloaderMergedTask *)mergedTask { + switch (self.downloadPrioritizaton) { + case AFImageDownloadPrioritizationFIFO: + [self.queuedMergedTasks addObject:mergedTask]; + break; + case AFImageDownloadPrioritizationLIFO: + [self.queuedMergedTasks insertObject:mergedTask atIndex:0]; + break; + } +} + +- (AFImageDownloaderMergedTask *)dequeueMergedTask { + AFImageDownloaderMergedTask *mergedTask = nil; + mergedTask = [self.queuedMergedTasks firstObject]; + [self.queuedMergedTasks removeObject:mergedTask]; + return mergedTask; +} + +- (BOOL)isActiveRequestCountBelowMaximumLimit { + return self.activeRequestCount < self.maximumActiveDownloads; +} + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 100644 index 0000000..3bcf289 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1,103 @@ +// AFNetworkActivityIndicatorManager.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a session task has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. + + You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: + + [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; + + By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. + + See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: + http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 + */ +NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") +@interface AFNetworkActivityIndicatorManager : NSObject + +/** + A Boolean value indicating whether the manager is enabled. + + If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. + */ +@property (nonatomic, assign, getter = isEnabled) BOOL enabled; + +/** + A Boolean value indicating whether the network activity indicator manager is currently active. +*/ +@property (readonly, nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; + +/** + A time interval indicating the minimum duration of networking activity that should occur before the activity indicator is displayed. The default value 1 second. If the network activity indicator should be displayed immediately when network activity occurs, this value should be set to 0 seconds. + + Apple's HIG describes the following: + + > Display the network activity indicator to provide feedback when your app accesses the network for more than a couple of seconds. If the operation finishes sooner than that, you don’t have to show the network activity indicator, because the indicator is likely to disappear before users notice its presence. + + */ +@property (nonatomic, assign) NSTimeInterval activationDelay; + +/** + A time interval indicating the duration of time of no networking activity required before the activity indicator is disabled. This allows for continuous display of the network activity indicator across multiple requests. The default value is 0.17 seconds. + */ + +@property (nonatomic, assign) NSTimeInterval completionDelay; + +/** + Returns the shared network activity indicator manager object for the system. + + @return The systemwide network activity indicator manager. + */ ++ (instancetype)sharedManager; + +/** + Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. + */ +- (void)incrementActivityCount; + +/** + Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. + */ +- (void)decrementActivityCount; + +/** + Set the a custom method to be executed when the network activity indicator manager should be hidden/shown. By default, this is null, and the UIApplication Network Activity Indicator will be managed automatically. If this block is set, it is the responsiblity of the caller to manager the network activity indicator going forward. + + @param block A block to be executed when the network activity indicator status changes. + */ +- (void)setNetworkingActivityActionWithBlock:(nullable void (^)(BOOL networkActivityIndicatorVisible))block; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m new file mode 100644 index 0000000..e77508e --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m @@ -0,0 +1,261 @@ +// AFNetworkActivityIndicatorManager.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkActivityIndicatorManager.h" + +#if TARGET_OS_IOS +#import "AFURLSessionManager.h" + +typedef NS_ENUM(NSInteger, AFNetworkActivityManagerState) { + AFNetworkActivityManagerStateNotActive, + AFNetworkActivityManagerStateDelayingStart, + AFNetworkActivityManagerStateActive, + AFNetworkActivityManagerStateDelayingEnd +}; + +static NSTimeInterval const kDefaultAFNetworkActivityManagerActivationDelay = 1.0; +static NSTimeInterval const kDefaultAFNetworkActivityManagerCompletionDelay = 0.17; + +static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { + if ([[notification object] respondsToSelector:@selector(originalRequest)]) { + return [(NSURLSessionTask *)[notification object] originalRequest]; + } else { + return nil; + } +} + +typedef void (^AFNetworkActivityActionBlock)(BOOL networkActivityIndicatorVisible); + +@interface AFNetworkActivityIndicatorManager () +@property (readwrite, nonatomic, assign) NSInteger activityCount; +@property (readwrite, nonatomic, strong) NSTimer *activationDelayTimer; +@property (readwrite, nonatomic, strong) NSTimer *completionDelayTimer; +@property (readonly, nonatomic, getter = isNetworkActivityOccurring) BOOL networkActivityOccurring; +@property (nonatomic, copy) AFNetworkActivityActionBlock networkActivityActionBlock; +@property (nonatomic, assign) AFNetworkActivityManagerState currentState; +@property (nonatomic, assign, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; + +- (void)updateCurrentStateForNetworkActivityChange; +@end + +@implementation AFNetworkActivityIndicatorManager + ++ (instancetype)sharedManager { + static AFNetworkActivityIndicatorManager *_sharedManager = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _sharedManager = [[self alloc] init]; + }); + + return _sharedManager; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + self.currentState = AFNetworkActivityManagerStateNotActive; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; + self.activationDelay = kDefaultAFNetworkActivityManagerActivationDelay; + self.completionDelay = kDefaultAFNetworkActivityManagerCompletionDelay; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [_activationDelayTimer invalidate]; + [_completionDelayTimer invalidate]; +} + +- (void)setEnabled:(BOOL)enabled { + _enabled = enabled; + if (enabled == NO) { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; + } +} + +- (void)setNetworkingActivityActionWithBlock:(void (^)(BOOL networkActivityIndicatorVisible))block { + self.networkActivityActionBlock = block; +} + +- (BOOL)isNetworkActivityOccurring { + @synchronized(self) { + return self.activityCount > 0; + } +} + +- (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible { + if (_networkActivityIndicatorVisible != networkActivityIndicatorVisible) { + [self willChangeValueForKey:@"networkActivityIndicatorVisible"]; + @synchronized(self) { + _networkActivityIndicatorVisible = networkActivityIndicatorVisible; + } + [self didChangeValueForKey:@"networkActivityIndicatorVisible"]; + if (self.networkActivityActionBlock) { + self.networkActivityActionBlock(networkActivityIndicatorVisible); + } else { + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:networkActivityIndicatorVisible]; + } + } +} + +- (void)setActivityCount:(NSInteger)activityCount { + @synchronized(self) { + _activityCount = activityCount; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateCurrentStateForNetworkActivityChange]; + }); +} + +- (void)incrementActivityCount { + [self willChangeValueForKey:@"activityCount"]; + @synchronized(self) { + _activityCount++; + } + [self didChangeValueForKey:@"activityCount"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateCurrentStateForNetworkActivityChange]; + }); +} + +- (void)decrementActivityCount { + [self willChangeValueForKey:@"activityCount"]; + @synchronized(self) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + _activityCount = MAX(_activityCount - 1, 0); +#pragma clang diagnostic pop + } + [self didChangeValueForKey:@"activityCount"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateCurrentStateForNetworkActivityChange]; + }); +} + +- (void)networkRequestDidStart:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self incrementActivityCount]; + } +} + +- (void)networkRequestDidFinish:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self decrementActivityCount]; + } +} + +#pragma mark - Internal State Management +- (void)setCurrentState:(AFNetworkActivityManagerState)currentState { + @synchronized(self) { + if (_currentState != currentState) { + [self willChangeValueForKey:@"currentState"]; + _currentState = currentState; + switch (currentState) { + case AFNetworkActivityManagerStateNotActive: + [self cancelActivationDelayTimer]; + [self cancelCompletionDelayTimer]; + [self setNetworkActivityIndicatorVisible:NO]; + break; + case AFNetworkActivityManagerStateDelayingStart: + [self startActivationDelayTimer]; + break; + case AFNetworkActivityManagerStateActive: + [self cancelCompletionDelayTimer]; + [self setNetworkActivityIndicatorVisible:YES]; + break; + case AFNetworkActivityManagerStateDelayingEnd: + [self startCompletionDelayTimer]; + break; + } + } + [self didChangeValueForKey:@"currentState"]; + } +} + +- (void)updateCurrentStateForNetworkActivityChange { + if (self.enabled) { + switch (self.currentState) { + case AFNetworkActivityManagerStateNotActive: + if (self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateDelayingStart]; + } + break; + case AFNetworkActivityManagerStateDelayingStart: + //No op. Let the delay timer finish out. + break; + case AFNetworkActivityManagerStateActive: + if (!self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateDelayingEnd]; + } + break; + case AFNetworkActivityManagerStateDelayingEnd: + if (self.isNetworkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateActive]; + } + break; + } + } +} + +- (void)startActivationDelayTimer { + self.activationDelayTimer = [NSTimer + timerWithTimeInterval:self.activationDelay target:self selector:@selector(activationDelayTimerFired) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:self.activationDelayTimer forMode:NSRunLoopCommonModes]; +} + +- (void)activationDelayTimerFired { + if (self.networkActivityOccurring) { + [self setCurrentState:AFNetworkActivityManagerStateActive]; + } else { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; + } +} + +- (void)startCompletionDelayTimer { + [self.completionDelayTimer invalidate]; + self.completionDelayTimer = [NSTimer timerWithTimeInterval:self.completionDelay target:self selector:@selector(completionDelayTimerFired) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:self.completionDelayTimer forMode:NSRunLoopCommonModes]; +} + +- (void)completionDelayTimerFired { + [self setCurrentState:AFNetworkActivityManagerStateNotActive]; +} + +- (void)cancelActivationDelayTimer { + [self.activationDelayTimer invalidate]; +} + +- (void)cancelCompletionDelayTimer { + [self.completionDelayTimer invalidate]; +} + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 100644 index 0000000..d424c9b --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1,48 @@ +// UIActivityIndicatorView+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +/** + This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a session task. + */ +@interface UIActivityIndicatorView (AFNetworking) + +///---------------------------------- +/// @name Animating for Session Tasks +///---------------------------------- + +/** + Binds the animating state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m new file mode 100644 index 0000000..ed704ed --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m @@ -0,0 +1,124 @@ +// UIActivityIndicatorView+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIActivityIndicatorView+AFNetworking.h" +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFURLSessionManager.h" + +@interface AFActivityIndicatorViewNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +@implementation UIActivityIndicatorView (AFNetworking) + +- (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { + AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; +} + +@end + +@implementation AFActivityIndicatorViewNotificationObserver + +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView +{ + self = [super init]; + if (self) { + _activityIndicatorView = activityIndicatorView; + } + return self; +} + +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { + if (task.state != NSURLSessionTaskStateCompleted) { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (task.state == NSURLSessionTaskStateRunning) { + [self.activityIndicatorView startAnimating]; + } else { + [self.activityIndicatorView stopAnimating]; + } +#pragma clang diagnostic pop + + [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; + } + } +} + +#pragma mark - + +- (void)af_startAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.activityIndicatorView startAnimating]; +#pragma clang diagnostic pop + }); +} + +- (void)af_stopAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.activityIndicatorView stopAnimating]; +#pragma clang diagnostic pop + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +} + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h new file mode 100644 index 0000000..d33e0d4 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1,175 @@ +// UIButton+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFImageDownloader; + +/** + This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL. + + @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported. + */ +@interface UIButton (AFNetworking) + +///------------------------------------ +/// @name Accessing the Image Downloader +///------------------------------------ + +/** + Set the shared image downloader used to download images. + + @param imageDownloader The shared image downloader used to download images. +*/ ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; + +/** + The shared image downloader used to download images. + */ ++ (AFImageDownloader *)sharedImageDownloader; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the image request. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + + +///------------------------------- +/// @name Setting Background Image +///------------------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled. + + If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the background image request. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the background image request. + @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + + +///------------------------------ +/// @name Canceling Image Loading +///------------------------------ + +/** + Cancels any executing image task for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelImageDownloadTaskForState:(UIControlState)state; + +/** + Cancels any executing background image task for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m new file mode 100644 index 0000000..5bc49dd --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m @@ -0,0 +1,305 @@ +// UIButton+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIButton+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "UIImageView+AFNetworking.h" +#import "AFImageDownloader.h" + +@interface UIButton (_AFNetworking) +@end + +@implementation UIButton (_AFNetworking) + +#pragma mark - + +static char AFImageDownloadReceiptNormal; +static char AFImageDownloadReceiptHighlighted; +static char AFImageDownloadReceiptSelected; +static char AFImageDownloadReceiptDisabled; + +static const char * af_imageDownloadReceiptKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFImageDownloadReceiptHighlighted; + case UIControlStateSelected: + return &AFImageDownloadReceiptSelected; + case UIControlStateDisabled: + return &AFImageDownloadReceiptDisabled; + case UIControlStateNormal: + default: + return &AFImageDownloadReceiptNormal; + } +} + +- (AFImageDownloadReceipt *)af_imageDownloadReceiptForState:(UIControlState)state { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_imageDownloadReceiptKeyForState(state)); +} + +- (void)af_setImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_imageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +static char AFBackgroundImageDownloadReceiptNormal; +static char AFBackgroundImageDownloadReceiptHighlighted; +static char AFBackgroundImageDownloadReceiptSelected; +static char AFBackgroundImageDownloadReceiptDisabled; + +static const char * af_backgroundImageDownloadReceiptKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFBackgroundImageDownloadReceiptHighlighted; + case UIControlStateSelected: + return &AFBackgroundImageDownloadReceiptSelected; + case UIControlStateDisabled: + return &AFBackgroundImageDownloadReceiptDisabled; + case UIControlStateNormal: + default: + return &AFBackgroundImageDownloadReceiptNormal; + } +} + +- (AFImageDownloadReceipt *)af_backgroundImageDownloadReceiptForState:(UIControlState)state { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state)); +} + +- (void)af_setBackgroundImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_backgroundImageDownloadReceiptKeyForState(state), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIButton (AFNetworking) + ++ (AFImageDownloader *)sharedImageDownloader { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; +#pragma clang diagnostic pop +} + ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { + objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + if ([self isActiveTaskURLEqualToURLRequest:urlRequest forState:state]) { + return; + } + + [self cancelImageDownloadTaskForState:state]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setImage:cachedImage forState:state]; + } + [self af_setImageDownloadReceipt:nil forState:state]; + } else { + if (placeholderImage) { + [self setImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if(responseObject) { + [strongSelf setImage:responseObject forState:state]; + } + [strongSelf af_setImageDownloadReceipt:nil forState:state]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf af_setImageDownloadReceipt:nil forState:state]; + } + }]; + + [self af_setImageDownloadReceipt:receipt forState:state]; + } +} + +#pragma mark - + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setBackgroundImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + if ([self isActiveBackgroundTaskURLEqualToURLRequest:urlRequest forState:state]) { + return; + } + + [self cancelBackgroundImageDownloadTaskForState:state]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setBackgroundImage:cachedImage forState:state]; + } + [self af_setBackgroundImageDownloadReceipt:nil forState:state]; + } else { + if (placeholderImage) { + [self setBackgroundImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if(responseObject) { + [strongSelf setBackgroundImage:responseObject forState:state]; + } + [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state]; + } + }]; + + [self af_setBackgroundImageDownloadReceipt:receipt forState:state]; + } +} + +#pragma mark - + +- (void)cancelImageDownloadTaskForState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state]; + if (receipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt]; + [self af_setImageDownloadReceipt:nil forState:state]; + } +} + +- (void)cancelBackgroundImageDownloadTaskForState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state]; + if (receipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:receipt]; + [self af_setBackgroundImageDownloadReceipt:nil forState:state]; + } +} + +- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_imageDownloadReceiptForState:state]; + return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + +- (BOOL)isActiveBackgroundTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest forState:(UIControlState)state { + AFImageDownloadReceipt *receipt = [self af_backgroundImageDownloadReceiptForState:state]; + return [receipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h new file mode 100644 index 0000000..14744cd --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1,35 @@ +// +// UIImage+AFNetworking.h +// +// +// Created by Paulo Ferreira on 08/07/15. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +@interface UIImage (AFNetworking) + ++ (UIImage*) safeImageWithData:(NSData*)data; + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h new file mode 100644 index 0000000..8929252 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1,109 @@ +// UIImageView+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFImageDownloader; + +/** + This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. + */ +@interface UIImageView (AFNetworking) + +///------------------------------------ +/// @name Accessing the Image Downloader +///------------------------------------ + +/** + Set the shared image downloader used to download images. + + @param imageDownloader The shared image downloader used to download images. + */ ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader; + +/** + The shared image downloader used to download images. + */ ++ (AFImageDownloader *)sharedImageDownloader; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + + @param url The URL used for the image request. + */ +- (void)setImageWithURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + + @param url The URL used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. + */ +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. + + @param urlRequest The URL request used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. + @param success A block to be executed when the image data task finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image data task finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure; + +/** + Cancels any executing image operation for the receiver, if one exists. + */ +- (void)cancelImageDownloadTask; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m new file mode 100644 index 0000000..5934d68 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m @@ -0,0 +1,161 @@ +// UIImageView+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIImageView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFImageDownloader.h" + +@interface UIImageView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setActiveImageDownloadReceipt:) AFImageDownloadReceipt *af_activeImageDownloadReceipt; +@end + +@implementation UIImageView (_AFNetworking) + +- (AFImageDownloadReceipt *)af_activeImageDownloadReceipt { + return (AFImageDownloadReceipt *)objc_getAssociatedObject(self, @selector(af_activeImageDownloadReceipt)); +} + +- (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloadReceipt { + objc_setAssociatedObject(self, @selector(af_activeImageDownloadReceipt), imageDownloadReceipt, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIImageView (AFNetworking) + ++ (AFImageDownloader *)sharedImageDownloader { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; +#pragma clang diagnostic pop +} + ++ (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { + objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageWithURL:(NSURL *)url { + [self setImageWithURL:url placeholderImage:nil]; +} + +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure +{ + + if ([urlRequest URL] == nil) { + [self cancelImageDownloadTask]; + self.image = placeholderImage; + return; + } + + if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){ + return; + } + + [self cancelImageDownloadTask]; + + AFImageDownloader *downloader = [[self class] sharedImageDownloader]; + id imageCache = downloader.imageCache; + + //Use the image from the image cache if it exists + UIImage *cachedImage = [imageCache imageforRequest:urlRequest withAdditionalIdentifier:nil]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + self.image = cachedImage; + } + [self clearActiveDownloadInformation]; + } else { + if (placeholderImage) { + self.image = placeholderImage; + } + + __weak __typeof(self)weakSelf = self; + NSUUID *downloadID = [NSUUID UUID]; + AFImageDownloadReceipt *receipt; + receipt = [downloader + downloadImageForURLRequest:urlRequest + withReceiptID:downloadID + success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, UIImage * _Nonnull responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { + if (success) { + success(request, response, responseObject); + } else if(responseObject) { + strongSelf.image = responseObject; + } + [strongSelf clearActiveDownloadInformation]; + } + + } + failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { + if (failure) { + failure(request, response, error); + } + [strongSelf clearActiveDownloadInformation]; + } + }]; + + self.af_activeImageDownloadReceipt = receipt; + } +} + +- (void)cancelImageDownloadTask { + if (self.af_activeImageDownloadReceipt != nil) { + [[self.class sharedImageDownloader] cancelTaskForImageDownloadReceipt:self.af_activeImageDownloadReceipt]; + [self clearActiveDownloadInformation]; + } +} + +- (void)clearActiveDownloadInformation { + self.af_activeImageDownloadReceipt = nil; +} + +- (BOOL)isActiveTaskURLEqualToURLRequest:(NSURLRequest *)urlRequest { + return [self.af_activeImageDownloadReceipt.task.originalRequest.URL.absoluteString isEqualToString:urlRequest.URL.absoluteString]; +} + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h new file mode 100644 index 0000000..febacfc --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1,42 @@ +// UIKit+AFNetworking.h +// +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if TARGET_OS_IOS || TARGET_OS_TV +#import + +#ifndef _UIKIT_AFNETWORKING_ + #define _UIKIT_AFNETWORKING_ + +#if TARGET_OS_IOS + #import "AFAutoPurgingImageCache.h" + #import "AFImageDownloader.h" + #import "AFNetworkActivityIndicatorManager.h" + #import "UIRefreshControl+AFNetworking.h" + #import "UIWebView+AFNetworking.h" +#endif + + #import "UIActivityIndicatorView+AFNetworking.h" + #import "UIButton+AFNetworking.h" + #import "UIImageView+AFNetworking.h" + #import "UIProgressView+AFNetworking.h" +#endif /* _UIKIT_AFNETWORKING_ */ +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h new file mode 100644 index 0000000..8ea0a73 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1,64 @@ +// UIProgressView+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import + +NS_ASSUME_NONNULL_BEGIN + + +/** + This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task. + */ +@interface UIProgressView (AFNetworking) + +///------------------------------------ +/// @name Setting Session Task Progress +///------------------------------------ + +/** + Binds the progress to the upload progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated; + +/** + Binds the progress to the download progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m new file mode 100644 index 0000000..058755e --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m @@ -0,0 +1,118 @@ +// UIProgressView+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIProgressView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS || TARGET_OS_TV + +#import "AFURLSessionManager.h" + +static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; +static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; + +#pragma mark - + +@implementation UIProgressView (AFNetworking) + +- (BOOL)af_uploadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; +} + +- (void)af_setUploadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (BOOL)af_downloadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; +} + +- (void)af_setDownloadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated +{ + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + + [self af_setUploadProgressAnimated:animated]; +} + +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated +{ + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + + [self af_setDownloadProgressAnimated:animated]; +} + +#pragma mark - NSKeyValueObserving + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(__unused NSDictionary *)change + context:(void *)context +{ + if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { + if ([object countOfBytesExpectedToSend] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { + if ([object countOfBytesExpectedToReceive] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { + if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { + @try { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; + + if (context == AFTaskCountOfBytesSentContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; + } + + if (context == AFTaskCountOfBytesReceivedContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; + } + } + @catch (NSException * __unused exception) {} + } + } + } +} + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h new file mode 100644 index 0000000..215eafc --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1,53 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a session task. + */ +@interface UIRefreshControl (AFNetworking) + +///----------------------------------- +/// @name Refreshing for Session Tasks +///----------------------------------- + +/** + Binds the refreshing state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m new file mode 100644 index 0000000..aba6d61 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m @@ -0,0 +1,122 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIRefreshControl+AFNetworking.h" +#import + +#if TARGET_OS_IOS + +#import "AFURLSessionManager.h" + +@interface AFRefreshControlNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; + +@end + +@implementation UIRefreshControl (AFNetworking) + +- (AFRefreshControlNotificationObserver *)af_notificationObserver { + AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; +} + +@end + +@implementation AFRefreshControlNotificationObserver + +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl +{ + self = [super init]; + if (self) { + _refreshControl = refreshControl; + } + return self; +} + +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (task.state == NSURLSessionTaskStateRunning) { + [self.refreshControl beginRefreshing]; + + [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; + } else { + [self.refreshControl endRefreshing]; + } +#pragma clang diagnostic pop + } +} + +#pragma mark - + +- (void)af_beginRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.refreshControl beginRefreshing]; +#pragma clang diagnostic pop + }); +} + +- (void)af_endRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.refreshControl endRefreshing]; +#pragma clang diagnostic pop + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +} + +@end + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h new file mode 100644 index 0000000..b9a56af --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1,80 @@ +// UIWebView+AFNetworking.h +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if TARGET_OS_IOS + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFHTTPSessionManager; + +/** + This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. + + @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. + */ +@interface UIWebView (AFNetworking) + +/** + The session manager used to download all requests. + */ +@property (nonatomic, strong) AFHTTPSessionManager *sessionManager; + +/** + Asynchronously loads the specified request. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param progress A progress object monitoring the current download progress. + @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. + @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)loadRequest:(NSURLRequest *)request + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(nullable void (^)(NSError *error))failure; + +/** + Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. + @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. +@param progress A progress object monitoring the current download progress. + @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. + @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)loadRequest:(NSURLRequest *)request + MIMEType:(nullable NSString *)MIMEType + textEncodingName:(nullable NSString *)textEncodingName + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(nullable void (^)(NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m new file mode 100644 index 0000000..751c499 --- /dev/null +++ b/KtTableView/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m @@ -0,0 +1,162 @@ +// UIWebView+AFNetworking.m +// Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIWebView+AFNetworking.h" + +#import + +#if TARGET_OS_IOS + +#import "AFHTTPSessionManager.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" + +@interface UIWebView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setURLSessionTask:) NSURLSessionDataTask *af_URLSessionTask; +@end + +@implementation UIWebView (_AFNetworking) + +- (NSURLSessionDataTask *)af_URLSessionTask { + return (NSURLSessionDataTask *)objc_getAssociatedObject(self, @selector(af_URLSessionTask)); +} + +- (void)af_setURLSessionTask:(NSURLSessionDataTask *)af_URLSessionTask { + objc_setAssociatedObject(self, @selector(af_URLSessionTask), af_URLSessionTask, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIWebView (AFNetworking) + +- (AFHTTPSessionManager *)sessionManager { + static AFHTTPSessionManager *_af_defaultHTTPSessionManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultHTTPSessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; + _af_defaultHTTPSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer]; + _af_defaultHTTPSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sessionManager)) ?: _af_defaultHTTPSessionManager; +#pragma clang diagnostic pop +} + +- (void)setSessionManager:(AFHTTPSessionManager *)sessionManager { + objc_setAssociatedObject(self, @selector(sessionManager), sessionManager, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (AFHTTPResponseSerializer *)responseSerializer { + static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; +#pragma clang diagnostic pop +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)loadRequest:(NSURLRequest *)request + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(void (^)(NSError *error))failure +{ + [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (success) { + string = success(response, string); + } + + return [string dataUsingEncoding:stringEncoding]; + } failure:failure]; +} + +- (void)loadRequest:(NSURLRequest *)request + MIMEType:(NSString *)MIMEType + textEncodingName:(NSString *)textEncodingName + progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress + success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(void (^)(NSError *error))failure +{ + NSParameterAssert(request); + + if (self.af_URLSessionTask.state == NSURLSessionTaskStateRunning || self.af_URLSessionTask.state == NSURLSessionTaskStateSuspended) { + [self.af_URLSessionTask cancel]; + } + self.af_URLSessionTask = nil; + + __weak __typeof(self)weakSelf = self; + NSURLSessionDataTask *dataTask; + dataTask = [self.sessionManager + GET:request.URL.absoluteString + parameters:nil + progress:nil + success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { + __strong __typeof(weakSelf) strongSelf = weakSelf; + if (success) { + success((NSHTTPURLResponse *)task.response, responseObject); + } + [strongSelf loadData:responseObject MIMEType:MIMEType textEncodingName:textEncodingName baseURL:[task.currentRequest URL]]; + + if ([strongSelf.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { + [strongSelf.delegate webViewDidFinishLoad:strongSelf]; + } + } + failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) { + if (failure) { + failure(error); + } + }]; + self.af_URLSessionTask = dataTask; + if (progress != nil) { + *progress = [self.sessionManager downloadProgressForTask:dataTask]; + } + [self.af_URLSessionTask resume]; + + if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { + [self.delegate webViewDidStartLoad:self]; + } +} + +@end + +#endif \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h new file mode 120000 index 0000000..f9dc7db --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFAutoPurgingImageCache.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h new file mode 120000 index 0000000..56feb9f --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFImageDownloader.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFImageDownloader.h new file mode 120000 index 0000000..ce47c92 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFImageDownloader.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 120000 index 0000000..67519d9 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h new file mode 120000 index 0000000..68fc774 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworking.h new file mode 120000 index 0000000..a5a38da --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h new file mode 120000 index 0000000..fd1322d --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFSecurityPolicy.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h new file mode 120000 index 0000000..ca8209b --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h new file mode 120000 index 0000000..e36a765 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h b/KtTableView/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h new file mode 120000 index 0000000..835101d --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLSessionManager.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 120000 index 0000000..c534ebf --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h new file mode 120000 index 0000000..8f2e221 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h new file mode 120000 index 0000000..74f6649 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h new file mode 120000 index 0000000..a95d673 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h new file mode 120000 index 0000000..95017cc --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h new file mode 120000 index 0000000..730b167 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h new file mode 120000 index 0000000..8efd826 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h b/KtTableView/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h new file mode 120000 index 0000000..c8df6ef --- /dev/null +++ b/KtTableView/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefresh.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefresh.h new file mode 120000 index 0000000..d83fdd6 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefresh.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/MJRefresh.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoFooter.h new file mode 120000 index 0000000..5bb1fbc --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoGifFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoGifFooter.h new file mode 120000 index 0000000..1435437 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoGifFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoNormalFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoNormalFooter.h new file mode 120000 index 0000000..6b87abe --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoNormalFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoStateFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoStateFooter.h new file mode 120000 index 0000000..19b2053 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshAutoStateFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackFooter.h new file mode 120000 index 0000000..3df4973 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackGifFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackGifFooter.h new file mode 120000 index 0000000..e5d5f96 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackGifFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackNormalFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackNormalFooter.h new file mode 120000 index 0000000..c578c7f --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackNormalFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackStateFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackStateFooter.h new file mode 120000 index 0000000..3317188 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshBackStateFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshComponent.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshComponent.h new file mode 120000 index 0000000..35cb1b1 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshComponent.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshComponent.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshConst.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshConst.h new file mode 120000 index 0000000..035954b --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshConst.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/MJRefreshConst.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshFooter.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshFooter.h new file mode 120000 index 0000000..743dda2 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshGifHeader.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshGifHeader.h new file mode 120000 index 0000000..aa6afbd --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshGifHeader.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshHeader.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshHeader.h new file mode 120000 index 0000000..3a38b26 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshHeader.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshHeader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshNormalHeader.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshNormalHeader.h new file mode 120000 index 0000000..b5cc164 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshNormalHeader.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshStateHeader.h b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshStateHeader.h new file mode 120000 index 0000000..7bd25cf --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/MJRefreshStateHeader.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/UIScrollView+MJExtension.h b/KtTableView/Pods/Headers/Private/MJRefresh/UIScrollView+MJExtension.h new file mode 120000 index 0000000..1919784 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/UIScrollView+MJExtension.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/UIScrollView+MJExtension.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/UIScrollView+MJRefresh.h b/KtTableView/Pods/Headers/Private/MJRefresh/UIScrollView+MJRefresh.h new file mode 120000 index 0000000..47b703d --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/UIScrollView+MJRefresh.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/UIScrollView+MJRefresh.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Private/MJRefresh/UIView+MJExtension.h b/KtTableView/Pods/Headers/Private/MJRefresh/UIView+MJExtension.h new file mode 120000 index 0000000..5f19813 --- /dev/null +++ b/KtTableView/Pods/Headers/Private/MJRefresh/UIView+MJExtension.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/UIView+MJExtension.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFAutoPurgingImageCache.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFAutoPurgingImageCache.h new file mode 120000 index 0000000..f9dc7db --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFAutoPurgingImageCache.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h new file mode 120000 index 0000000..56feb9f --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFImageDownloader.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFImageDownloader.h new file mode 120000 index 0000000..ce47c92 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFImageDownloader.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 120000 index 0000000..67519d9 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h new file mode 120000 index 0000000..68fc774 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworking.h new file mode 120000 index 0000000..a5a38da --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h new file mode 120000 index 0000000..fd1322d --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFSecurityPolicy.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h new file mode 120000 index 0000000..ca8209b --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h new file mode 120000 index 0000000..e36a765 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h b/KtTableView/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h new file mode 120000 index 0000000..835101d --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLSessionManager.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 120000 index 0000000..c534ebf --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h new file mode 120000 index 0000000..8f2e221 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h new file mode 120000 index 0000000..74f6649 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h new file mode 120000 index 0000000..a95d673 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h new file mode 120000 index 0000000..95017cc --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h new file mode 120000 index 0000000..730b167 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h new file mode 120000 index 0000000..8efd826 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h b/KtTableView/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h new file mode 120000 index 0000000..c8df6ef --- /dev/null +++ b/KtTableView/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefresh.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefresh.h new file mode 120000 index 0000000..d83fdd6 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefresh.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/MJRefresh.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoFooter.h new file mode 120000 index 0000000..5bb1fbc --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoGifFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoGifFooter.h new file mode 120000 index 0000000..1435437 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoGifFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoNormalFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoNormalFooter.h new file mode 120000 index 0000000..6b87abe --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoNormalFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoStateFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoStateFooter.h new file mode 120000 index 0000000..19b2053 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshAutoStateFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackFooter.h new file mode 120000 index 0000000..3df4973 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackGifFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackGifFooter.h new file mode 120000 index 0000000..e5d5f96 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackGifFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackNormalFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackNormalFooter.h new file mode 120000 index 0000000..c578c7f --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackNormalFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackStateFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackStateFooter.h new file mode 120000 index 0000000..3317188 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshBackStateFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshComponent.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshComponent.h new file mode 120000 index 0000000..35cb1b1 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshComponent.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshComponent.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshConst.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshConst.h new file mode 120000 index 0000000..035954b --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshConst.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/MJRefreshConst.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshFooter.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshFooter.h new file mode 120000 index 0000000..743dda2 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshFooter.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshFooter.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshGifHeader.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshGifHeader.h new file mode 120000 index 0000000..aa6afbd --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshGifHeader.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshHeader.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshHeader.h new file mode 120000 index 0000000..3a38b26 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshHeader.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Base/MJRefreshHeader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshNormalHeader.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshNormalHeader.h new file mode 120000 index 0000000..b5cc164 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshNormalHeader.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshStateHeader.h b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshStateHeader.h new file mode 120000 index 0000000..7bd25cf --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/MJRefreshStateHeader.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/UIScrollView+MJExtension.h b/KtTableView/Pods/Headers/Public/MJRefresh/UIScrollView+MJExtension.h new file mode 120000 index 0000000..1919784 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/UIScrollView+MJExtension.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/UIScrollView+MJExtension.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/UIScrollView+MJRefresh.h b/KtTableView/Pods/Headers/Public/MJRefresh/UIScrollView+MJRefresh.h new file mode 120000 index 0000000..47b703d --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/UIScrollView+MJRefresh.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/UIScrollView+MJRefresh.h \ No newline at end of file diff --git a/KtTableView/Pods/Headers/Public/MJRefresh/UIView+MJExtension.h b/KtTableView/Pods/Headers/Public/MJRefresh/UIView+MJExtension.h new file mode 120000 index 0000000..5f19813 --- /dev/null +++ b/KtTableView/Pods/Headers/Public/MJRefresh/UIView+MJExtension.h @@ -0,0 +1 @@ +../../../MJRefresh/MJRefresh/UIView+MJExtension.h \ No newline at end of file diff --git a/KtTableView/Pods/MJRefresh/LICENSE b/KtTableView/Pods/MJRefresh/LICENSE new file mode 100644 index 0000000..11bf234 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h new file mode 100644 index 0000000..5aac4f6 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.h @@ -0,0 +1,20 @@ +// +// MJRefreshAutoFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshFooter.h" + +@interface MJRefreshAutoFooter : MJRefreshFooter +/** 是否自动刷新(默认为YES) */ +@property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; + +/** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ +@property (assign, nonatomic) CGFloat appearencePercentTriggerAutoRefresh MJRefreshDeprecated("请使用automaticallyChangeAlpha属性"); + +/** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ +@property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.m new file mode 100644 index 0000000..fd1687f --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshAutoFooter.m @@ -0,0 +1,133 @@ +// +// MJRefreshAutoFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshAutoFooter.h" + +@interface MJRefreshAutoFooter() +@end + +@implementation MJRefreshAutoFooter + +#pragma mark - 初始化 +- (void)willMoveToSuperview:(UIView *)newSuperview +{ + [super willMoveToSuperview:newSuperview]; + + if (newSuperview) { // 新的父控件 + if (self.hidden == NO) { + self.scrollView.mj_insetB += self.mj_h; + } + + // 设置位置 + self.mj_y = _scrollView.mj_contentH; + } else { // 被移除了 + if (self.hidden == NO) { + self.scrollView.mj_insetB -= self.mj_h; + } + } +} + +#pragma mark - 过期方法 +- (void)setAppearencePercentTriggerAutoRefresh:(CGFloat)appearencePercentTriggerAutoRefresh +{ + self.triggerAutomaticallyRefreshPercent = appearencePercentTriggerAutoRefresh; +} + +- (CGFloat)appearencePercentTriggerAutoRefresh +{ + return self.triggerAutomaticallyRefreshPercent; +} + +#pragma mark - 实现父类的方法 +- (void)prepare +{ + [super prepare]; + + // 默认底部控件100%出现时才会自动刷新 + self.triggerAutomaticallyRefreshPercent = 1.0; + + // 设置为默认状态 + self.automaticallyRefresh = YES; +} + +- (void)scrollViewContentSizeDidChange:(NSDictionary *)change +{ + [super scrollViewContentSizeDidChange:change]; + + // 设置位置 + self.mj_y = self.scrollView.mj_contentH; +} + +- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change +{ + [super scrollViewContentOffsetDidChange:change]; + + if (self.state != MJRefreshStateIdle || !self.automaticallyRefresh || self.mj_y == 0) return; + + if (_scrollView.mj_insetT + _scrollView.mj_contentH > _scrollView.mj_h) { // 内容超过一个屏幕 + // 这里的_scrollView.mj_contentH替换掉self.mj_y更为合理 + if (_scrollView.mj_offsetY >= _scrollView.mj_contentH - _scrollView.mj_h + self.mj_h * self.triggerAutomaticallyRefreshPercent + _scrollView.mj_insetB - self.mj_h) { + // 防止手松开时连续调用 + CGPoint old = [change[@"old"] CGPointValue]; + CGPoint new = [change[@"new"] CGPointValue]; + if (new.y <= old.y) return; + + // 当底部刷新控件完全出现时,才刷新 + [self beginRefreshing]; + } + } +} + +- (void)scrollViewPanStateDidChange:(NSDictionary *)change +{ + [super scrollViewPanStateDidChange:change]; + + if (self.state != MJRefreshStateIdle) return; + + if (_scrollView.panGestureRecognizer.state == UIGestureRecognizerStateEnded) {// 手松开 + if (_scrollView.mj_insetT + _scrollView.mj_contentH <= _scrollView.mj_h) { // 不够一个屏幕 + if (_scrollView.mj_offsetY >= - _scrollView.mj_insetT) { // 向上拽 + [self beginRefreshing]; + } + } else { // 超出一个屏幕 + if (_scrollView.mj_offsetY >= _scrollView.mj_contentH + _scrollView.mj_insetB - _scrollView.mj_h) { + [self beginRefreshing]; + } + } + } +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + if (state == MJRefreshStateRefreshing) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self executeRefreshingCallback]; + }); + } +} + +- (void)setHidden:(BOOL)hidden +{ + BOOL lastHidden = self.isHidden; + + [super setHidden:hidden]; + + if (!lastHidden && hidden) { + self.state = MJRefreshStateIdle; + + self.scrollView.mj_insetB -= self.mj_h; + } else if (lastHidden && !hidden) { + self.scrollView.mj_insetB += self.mj_h; + + // 设置位置 + self.mj_y = _scrollView.mj_contentH; + } +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h new file mode 100644 index 0000000..347083c --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.h @@ -0,0 +1,13 @@ +// +// MJRefreshBackFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshFooter.h" + +@interface MJRefreshBackFooter : MJRefreshFooter + +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.m new file mode 100644 index 0000000..0ffc5e9 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshBackFooter.m @@ -0,0 +1,166 @@ +// +// MJRefreshBackFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshBackFooter.h" + +@interface MJRefreshBackFooter() +@property (assign, nonatomic) NSInteger lastRefreshCount; +@property (assign, nonatomic) CGFloat lastBottomDelta; +@end + +@implementation MJRefreshBackFooter + +#pragma mark - 初始化 +- (void)willMoveToSuperview:(UIView *)newSuperview +{ + [super willMoveToSuperview:newSuperview]; + + [self scrollViewContentSizeDidChange:nil]; +} + +#pragma mark - 实现父类的方法 +- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change +{ + [super scrollViewContentOffsetDidChange:change]; + + // 如果正在刷新,直接返回 + if (self.state == MJRefreshStateRefreshing) return; + + _scrollViewOriginalInset = self.scrollView.contentInset; + + // 当前的contentOffset + CGFloat currentOffsetY = self.scrollView.mj_offsetY; + // 尾部控件刚好出现的offsetY + CGFloat happenOffsetY = [self happenOffsetY]; + // 如果是向下滚动到看不见尾部控件,直接返回 + if (currentOffsetY <= happenOffsetY) return; + + CGFloat pullingPercent = (currentOffsetY - happenOffsetY) / self.mj_h; + + // 如果已全部加载,仅设置pullingPercent,然后返回 + if (self.state == MJRefreshStateNoMoreData) { + self.pullingPercent = pullingPercent; + return; + } + + if (self.scrollView.isDragging) { + self.pullingPercent = pullingPercent; + // 普通 和 即将刷新 的临界点 + CGFloat normal2pullingOffsetY = happenOffsetY + self.mj_h; + + if (self.state == MJRefreshStateIdle && currentOffsetY > normal2pullingOffsetY) { + // 转为即将刷新状态 + self.state = MJRefreshStatePulling; + } else if (self.state == MJRefreshStatePulling && currentOffsetY <= normal2pullingOffsetY) { + // 转为普通状态 + self.state = MJRefreshStateIdle; + } + } else if (self.state == MJRefreshStatePulling) {// 即将刷新 && 手松开 + // 开始刷新 + [self beginRefreshing]; + } else if (pullingPercent < 1) { + self.pullingPercent = pullingPercent; + } +} + +- (void)scrollViewContentSizeDidChange:(NSDictionary *)change +{ + [super scrollViewContentSizeDidChange:change]; + + // 内容的高度 + CGFloat contentHeight = self.scrollView.mj_contentH + self.ignoredScrollViewContentInsetBottom; + // 表格的高度 + CGFloat scrollHeight = self.scrollView.mj_h - self.scrollViewOriginalInset.top - self.scrollViewOriginalInset.bottom + self.ignoredScrollViewContentInsetBottom; + // 设置位置和尺寸 + self.mj_y = MAX(contentHeight, scrollHeight); +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 根据状态来设置属性 + if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { + // 刷新完毕 + if (MJRefreshStateRefreshing == oldState) { + [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ + self.scrollView.mj_insetB -= self.lastBottomDelta; + + // 自动调整透明度 + if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; + } completion:^(BOOL finished) { + self.pullingPercent = 0.0; + }]; + } + + CGFloat deltaH = [self heightForContentBreakView]; + // 刚刷新完毕 + if (MJRefreshStateRefreshing == oldState && deltaH > 0 && self.scrollView.mj_totalDataCount != self.lastRefreshCount) { + self.scrollView.mj_offsetY = self.scrollView.mj_offsetY; + } + } else if (state == MJRefreshStateRefreshing) { + // 记录刷新前的数量 + self.lastRefreshCount = self.scrollView.mj_totalDataCount; + + [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ + CGFloat bottom = self.mj_h + self.scrollViewOriginalInset.bottom; + CGFloat deltaH = [self heightForContentBreakView]; + if (deltaH < 0) { // 如果内容高度小于view的高度 + bottom -= deltaH; + } + self.lastBottomDelta = bottom - self.scrollView.mj_insetB; + self.scrollView.mj_insetB = bottom; + self.scrollView.mj_offsetY = [self happenOffsetY] + self.mj_h; + } completion:^(BOOL finished) { + [self executeRefreshingCallback]; + }]; + } +} + +#pragma mark - 公共方法 +- (void)endRefreshing +{ + if ([self.scrollView isKindOfClass:[UICollectionView class]]) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [super endRefreshing]; + }); + } else { + [super endRefreshing]; + } +} + +- (void)noticeNoMoreData +{ + if ([self.scrollView isKindOfClass:[UICollectionView class]]) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [super noticeNoMoreData]; + }); + } else { + [super noticeNoMoreData]; + } +} + +#pragma mark - 私有方法 +#pragma mark 获得scrollView的内容 超出 view 的高度 +- (CGFloat)heightForContentBreakView +{ + CGFloat h = self.scrollView.frame.size.height - self.scrollViewOriginalInset.bottom - self.scrollViewOriginalInset.top; + return self.scrollView.contentSize.height - h; +} + +#pragma mark 刚好看到上拉刷新控件时的contentOffset.y +- (CGFloat)happenOffsetY +{ + CGFloat deltaH = [self heightForContentBreakView]; + if (deltaH > 0) { + return deltaH - self.scrollViewOriginalInset.top; + } else { + return - self.scrollViewOriginalInset.top; + } +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.h b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.h new file mode 100644 index 0000000..5f59361 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.h @@ -0,0 +1,93 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// MJRefreshComponent.h +// MJRefreshExample +// +// Created by MJ Lee on 15/3/4. +// Copyright (c) 2015年 小码哥. All rights reserved. +// 刷新控件的基类 + +#import +#import "MJRefreshConst.h" +#import "UIView+MJExtension.h" +#import "UIScrollView+MJExtension.h" +#import "UIScrollView+MJRefresh.h" + +/** 刷新控件的状态 */ +typedef NS_ENUM(NSInteger, MJRefreshState) { + /** 普通闲置状态 */ + MJRefreshStateIdle = 1, + /** 松开就可以进行刷新的状态 */ + MJRefreshStatePulling, + /** 正在刷新中的状态 */ + MJRefreshStateRefreshing, + /** 即将刷新的状态 */ + MJRefreshStateWillRefresh, + /** 所有数据加载完毕,没有更多的数据了 */ + MJRefreshStateNoMoreData +}; + +/** 进入刷新状态的回调 */ +typedef void (^MJRefreshComponentRefreshingBlock)(); + +/** 刷新控件的基类 */ +@interface MJRefreshComponent : UIView +{ + /** 记录scrollView刚开始的inset */ + UIEdgeInsets _scrollViewOriginalInset; + /** 父控件 */ + __weak UIScrollView *_scrollView; +} +#pragma mark - 刷新回调 +/** 正在刷新的回调 */ +@property (copy, nonatomic) MJRefreshComponentRefreshingBlock refreshingBlock; +/** 设置回调对象和回调方法 */ +- (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action; +/** 回调对象 */ +@property (weak, nonatomic) id refreshingTarget; +/** 回调方法 */ +@property (assign, nonatomic) SEL refreshingAction; +/** 触发回调(交给子类去调用) */ +- (void)executeRefreshingCallback; + +#pragma mark - 刷新状态控制 +/** 进入刷新状态 */ +- (void)beginRefreshing; +/** 结束刷新状态 */ +- (void)endRefreshing; +/** 是否正在刷新 */ +- (BOOL)isRefreshing; +/** 刷新状态 一般交给子类内部实现 */ +@property (assign, nonatomic) MJRefreshState state; + +#pragma mark - 交给子类去访问 +/** 记录scrollView刚开始的inset */ +@property (assign, nonatomic, readonly) UIEdgeInsets scrollViewOriginalInset; +/** 父控件 */ +@property (weak, nonatomic, readonly) UIScrollView *scrollView; + +#pragma mark - 交给子类们去实现 +/** 初始化 */ +- (void)prepare NS_REQUIRES_SUPER; +/** 摆放子控件frame */ +- (void)placeSubviews NS_REQUIRES_SUPER; +/** 当scrollView的contentOffset发生改变的时候调用 */ +- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; +/** 当scrollView的contentSize发生改变的时候调用 */ +- (void)scrollViewContentSizeDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; +/** 当scrollView的拖拽状态发生改变的时候调用 */ +- (void)scrollViewPanStateDidChange:(NSDictionary *)change NS_REQUIRES_SUPER; + + +#pragma mark - 其他 +/** 拉拽的百分比(交给子类重写) */ +@property (assign, nonatomic) CGFloat pullingPercent; +/** 根据拖拽比例自动切换透明度 */ +@property (assign, nonatomic, getter=isAutoChangeAlpha) BOOL autoChangeAlpha MJRefreshDeprecated("请使用automaticallyChangeAlpha属性"); +/** 根据拖拽比例自动切换透明度 */ +@property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; +@end + +@interface UILabel(MJRefresh) ++ (instancetype)label; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.m b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.m new file mode 100644 index 0000000..1b6ea27 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshComponent.m @@ -0,0 +1,226 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// MJRefreshComponent.m +// MJRefreshExample +// +// Created by MJ Lee on 15/3/4. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshComponent.h" +#import "MJRefreshConst.h" +#import "UIView+MJExtension.h" +#import "UIScrollView+MJRefresh.h" + +@interface MJRefreshComponent() +@property (strong, nonatomic) UIPanGestureRecognizer *pan; +@end + +@implementation MJRefreshComponent +#pragma mark - 初始化 +- (instancetype)initWithFrame:(CGRect)frame +{ + if (self = [super initWithFrame:frame]) { + // 准备工作 + [self prepare]; + + // 默认是普通状态 + self.state = MJRefreshStateIdle; + } + return self; +} + +- (void)prepare +{ + // 基本属性 + self.autoresizingMask = UIViewAutoresizingFlexibleWidth; + self.backgroundColor = [UIColor clearColor]; +} + +- (void)layoutSubviews +{ + [super layoutSubviews]; + + [self placeSubviews]; +} + +- (void)placeSubviews{} + +- (void)willMoveToSuperview:(UIView *)newSuperview +{ + [super willMoveToSuperview:newSuperview]; + + // 如果不是UIScrollView,不做任何事情 + if (newSuperview && ![newSuperview isKindOfClass:[UIScrollView class]]) return; + + // 旧的父控件移除监听 + [self removeObservers]; + + if (newSuperview) { // 新的父控件 + // 设置宽度 + self.mj_w = newSuperview.mj_w; + // 设置位置 + self.mj_x = 0; + + // 记录UIScrollView + _scrollView = (UIScrollView *)newSuperview; + // 设置永远支持垂直弹簧效果 + _scrollView.alwaysBounceVertical = YES; + // 记录UIScrollView最开始的contentInset + _scrollViewOriginalInset = _scrollView.contentInset; + + // 添加监听 + [self addObservers]; + } +} + +- (void)drawRect:(CGRect)rect +{ + [super drawRect:rect]; + + if (self.state == MJRefreshStateWillRefresh) { + // 预防view还没显示出来就调用了beginRefreshing + self.state = MJRefreshStateRefreshing; + } +} + +#pragma mark - KVO监听 +- (void)addObservers +{ + NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld; + [self.scrollView addObserver:self forKeyPath:MJRefreshKeyPathContentOffset options:options context:nil]; + [self.scrollView addObserver:self forKeyPath:MJRefreshKeyPathContentSize options:options context:nil]; + self.pan = self.scrollView.panGestureRecognizer; + [self.pan addObserver:self forKeyPath:MJRefreshKeyPathPanState options:options context:nil]; +} + +- (void)removeObservers +{ + [self.superview removeObserver:self forKeyPath:MJRefreshKeyPathContentOffset]; + [self.superview removeObserver:self forKeyPath:MJRefreshKeyPathContentSize];; + [self.pan removeObserver:self forKeyPath:MJRefreshKeyPathPanState]; + self.pan = nil; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + // 遇到这些情况就直接返回 + if (!self.userInteractionEnabled) return; + + // 这个就算看不见也需要处理 + if ([keyPath isEqualToString:MJRefreshKeyPathContentSize]) { + [self scrollViewContentSizeDidChange:change]; + } + + // 看不见 + if (self.hidden) return; + if ([keyPath isEqualToString:MJRefreshKeyPathContentOffset]) { + [self scrollViewContentOffsetDidChange:change]; + } else if ([keyPath isEqualToString:MJRefreshKeyPathPanState]) { + [self scrollViewPanStateDidChange:change]; + } +} + +- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change{} +- (void)scrollViewContentSizeDidChange:(NSDictionary *)change{} +- (void)scrollViewPanStateDidChange:(NSDictionary *)change{} + +#pragma mark - 公共方法 +#pragma mark 设置回调对象和回调方法 +- (void)setRefreshingTarget:(id)target refreshingAction:(SEL)action +{ + self.refreshingTarget = target; + self.refreshingAction = action; +} + +#pragma mark 进入刷新状态 +- (void)beginRefreshing +{ + [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ + self.alpha = 1.0; + }]; + self.pullingPercent = 1.0; + // 只要正在刷新,就完全显示 + if (self.window) { + self.state = MJRefreshStateRefreshing; + } else { + self.state = MJRefreshStateWillRefresh; + // 刷新(预防从另一个控制器回到这个控制器的情况,回来要重新刷新一下) + [self setNeedsDisplay]; + } +} + +#pragma mark 结束刷新状态 +- (void)endRefreshing +{ + self.state = MJRefreshStateIdle; +} + +#pragma mark 是否正在刷新 +- (BOOL)isRefreshing +{ + return self.state == MJRefreshStateRefreshing || self.state == MJRefreshStateWillRefresh; +} + +#pragma mark 自动切换透明度 +- (void)setAutoChangeAlpha:(BOOL)autoChangeAlpha +{ + self.automaticallyChangeAlpha = autoChangeAlpha; +} + +- (BOOL)isAutoChangeAlpha +{ + return self.isAutomaticallyChangeAlpha; +} + +- (void)setAutomaticallyChangeAlpha:(BOOL)automaticallyChangeAlpha +{ + _automaticallyChangeAlpha = automaticallyChangeAlpha; + + if (self.isRefreshing) return; + + if (automaticallyChangeAlpha) { + self.alpha = self.pullingPercent; + } else { + self.alpha = 1.0; + } +} + +#pragma mark 根据拖拽进度设置透明度 +- (void)setPullingPercent:(CGFloat)pullingPercent +{ + _pullingPercent = pullingPercent; + + if (self.isRefreshing) return; + + if (self.isAutomaticallyChangeAlpha) { + self.alpha = pullingPercent; + } +} + +#pragma mark - 内部方法 +- (void)executeRefreshingCallback +{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.refreshingBlock) { + self.refreshingBlock(); + } + if ([self.refreshingTarget respondsToSelector:self.refreshingAction]) { + MJRefreshMsgSend(MJRefreshMsgTarget(self.refreshingTarget), self.refreshingAction, self); + } + }); +} +@end + +@implementation UILabel(MJRefresh) ++ (instancetype)label +{ + UILabel *label = [[self alloc] init]; + label.font = MJRefreshLabelFont; + label.textColor = MJRefreshLabelTextColor; + label.autoresizingMask = UIViewAutoresizingFlexibleWidth; + label.textAlignment = NSTextAlignmentCenter; + label.backgroundColor = [UIColor clearColor]; + return label; +} +@end \ No newline at end of file diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.h new file mode 100644 index 0000000..22d23e5 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.h @@ -0,0 +1,30 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// MJRefreshFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/3/5. +// Copyright (c) 2015年 小码哥. All rights reserved. +// 上拉刷新控件 + +#import "MJRefreshComponent.h" + +@interface MJRefreshFooter : MJRefreshComponent +/** 创建footer */ ++ (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; +/** 创建footer */ ++ (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; + +/** 提示没有更多的数据 */ +- (void)endRefreshingWithNoMoreData; +- (void)noticeNoMoreData MJRefreshDeprecated("使用endRefreshingWithNoMoreData"); + +/** 重置没有更多的数据(消除没有更多数据的状态) */ +- (void)resetNoMoreData; + +/** 忽略多少scrollView的contentInset的bottom */ +@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; + +/** 自动根据有无数据来显示和隐藏(有数据就显示,没有数据隐藏。默认是NO) */ +@property (assign, nonatomic, getter=isAutomaticallyHidden) BOOL automaticallyHidden; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.m new file mode 100644 index 0000000..69f65e7 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshFooter.m @@ -0,0 +1,74 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// MJRefreshFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/3/5. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshFooter.h" + +@interface MJRefreshFooter() + +@end + +@implementation MJRefreshFooter +#pragma mark - 构造方法 ++ (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock +{ + MJRefreshFooter *cmp = [[self alloc] init]; + cmp.refreshingBlock = refreshingBlock; + return cmp; +} ++ (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action +{ + MJRefreshFooter *cmp = [[self alloc] init]; + [cmp setRefreshingTarget:target refreshingAction:action]; + return cmp; +} + +#pragma mark - 重写父类的方法 +- (void)prepare +{ + [super prepare]; + + // 设置自己的高度 + self.mj_h = MJRefreshFooterHeight; + + // 默认不会自动隐藏 + self.automaticallyHidden = NO; +} + +- (void)willMoveToSuperview:(UIView *)newSuperview +{ + [super willMoveToSuperview:newSuperview]; + + if (newSuperview) { + // 监听scrollView数据的变化 + if ([self.scrollView isKindOfClass:[UITableView class]] || [self.scrollView isKindOfClass:[UICollectionView class]]) { + [self.scrollView setMj_reloadDataBlock:^(NSInteger totalDataCount) { + if (self.isAutomaticallyHidden) { + self.hidden = (totalDataCount == 0); + } + }]; + } + } +} + +#pragma mark - 公共方法 +- (void)endRefreshingWithNoMoreData +{ + self.state = MJRefreshStateNoMoreData; +} + +- (void)noticeNoMoreData +{ + [self endRefreshingWithNoMoreData]; +} + +- (void)resetNoMoreData +{ + self.state = MJRefreshStateIdle; +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.h b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.h new file mode 100644 index 0000000..0816024 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.h @@ -0,0 +1,25 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// MJRefreshHeader.h +// MJRefreshExample +// +// Created by MJ Lee on 15/3/4. +// Copyright (c) 2015年 小码哥. All rights reserved. +// 下拉刷新控件:负责监控用户下拉的状态 + +#import "MJRefreshComponent.h" + +@interface MJRefreshHeader : MJRefreshComponent +/** 创建header */ ++ (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; +/** 创建header */ ++ (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; + +/** 这个key用来存储上一次下拉刷新成功的时间 */ +@property (copy, nonatomic) NSString *lastUpdatedTimeKey; +/** 上一次下拉刷新成功的时间 */ +@property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; + +/** 忽略多少scrollView的contentInset的top */ +@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.m b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.m new file mode 100644 index 0000000..852f3c7 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Base/MJRefreshHeader.m @@ -0,0 +1,159 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// MJRefreshHeader.m +// MJRefreshExample +// +// Created by MJ Lee on 15/3/4. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshHeader.h" + +@interface MJRefreshHeader() +@property (assign, nonatomic) CGFloat insetTDelta; +@end + +@implementation MJRefreshHeader +#pragma mark - 构造方法 ++ (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock +{ + MJRefreshHeader *cmp = [[self alloc] init]; + cmp.refreshingBlock = refreshingBlock; + return cmp; +} ++ (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action +{ + MJRefreshHeader *cmp = [[self alloc] init]; + [cmp setRefreshingTarget:target refreshingAction:action]; + return cmp; +} + +#pragma mark - 覆盖父类的方法 +- (void)prepare +{ + [super prepare]; + + // 设置key + self.lastUpdatedTimeKey = MJRefreshHeaderLastUpdatedTimeKey; + + // 设置高度 + self.mj_h = MJRefreshHeaderHeight; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + // 设置y值(当自己的高度发生改变了,肯定要重新调整Y值,所以放到placeSubviews方法中设置y值) + self.mj_y = - self.mj_h - self.ignoredScrollViewContentInsetTop; +} + +- (void)scrollViewContentOffsetDidChange:(NSDictionary *)change +{ + [super scrollViewContentOffsetDidChange:change]; + + // 在刷新的refreshing状态 + if (self.state == MJRefreshStateRefreshing) { + if (self.window == nil) return; + + // sectionheader停留解决 + CGFloat insetT = - self.scrollView.mj_offsetY > _scrollViewOriginalInset.top ? - self.scrollView.mj_offsetY : _scrollViewOriginalInset.top; + insetT = insetT > self.mj_h + _scrollViewOriginalInset.top ? self.mj_h + _scrollViewOriginalInset.top : insetT; + self.scrollView.mj_insetT = insetT; + + self.insetTDelta = _scrollViewOriginalInset.top - insetT; + return; + } + + // 跳转到下一个控制器时,contentInset可能会变 + _scrollViewOriginalInset = self.scrollView.contentInset; + + // 当前的contentOffset + CGFloat offsetY = self.scrollView.mj_offsetY; + // 头部控件刚好出现的offsetY + CGFloat happenOffsetY = - self.scrollViewOriginalInset.top; + + // 如果是向上滚动到看不见头部控件,直接返回 + // >= -> > + if (offsetY > happenOffsetY) return; + + // 普通 和 即将刷新 的临界点 + CGFloat normal2pullingOffsetY = happenOffsetY - self.mj_h; + CGFloat pullingPercent = (happenOffsetY - offsetY) / self.mj_h; + + if (self.scrollView.isDragging) { // 如果正在拖拽 + self.pullingPercent = pullingPercent; + if (self.state == MJRefreshStateIdle && offsetY < normal2pullingOffsetY) { + // 转为即将刷新状态 + self.state = MJRefreshStatePulling; + } else if (self.state == MJRefreshStatePulling && offsetY >= normal2pullingOffsetY) { + // 转为普通状态 + self.state = MJRefreshStateIdle; + } + } else if (self.state == MJRefreshStatePulling) {// 即将刷新 && 手松开 + // 开始刷新 + [self beginRefreshing]; + } else if (pullingPercent < 1) { + self.pullingPercent = pullingPercent; + } +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 根据状态做事情 + if (state == MJRefreshStateIdle) { + if (oldState != MJRefreshStateRefreshing) return; + + // 保存刷新时间 + [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:self.lastUpdatedTimeKey]; + [[NSUserDefaults standardUserDefaults] synchronize]; + + // 恢复inset和offset + [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ + self.scrollView.mj_insetT += self.insetTDelta; + + // 自动调整透明度 + if (self.isAutomaticallyChangeAlpha) self.alpha = 0.0; + } completion:^(BOOL finished) { + self.pullingPercent = 0.0; + }]; + } else if (state == MJRefreshStateRefreshing) { + [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ + // 增加滚动区域 + CGFloat top = self.scrollViewOriginalInset.top + self.mj_h; + self.scrollView.mj_insetT = top; + + // 设置滚动位置 + self.scrollView.mj_offsetY = - top; + } completion:^(BOOL finished) { + [self executeRefreshingCallback]; + }]; + } +} + +- (void)drawRect:(CGRect)rect +{ + [super drawRect:rect]; + + +} + +#pragma mark - 公共方法 +- (void)endRefreshing +{ + if ([self.scrollView isKindOfClass:[UICollectionView class]]) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [super endRefreshing]; + }); + } else { + [super endRefreshing]; + } +} + +- (NSDate *)lastUpdatedTime +{ + return [[NSUserDefaults standardUserDefaults] objectForKey:self.lastUpdatedTimeKey]; +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h new file mode 100644 index 0000000..6a127e6 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h @@ -0,0 +1,17 @@ +// +// MJRefreshAutoGifFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshAutoStateFooter.h" + +@interface MJRefreshAutoGifFooter : MJRefreshAutoStateFooter +@property (weak, nonatomic, readonly) UIImageView *gifView; + +/** 设置state状态下的动画图片images 动画持续时间duration*/ +- (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; +- (void)setImages:(NSArray *)images forState:(MJRefreshState)state; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m new file mode 100644 index 0000000..9e68606 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m @@ -0,0 +1,108 @@ +// +// MJRefreshAutoGifFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshAutoGifFooter.h" + +@interface MJRefreshAutoGifFooter() +{ + __unsafe_unretained UIImageView *_gifView; +} +/** 所有状态对应的动画图片 */ +@property (strong, nonatomic) NSMutableDictionary *stateImages; +/** 所有状态对应的动画时间 */ +@property (strong, nonatomic) NSMutableDictionary *stateDurations; +@end + +@implementation MJRefreshAutoGifFooter +#pragma mark - 懒加载 +- (UIImageView *)gifView +{ + if (!_gifView) { + UIImageView *gifView = [[UIImageView alloc] init]; + [self addSubview:_gifView = gifView]; + } + return _gifView; +} + +- (NSMutableDictionary *)stateImages +{ + if (!_stateImages) { + self.stateImages = [NSMutableDictionary dictionary]; + } + return _stateImages; +} + +- (NSMutableDictionary *)stateDurations +{ + if (!_stateDurations) { + self.stateDurations = [NSMutableDictionary dictionary]; + } + return _stateDurations; +} + +#pragma mark - 公共方法 +- (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state +{ + if (images == nil) return; + + self.stateImages[@(state)] = images; + self.stateDurations[@(state)] = @(duration); + + /* 根据图片设置控件的高度 */ + UIImage *image = [images firstObject]; + if (image.size.height > self.mj_h) { + self.mj_h = image.size.height; + } +} + +- (void)setImages:(NSArray *)images forState:(MJRefreshState)state +{ + [self setImages:images duration:images.count * 0.1 forState:state]; +} + +#pragma mark - 实现父类的方法 +- (void)placeSubviews +{ + [super placeSubviews]; + + if (self.gifView.constraints.count) return; + + self.gifView.frame = self.bounds; + if (self.isRefreshingTitleHidden) { + self.gifView.contentMode = UIViewContentModeCenter; + } else { + self.gifView.contentMode = UIViewContentModeRight; + self.gifView.mj_w = self.mj_w * 0.5 - 90; + } +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 根据状态做事情 + if (state == MJRefreshStateRefreshing) { + NSArray *images = self.stateImages[@(state)]; + if (images.count == 0) return; + [self.gifView stopAnimating]; + + self.gifView.hidden = NO; + if (images.count == 1) { // 单张图片 + self.gifView.image = [images lastObject]; + } else { // 多张图片 + self.gifView.animationImages = images; + self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; + [self.gifView startAnimating]; + } + } else if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { + [self.gifView stopAnimating]; + self.gifView.hidden = YES; + } +} +@end + diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h new file mode 100644 index 0000000..5549cff --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h @@ -0,0 +1,14 @@ +// +// MJRefreshAutoNormalFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshAutoStateFooter.h" + +@interface MJRefreshAutoNormalFooter : MJRefreshAutoStateFooter +/** 菊花的样式 */ +@property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m new file mode 100644 index 0000000..c14bdf8 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m @@ -0,0 +1,69 @@ +// +// MJRefreshAutoNormalFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshAutoNormalFooter.h" + +@interface MJRefreshAutoNormalFooter() +@property (weak, nonatomic) UIActivityIndicatorView *loadingView; +@end + +@implementation MJRefreshAutoNormalFooter +#pragma mark - 懒加载子控件 +- (UIActivityIndicatorView *)loadingView +{ + if (!_loadingView) { + UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; + loadingView.hidesWhenStopped = YES; + [self addSubview:_loadingView = loadingView]; + } + return _loadingView; +} + +- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle +{ + _activityIndicatorViewStyle = activityIndicatorViewStyle; + + self.loadingView = nil; + [self setNeedsLayout]; +} +#pragma makr - 重写父类的方法 +- (void)prepare +{ + [super prepare]; + + self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + if (self.loadingView.constraints.count) return; + + // 圈圈 + CGFloat loadingCenterX = self.mj_w * 0.5; + if (!self.isRefreshingTitleHidden) { + loadingCenterX -= 100; + } + CGFloat loadingCenterY = self.mj_h * 0.5; + self.loadingView.center = CGPointMake(loadingCenterX, loadingCenterY); +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 根据状态做事情 + if (state == MJRefreshStateNoMoreData || state == MJRefreshStateIdle) { + [self.loadingView stopAnimating]; + } else if (state == MJRefreshStateRefreshing) { + [self.loadingView startAnimating]; + } +} + +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h new file mode 100644 index 0000000..956188b --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h @@ -0,0 +1,20 @@ +// +// MJRefreshAutoStateFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/6/13. +// Copyright © 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshAutoFooter.h" + +@interface MJRefreshAutoStateFooter : MJRefreshAutoFooter +/** 显示刷新状态的label */ +@property (weak, nonatomic, readonly) UILabel *stateLabel; + +/** 设置state状态下的文字 */ +- (void)setTitle:(NSString *)title forState:(MJRefreshState)state; + +/** 隐藏刷新状态的文字 */ +@property (assign, nonatomic, getter=isRefreshingTitleHidden) BOOL refreshingTitleHidden; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m new file mode 100644 index 0000000..9135bf1 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m @@ -0,0 +1,89 @@ +// +// MJRefreshAutoStateFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/6/13. +// Copyright © 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshAutoStateFooter.h" + +@interface MJRefreshAutoStateFooter() +{ + /** 显示刷新状态的label */ + __unsafe_unretained UILabel *_stateLabel; +} +/** 所有状态对应的文字 */ +@property (strong, nonatomic) NSMutableDictionary *stateTitles; +@end + +@implementation MJRefreshAutoStateFooter +#pragma mark - 懒加载 +- (NSMutableDictionary *)stateTitles +{ + if (!_stateTitles) { + self.stateTitles = [NSMutableDictionary dictionary]; + } + return _stateTitles; +} + +- (UILabel *)stateLabel +{ + if (!_stateLabel) { + [self addSubview:_stateLabel = [UILabel label]]; + } + return _stateLabel; +} + +#pragma mark - 公共方法 +- (void)setTitle:(NSString *)title forState:(MJRefreshState)state +{ + if (title == nil) return; + self.stateTitles[@(state)] = title; + self.stateLabel.text = self.stateTitles[@(self.state)]; +} + +#pragma mark - 私有方法 +- (void)stateLabelClick +{ + if (self.state == MJRefreshStateIdle) { + [self beginRefreshing]; + } +} + +#pragma mark - 重写父类的方法 +- (void)prepare +{ + [super prepare]; + + // 初始化文字 + [self setTitle:MJRefreshAutoFooterIdleText forState:MJRefreshStateIdle]; + [self setTitle:MJRefreshAutoFooterRefreshingText forState:MJRefreshStateRefreshing]; + [self setTitle:MJRefreshAutoFooterNoMoreDataText forState:MJRefreshStateNoMoreData]; + + // 监听label + self.stateLabel.userInteractionEnabled = YES; + [self.stateLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stateLabelClick)]]; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + if (self.stateLabel.constraints.count) return; + + // 状态标签 + self.stateLabel.frame = self.bounds; +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + if (self.isRefreshingTitleHidden && state == MJRefreshStateRefreshing) { + self.stateLabel.text = nil; + } else { + self.stateLabel.text = self.stateTitles[@(state)]; + } +} +@end \ No newline at end of file diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h new file mode 100644 index 0000000..b29af86 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h @@ -0,0 +1,17 @@ +// +// MJRefreshBackGifFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshBackStateFooter.h" + +@interface MJRefreshBackGifFooter : MJRefreshBackStateFooter +@property (weak, nonatomic, readonly) UIImageView *gifView; + +/** 设置state状态下的动画图片images 动画持续时间duration*/ +- (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; +- (void)setImages:(NSArray *)images forState:(MJRefreshState)state; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m new file mode 100644 index 0000000..ae233e0 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m @@ -0,0 +1,119 @@ +// +// MJRefreshBackGifFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshBackGifFooter.h" + +@interface MJRefreshBackGifFooter() +{ + __unsafe_unretained UIImageView *_gifView; +} +/** 所有状态对应的动画图片 */ +@property (strong, nonatomic) NSMutableDictionary *stateImages; +/** 所有状态对应的动画时间 */ +@property (strong, nonatomic) NSMutableDictionary *stateDurations; +@end + +@implementation MJRefreshBackGifFooter +#pragma mark - 懒加载 +- (UIImageView *)gifView +{ + if (!_gifView) { + UIImageView *gifView = [[UIImageView alloc] init]; + [self addSubview:_gifView = gifView]; + } + return _gifView; +} + +- (NSMutableDictionary *)stateImages +{ + if (!_stateImages) { + self.stateImages = [NSMutableDictionary dictionary]; + } + return _stateImages; +} + +- (NSMutableDictionary *)stateDurations +{ + if (!_stateDurations) { + self.stateDurations = [NSMutableDictionary dictionary]; + } + return _stateDurations; +} + +#pragma mark - 公共方法 +- (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state +{ + if (images == nil) return; + + self.stateImages[@(state)] = images; + self.stateDurations[@(state)] = @(duration); + + /* 根据图片设置控件的高度 */ + UIImage *image = [images firstObject]; + if (image.size.height > self.mj_h) { + self.mj_h = image.size.height; + } +} + +- (void)setImages:(NSArray *)images forState:(MJRefreshState)state +{ + [self setImages:images duration:images.count * 0.1 forState:state]; +} + +#pragma mark - 实现父类的方法 +- (void)setPullingPercent:(CGFloat)pullingPercent +{ + [super setPullingPercent:pullingPercent]; + NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; + if (self.state != MJRefreshStateIdle || images.count == 0) return; + [self.gifView stopAnimating]; + NSUInteger index = images.count * pullingPercent; + if (index >= images.count) index = images.count - 1; + self.gifView.image = images[index]; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + if (self.gifView.constraints.count) return; + + self.gifView.frame = self.bounds; + if (self.stateLabel.hidden) { + self.gifView.contentMode = UIViewContentModeCenter; + } else { + self.gifView.contentMode = UIViewContentModeRight; + self.gifView.mj_w = self.mj_w * 0.5 - 90; + } +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 根据状态做事情 + if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { + NSArray *images = self.stateImages[@(state)]; + if (images.count == 0) return; + + self.gifView.hidden = NO; + [self.gifView stopAnimating]; + if (images.count == 1) { // 单张图片 + self.gifView.image = [images lastObject]; + } else { // 多张图片 + self.gifView.animationImages = images; + self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; + [self.gifView startAnimating]; + } + } else if (state == MJRefreshStateIdle) { + self.gifView.hidden = NO; + } else if (state == MJRefreshStateNoMoreData) { + self.gifView.hidden = YES; + } +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h new file mode 100644 index 0000000..90e8b77 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h @@ -0,0 +1,15 @@ +// +// MJRefreshBackNormalFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshBackStateFooter.h" + +@interface MJRefreshBackNormalFooter : MJRefreshBackStateFooter +@property (weak, nonatomic, readonly) UIImageView *arrowView; +/** 菊花的样式 */ +@property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m new file mode 100644 index 0000000..4d42de6 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m @@ -0,0 +1,118 @@ +// +// MJRefreshBackNormalFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshBackNormalFooter.h" + +@interface MJRefreshBackNormalFooter() +{ + __unsafe_unretained UIImageView *_arrowView; +} +@property (weak, nonatomic) UIActivityIndicatorView *loadingView; +@end + +@implementation MJRefreshBackNormalFooter +#pragma mark - 懒加载子控件 +- (UIImageView *)arrowView +{ + if (!_arrowView) { + UIImage *image = [UIImage imageNamed:MJRefreshSrcName(@"arrow.png")] ?: [UIImage imageNamed:MJRefreshFrameworkSrcName(@"arrow.png")]; + UIImageView *arrowView = [[UIImageView alloc] initWithImage:image]; + [self addSubview:_arrowView = arrowView]; + } + return _arrowView; +} + + +- (UIActivityIndicatorView *)loadingView +{ + if (!_loadingView) { + UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; + loadingView.hidesWhenStopped = YES; + [self addSubview:_loadingView = loadingView]; + } + return _loadingView; +} + +- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle +{ + _activityIndicatorViewStyle = activityIndicatorViewStyle; + + self.loadingView = nil; + [self setNeedsLayout]; +} +#pragma makr - 重写父类的方法 +- (void)prepare +{ + [super prepare]; + + self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + // 箭头的中心点 + CGFloat arrowCenterX = self.mj_w * 0.5; + if (!self.stateLabel.hidden) { + arrowCenterX -= 100; + } + CGFloat arrowCenterY = self.mj_h * 0.5; + CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); + + // 箭头 + if (self.arrowView.constraints.count == 0) { + self.arrowView.mj_size = self.arrowView.image.size; + self.arrowView.center = arrowCenter; + } + + // 圈圈 + if (self.loadingView.constraints.count == 0) { + self.loadingView.center = arrowCenter; + } +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 根据状态做事情 + if (state == MJRefreshStateIdle) { + if (oldState == MJRefreshStateRefreshing) { + self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); + [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ + self.loadingView.alpha = 0.0; + } completion:^(BOOL finished) { + self.loadingView.alpha = 1.0; + [self.loadingView stopAnimating]; + + self.arrowView.hidden = NO; + }]; + } else { + self.arrowView.hidden = NO; + [self.loadingView stopAnimating]; + [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ + self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); + }]; + } + } else if (state == MJRefreshStatePulling) { + self.arrowView.hidden = NO; + [self.loadingView stopAnimating]; + [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ + self.arrowView.transform = CGAffineTransformIdentity; + }]; + } else if (state == MJRefreshStateRefreshing) { + self.arrowView.hidden = YES; + [self.loadingView startAnimating]; + } else if (state == MJRefreshStateNoMoreData) { + self.arrowView.hidden = YES; + [self.loadingView stopAnimating]; + } +} + +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h new file mode 100644 index 0000000..2d02b2e --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h @@ -0,0 +1,19 @@ +// +// MJRefreshBackStateFooter.h +// MJRefreshExample +// +// Created by MJ Lee on 15/6/13. +// Copyright © 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshBackFooter.h" + +@interface MJRefreshBackStateFooter : MJRefreshBackFooter +/** 显示刷新状态的label */ +@property (weak, nonatomic, readonly) UILabel *stateLabel; +/** 设置state状态下的文字 */ +- (void)setTitle:(NSString *)title forState:(MJRefreshState)state; + +/** 获取state状态下的title */ +- (NSString *)titleForState:(MJRefreshState)state; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m new file mode 100644 index 0000000..ab453d1 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m @@ -0,0 +1,79 @@ +// +// MJRefreshBackStateFooter.m +// MJRefreshExample +// +// Created by MJ Lee on 15/6/13. +// Copyright © 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshBackStateFooter.h" + +@interface MJRefreshBackStateFooter() +{ + /** 显示刷新状态的label */ + __unsafe_unretained UILabel *_stateLabel; +} +/** 所有状态对应的文字 */ +@property (strong, nonatomic) NSMutableDictionary *stateTitles; +@end + +@implementation MJRefreshBackStateFooter +#pragma mark - 懒加载 +- (NSMutableDictionary *)stateTitles +{ + if (!_stateTitles) { + self.stateTitles = [NSMutableDictionary dictionary]; + } + return _stateTitles; +} + +- (UILabel *)stateLabel +{ + if (!_stateLabel) { + [self addSubview:_stateLabel = [UILabel label]]; + } + return _stateLabel; +} + +#pragma mark - 公共方法 +- (void)setTitle:(NSString *)title forState:(MJRefreshState)state +{ + if (title == nil) return; + self.stateTitles[@(state)] = title; + self.stateLabel.text = self.stateTitles[@(self.state)]; +} + +- (NSString *)titleForState:(MJRefreshState)state { + return self.stateTitles[@(state)]; +} + +#pragma mark - 重写父类的方法 +- (void)prepare +{ + [super prepare]; + + // 初始化文字 + [self setTitle:MJRefreshBackFooterIdleText forState:MJRefreshStateIdle]; + [self setTitle:MJRefreshBackFooterPullingText forState:MJRefreshStatePulling]; + [self setTitle:MJRefreshBackFooterRefreshingText forState:MJRefreshStateRefreshing]; + [self setTitle:MJRefreshBackFooterNoMoreDataText forState:MJRefreshStateNoMoreData]; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + if (self.stateLabel.constraints.count) return; + + // 状态标签 + self.stateLabel.frame = self.bounds; +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 设置状态文字 + self.stateLabel.text = self.stateTitles[@(state)]; +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h new file mode 100644 index 0000000..ce3ed42 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.h @@ -0,0 +1,17 @@ +// +// MJRefreshGifHeader.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshStateHeader.h" + +@interface MJRefreshGifHeader : MJRefreshStateHeader +@property (weak, nonatomic, readonly) UIImageView *gifView; + +/** 设置state状态下的动画图片images 动画持续时间duration*/ +- (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state; +- (void)setImages:(NSArray *)images forState:(MJRefreshState)state; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m new file mode 100644 index 0000000..3671d72 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshGifHeader.m @@ -0,0 +1,118 @@ +// +// MJRefreshGifHeader.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshGifHeader.h" + +@interface MJRefreshGifHeader() +{ + __unsafe_unretained UIImageView *_gifView; +} +/** 所有状态对应的动画图片 */ +@property (strong, nonatomic) NSMutableDictionary *stateImages; +/** 所有状态对应的动画时间 */ +@property (strong, nonatomic) NSMutableDictionary *stateDurations; +@end + +@implementation MJRefreshGifHeader +#pragma mark - 懒加载 +- (UIImageView *)gifView +{ + if (!_gifView) { + UIImageView *gifView = [[UIImageView alloc] init]; + [self addSubview:_gifView = gifView]; + } + return _gifView; +} + +- (NSMutableDictionary *)stateImages +{ + if (!_stateImages) { + self.stateImages = [NSMutableDictionary dictionary]; + } + return _stateImages; +} + +- (NSMutableDictionary *)stateDurations +{ + if (!_stateDurations) { + self.stateDurations = [NSMutableDictionary dictionary]; + } + return _stateDurations; +} + +#pragma mark - 公共方法 +- (void)setImages:(NSArray *)images duration:(NSTimeInterval)duration forState:(MJRefreshState)state +{ + if (images == nil) return; + + self.stateImages[@(state)] = images; + self.stateDurations[@(state)] = @(duration); + + /* 根据图片设置控件的高度 */ + UIImage *image = [images firstObject]; + if (image.size.height > self.mj_h) { + self.mj_h = image.size.height; + } +} + +- (void)setImages:(NSArray *)images forState:(MJRefreshState)state +{ + [self setImages:images duration:images.count * 0.1 forState:state]; +} + +#pragma mark - 实现父类的方法 +- (void)setPullingPercent:(CGFloat)pullingPercent +{ + [super setPullingPercent:pullingPercent]; + NSArray *images = self.stateImages[@(MJRefreshStateIdle)]; + if (self.state != MJRefreshStateIdle || images.count == 0) return; + // 停止动画 + [self.gifView stopAnimating]; + // 设置当前需要显示的图片 + NSUInteger index = images.count * pullingPercent; + if (index >= images.count) index = images.count - 1; + self.gifView.image = images[index]; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + if (self.gifView.constraints.count) return; + + self.gifView.frame = self.bounds; + if (self.stateLabel.hidden && self.lastUpdatedTimeLabel.hidden) { + self.gifView.contentMode = UIViewContentModeCenter; + } else { + self.gifView.contentMode = UIViewContentModeRight; + self.gifView.mj_w = self.mj_w * 0.5 - 90; + } +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 根据状态做事情 + if (state == MJRefreshStatePulling || state == MJRefreshStateRefreshing) { + NSArray *images = self.stateImages[@(state)]; + if (images.count == 0) return; + + [self.gifView stopAnimating]; + if (images.count == 1) { // 单张图片 + self.gifView.image = [images lastObject]; + } else { // 多张图片 + self.gifView.animationImages = images; + self.gifView.animationDuration = [self.stateDurations[@(state)] doubleValue]; + [self.gifView startAnimating]; + } + } else if (state == MJRefreshStateIdle) { + [self.gifView stopAnimating]; + } +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h new file mode 100644 index 0000000..547d05e --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.h @@ -0,0 +1,15 @@ +// +// MJRefreshNormalHeader.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshStateHeader.h" + +@interface MJRefreshNormalHeader : MJRefreshStateHeader +@property (weak, nonatomic, readonly) UIImageView *arrowView; +/** 菊花的样式 */ +@property (assign, nonatomic) UIActivityIndicatorViewStyle activityIndicatorViewStyle; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m new file mode 100644 index 0000000..e94e0c0 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshNormalHeader.m @@ -0,0 +1,119 @@ +// +// MJRefreshNormalHeader.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshNormalHeader.h" + +@interface MJRefreshNormalHeader() +{ + __unsafe_unretained UIImageView *_arrowView; +} +@property (weak, nonatomic) UIActivityIndicatorView *loadingView; +@end + +@implementation MJRefreshNormalHeader +#pragma mark - 懒加载子控件 +- (UIImageView *)arrowView +{ + if (!_arrowView) { + UIImage *image = [UIImage imageNamed:MJRefreshSrcName(@"arrow.png")] ?: [UIImage imageNamed:MJRefreshFrameworkSrcName(@"arrow.png")]; + UIImageView *arrowView = [[UIImageView alloc] initWithImage:image]; + [self addSubview:_arrowView = arrowView]; + } + return _arrowView; +} + +- (UIActivityIndicatorView *)loadingView +{ + if (!_loadingView) { + UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorViewStyle]; + loadingView.hidesWhenStopped = YES; + [self addSubview:_loadingView = loadingView]; + } + return _loadingView; +} + +#pragma mark - 公共方法 +- (void)setActivityIndicatorViewStyle:(UIActivityIndicatorViewStyle)activityIndicatorViewStyle +{ + _activityIndicatorViewStyle = activityIndicatorViewStyle; + + self.loadingView = nil; + [self setNeedsLayout]; +} + +#pragma makr - 重写父类的方法 +- (void)prepare +{ + [super prepare]; + + self.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + // 箭头的中心点 + CGFloat arrowCenterX = self.mj_w * 0.5; + if (!self.stateLabel.hidden) { + arrowCenterX -= 100; + } + CGFloat arrowCenterY = self.mj_h * 0.5; + CGPoint arrowCenter = CGPointMake(arrowCenterX, arrowCenterY); + + // 箭头 + if (self.arrowView.constraints.count == 0) { + self.arrowView.mj_size = self.arrowView.image.size; + self.arrowView.center = arrowCenter; + } + + // 圈圈 + if (self.loadingView.constraints.count == 0) { + self.loadingView.center = arrowCenter; + } +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 根据状态做事情 + if (state == MJRefreshStateIdle) { + if (oldState == MJRefreshStateRefreshing) { + self.arrowView.transform = CGAffineTransformIdentity; + + [UIView animateWithDuration:MJRefreshSlowAnimationDuration animations:^{ + self.loadingView.alpha = 0.0; + } completion:^(BOOL finished) { + // 如果执行完动画发现不是idle状态,就直接返回,进入其他状态 + if (self.state != MJRefreshStateIdle) return; + + self.loadingView.alpha = 1.0; + [self.loadingView stopAnimating]; + self.arrowView.hidden = NO; + }]; + } else { + [self.loadingView stopAnimating]; + self.arrowView.hidden = NO; + [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ + self.arrowView.transform = CGAffineTransformIdentity; + }]; + } + } else if (state == MJRefreshStatePulling) { + [self.loadingView stopAnimating]; + self.arrowView.hidden = NO; + [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{ + self.arrowView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI); + }]; + } else if (state == MJRefreshStateRefreshing) { + self.loadingView.alpha = 1.0; // 防止refreshing -> idle的动画完毕动作没有被执行 + [self.loadingView startAnimating]; + self.arrowView.hidden = YES; + } +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h new file mode 100644 index 0000000..5909532 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.h @@ -0,0 +1,23 @@ +// +// MJRefreshStateHeader.h +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshHeader.h" + +@interface MJRefreshStateHeader : MJRefreshHeader +#pragma mark - 刷新时间相关 +/** 利用这个block来决定显示的更新时间文字 */ +@property (copy, nonatomic) NSString *(^lastUpdatedTimeText)(NSDate *lastUpdatedTime); +/** 显示上一次刷新时间的label */ +@property (weak, nonatomic, readonly) UILabel *lastUpdatedTimeLabel; + +#pragma mark - 状态相关 +/** 显示刷新状态的label */ +@property (weak, nonatomic, readonly) UILabel *stateLabel; +/** 设置state状态下的文字 */ +- (void)setTitle:(NSString *)title forState:(MJRefreshState)state; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.m b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.m new file mode 100644 index 0000000..b6cece3 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/Custom/Header/MJRefreshStateHeader.m @@ -0,0 +1,157 @@ +// +// MJRefreshStateHeader.m +// MJRefreshExample +// +// Created by MJ Lee on 15/4/24. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "MJRefreshStateHeader.h" + +@interface MJRefreshStateHeader() +{ + /** 显示上一次刷新时间的label */ + __unsafe_unretained UILabel *_lastUpdatedTimeLabel; + /** 显示刷新状态的label */ + __unsafe_unretained UILabel *_stateLabel; +} +/** 所有状态对应的文字 */ +@property (strong, nonatomic) NSMutableDictionary *stateTitles; +@end + +@implementation MJRefreshStateHeader +#pragma mark - 懒加载 +- (NSMutableDictionary *)stateTitles +{ + if (!_stateTitles) { + self.stateTitles = [NSMutableDictionary dictionary]; + } + return _stateTitles; +} + +- (UILabel *)stateLabel +{ + if (!_stateLabel) { + [self addSubview:_stateLabel = [UILabel label]]; + } + return _stateLabel; +} + +- (UILabel *)lastUpdatedTimeLabel +{ + if (!_lastUpdatedTimeLabel) { + [self addSubview:_lastUpdatedTimeLabel = [UILabel label]]; + } + return _lastUpdatedTimeLabel; +} + +#pragma mark - 公共方法 +- (void)setTitle:(NSString *)title forState:(MJRefreshState)state +{ + if (title == nil) return; + self.stateTitles[@(state)] = title; + self.stateLabel.text = self.stateTitles[@(self.state)]; +} + +#pragma mark - 日历获取在9.x之后的系统使用currentCalendar会出异常。在8.0之后使用系统新API。 +- (NSCalendar *)currentCalendar { + if ([NSCalendar respondsToSelector:@selector(calendarWithIdentifier:)]) { + return [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian]; + } + return [NSCalendar currentCalendar]; +} + +#pragma mark key的处理 +- (void)setLastUpdatedTimeKey:(NSString *)lastUpdatedTimeKey +{ + [super setLastUpdatedTimeKey:lastUpdatedTimeKey]; + + // 如果label隐藏了,就不用再处理 + if (self.lastUpdatedTimeLabel.hidden) return; + + NSDate *lastUpdatedTime = [[NSUserDefaults standardUserDefaults] objectForKey:lastUpdatedTimeKey]; + + // 如果有block + if (self.lastUpdatedTimeText) { + self.lastUpdatedTimeLabel.text = self.lastUpdatedTimeText(lastUpdatedTime); + return; + } + + if (lastUpdatedTime) { + // 1.获得年月日 + NSCalendar *calendar = [self currentCalendar]; + NSUInteger unitFlags = NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay |NSCalendarUnitHour |NSCalendarUnitMinute; + NSDateComponents *cmp1 = [calendar components:unitFlags fromDate:lastUpdatedTime]; + NSDateComponents *cmp2 = [calendar components:unitFlags fromDate:[NSDate date]]; + + // 2.格式化日期 + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + if ([cmp1 day] == [cmp2 day]) { // 今天 + formatter.dateFormat = @"今天 HH:mm"; + } else if ([cmp1 year] == [cmp2 year]) { // 今年 + formatter.dateFormat = @"MM-dd HH:mm"; + } else { + formatter.dateFormat = @"yyyy-MM-dd HH:mm"; + } + NSString *time = [formatter stringFromDate:lastUpdatedTime]; + + // 3.显示日期 + self.lastUpdatedTimeLabel.text = [NSString stringWithFormat:@"最后更新:%@", time]; + } else { + self.lastUpdatedTimeLabel.text = @"最后更新:无记录"; + } +} + +#pragma mark - 覆盖父类的方法 +- (void)prepare +{ + [super prepare]; + + // 初始化文字 + [self setTitle:MJRefreshHeaderIdleText forState:MJRefreshStateIdle]; + [self setTitle:MJRefreshHeaderPullingText forState:MJRefreshStatePulling]; + [self setTitle:MJRefreshHeaderRefreshingText forState:MJRefreshStateRefreshing]; +} + +- (void)placeSubviews +{ + [super placeSubviews]; + + if (self.stateLabel.hidden) return; + + BOOL noConstrainsOnStatusLabel = self.stateLabel.constraints.count == 0; + + if (self.lastUpdatedTimeLabel.hidden) { + // 状态 + if (noConstrainsOnStatusLabel) self.stateLabel.frame = self.bounds; + } else { + CGFloat stateLabelH = self.mj_h * 0.5; + // 状态 + if (noConstrainsOnStatusLabel) { + self.stateLabel.mj_x = 0; + self.stateLabel.mj_y = 0; + self.stateLabel.mj_w = self.mj_w; + self.stateLabel.mj_h = stateLabelH; + } + + // 更新时间 + if (self.lastUpdatedTimeLabel.constraints.count == 0) { + self.lastUpdatedTimeLabel.mj_x = 0; + self.lastUpdatedTimeLabel.mj_y = stateLabelH; + self.lastUpdatedTimeLabel.mj_w = self.mj_w; + self.lastUpdatedTimeLabel.mj_h = self.mj_h - self.lastUpdatedTimeLabel.mj_y; + } + } +} + +- (void)setState:(MJRefreshState)state +{ + MJRefreshCheckState + + // 设置状态文字 + self.stateLabel.text = self.stateTitles[@(state)]; + + // 重新设置key(重新显示时间) + self.lastUpdatedTimeKey = self.lastUpdatedTimeKey; +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png b/KtTableView/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png new file mode 100755 index 0000000..b1078de Binary files /dev/null and b/KtTableView/Pods/MJRefresh/MJRefresh/MJRefresh.bundle/arrow@2x.png differ diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/MJRefresh.h b/KtTableView/Pods/MJRefresh/MJRefresh/MJRefresh.h new file mode 100644 index 0000000..196e6ec --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/MJRefresh.h @@ -0,0 +1,14 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 + +#import "UIScrollView+MJRefresh.h" +#import "UIScrollView+MJExtension.h" +#import "UIView+MJExtension.h" + +#import "MJRefreshNormalHeader.h" +#import "MJRefreshGifHeader.h" + +#import "MJRefreshBackNormalFooter.h" +#import "MJRefreshBackGifFooter.h" +#import "MJRefreshAutoNormalFooter.h" +#import "MJRefreshAutoGifFooter.h" \ No newline at end of file diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/MJRefreshConst.h b/KtTableView/Pods/MJRefresh/MJRefresh/MJRefreshConst.h new file mode 100644 index 0000000..60c5fc1 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/MJRefreshConst.h @@ -0,0 +1,66 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +#import +#import + +// 弱引用 +#define MJWeakSelf __weak typeof(self) weakSelf = self; + +// 日志输出 +#ifdef DEBUG +#define MJRefreshLog(...) NSLog(__VA_ARGS__) +#else +#define MJRefreshLog(...) +#endif + +// 过期提醒 +#define MJRefreshDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead) + +// 运行时objc_msgSend +#define MJRefreshMsgSend(...) ((void (*)(void *, SEL, UIView *))objc_msgSend)(__VA_ARGS__) +#define MJRefreshMsgTarget(target) (__bridge void *)(target) + +// RGB颜色 +#define MJRefreshColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0] + +// 文字颜色 +#define MJRefreshLabelTextColor MJRefreshColor(90, 90, 90) + +// 字体大小 +#define MJRefreshLabelFont [UIFont boldSystemFontOfSize:14] + +// 图片路径 +#define MJRefreshSrcName(file) [@"MJRefresh.bundle" stringByAppendingPathComponent:file] +#define MJRefreshFrameworkSrcName(file) [@"Frameworks/MJRefresh.framework/MJRefresh.bundle" stringByAppendingPathComponent:file] + +// 常量 +UIKIT_EXTERN const CGFloat MJRefreshHeaderHeight; +UIKIT_EXTERN const CGFloat MJRefreshFooterHeight; +UIKIT_EXTERN const CGFloat MJRefreshFastAnimationDuration; +UIKIT_EXTERN const CGFloat MJRefreshSlowAnimationDuration; + +UIKIT_EXTERN NSString *const MJRefreshKeyPathContentOffset; +UIKIT_EXTERN NSString *const MJRefreshKeyPathContentSize; +UIKIT_EXTERN NSString *const MJRefreshKeyPathContentInset; +UIKIT_EXTERN NSString *const MJRefreshKeyPathPanState; + +UIKIT_EXTERN NSString *const MJRefreshHeaderLastUpdatedTimeKey; + +UIKIT_EXTERN NSString *const MJRefreshHeaderIdleText; +UIKIT_EXTERN NSString *const MJRefreshHeaderPullingText; +UIKIT_EXTERN NSString *const MJRefreshHeaderRefreshingText; + +UIKIT_EXTERN NSString *const MJRefreshAutoFooterIdleText; +UIKIT_EXTERN NSString *const MJRefreshAutoFooterRefreshingText; +UIKIT_EXTERN NSString *const MJRefreshAutoFooterNoMoreDataText; + +UIKIT_EXTERN NSString *const MJRefreshBackFooterIdleText; +UIKIT_EXTERN NSString *const MJRefreshBackFooterPullingText; +UIKIT_EXTERN NSString *const MJRefreshBackFooterRefreshingText; +UIKIT_EXTERN NSString *const MJRefreshBackFooterNoMoreDataText; + +// 状态检查 +#define MJRefreshCheckState \ +MJRefreshState oldState = self.state; \ +if (state == oldState) return; \ +[super setState:state]; diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/MJRefreshConst.m b/KtTableView/Pods/MJRefresh/MJRefresh/MJRefreshConst.m new file mode 100644 index 0000000..91e04f3 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/MJRefreshConst.m @@ -0,0 +1,28 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +#import + +const CGFloat MJRefreshHeaderHeight = 54.0; +const CGFloat MJRefreshFooterHeight = 44.0; +const CGFloat MJRefreshFastAnimationDuration = 0.25; +const CGFloat MJRefreshSlowAnimationDuration = 0.4; + +NSString *const MJRefreshKeyPathContentOffset = @"contentOffset"; +NSString *const MJRefreshKeyPathContentInset = @"contentInset"; +NSString *const MJRefreshKeyPathContentSize = @"contentSize"; +NSString *const MJRefreshKeyPathPanState = @"state"; + +NSString *const MJRefreshHeaderLastUpdatedTimeKey = @"MJRefreshHeaderLastUpdatedTimeKey"; + +NSString *const MJRefreshHeaderIdleText = @"下拉可以刷新"; +NSString *const MJRefreshHeaderPullingText = @"松开立即刷新"; +NSString *const MJRefreshHeaderRefreshingText = @"正在刷新数据中..."; + +NSString *const MJRefreshAutoFooterIdleText = @"点击或上拉加载更多"; +NSString *const MJRefreshAutoFooterRefreshingText = @"正在加载更多的数据..."; +NSString *const MJRefreshAutoFooterNoMoreDataText = @"已经全部加载完毕"; + +NSString *const MJRefreshBackFooterIdleText = @"上拉可以加载更多"; +NSString *const MJRefreshBackFooterPullingText = @"松开立即加载更多"; +NSString *const MJRefreshBackFooterRefreshingText = @"正在加载更多的数据..."; +NSString *const MJRefreshBackFooterNoMoreDataText = @"已经全部加载完毕"; \ No newline at end of file diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.h b/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.h new file mode 100644 index 0000000..734110f --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.h @@ -0,0 +1,23 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// UIScrollView+Extension.h +// MJRefreshExample +// +// Created by MJ Lee on 14-5-28. +// Copyright (c) 2014年 小码哥. All rights reserved. +// + +#import + +@interface UIScrollView (MJExtension) +@property (assign, nonatomic) CGFloat mj_insetT; +@property (assign, nonatomic) CGFloat mj_insetB; +@property (assign, nonatomic) CGFloat mj_insetL; +@property (assign, nonatomic) CGFloat mj_insetR; + +@property (assign, nonatomic) CGFloat mj_offsetX; +@property (assign, nonatomic) CGFloat mj_offsetY; + +@property (assign, nonatomic) CGFloat mj_contentW; +@property (assign, nonatomic) CGFloat mj_contentH; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.m b/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.m new file mode 100644 index 0000000..6a13f5f --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJExtension.m @@ -0,0 +1,110 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// UIScrollView+Extension.m +// MJRefreshExample +// +// Created by MJ Lee on 14-5-28. +// Copyright (c) 2014年 小码哥. All rights reserved. +// + +#import "UIScrollView+MJExtension.h" +#import + +@implementation UIScrollView (MJExtension) + +- (void)setMj_insetT:(CGFloat)mj_insetT +{ + UIEdgeInsets inset = self.contentInset; + inset.top = mj_insetT; + self.contentInset = inset; +} + +- (CGFloat)mj_insetT +{ + return self.contentInset.top; +} + +- (void)setMj_insetB:(CGFloat)mj_insetB +{ + UIEdgeInsets inset = self.contentInset; + inset.bottom = mj_insetB; + self.contentInset = inset; +} + +- (CGFloat)mj_insetB +{ + return self.contentInset.bottom; +} + +- (void)setMj_insetL:(CGFloat)mj_insetL +{ + UIEdgeInsets inset = self.contentInset; + inset.left = mj_insetL; + self.contentInset = inset; +} + +- (CGFloat)mj_insetL +{ + return self.contentInset.left; +} + +- (void)setMj_insetR:(CGFloat)mj_insetR +{ + UIEdgeInsets inset = self.contentInset; + inset.right = mj_insetR; + self.contentInset = inset; +} + +- (CGFloat)mj_insetR +{ + return self.contentInset.right; +} + +- (void)setMj_offsetX:(CGFloat)mj_offsetX +{ + CGPoint offset = self.contentOffset; + offset.x = mj_offsetX; + self.contentOffset = offset; +} + +- (CGFloat)mj_offsetX +{ + return self.contentOffset.x; +} + +- (void)setMj_offsetY:(CGFloat)mj_offsetY +{ + CGPoint offset = self.contentOffset; + offset.y = mj_offsetY; + self.contentOffset = offset; +} + +- (CGFloat)mj_offsetY +{ + return self.contentOffset.y; +} + +- (void)setMj_contentW:(CGFloat)mj_contentW +{ + CGSize size = self.contentSize; + size.width = mj_contentW; + self.contentSize = size; +} + +- (CGFloat)mj_contentW +{ + return self.contentSize.width; +} + +- (void)setMj_contentH:(CGFloat)mj_contentH +{ + CGSize size = self.contentSize; + size.height = mj_contentH; + self.contentSize = size; +} + +- (CGFloat)mj_contentH +{ + return self.contentSize.height; +} +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.h b/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.h new file mode 100644 index 0000000..17d4715 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.h @@ -0,0 +1,26 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// UIScrollView+MJRefresh.h +// MJRefreshExample +// +// Created by MJ Lee on 15/3/4. +// Copyright (c) 2015年 小码哥. All rights reserved. +// 给ScrollView增加下拉刷新、上拉刷新的功能 + +#import +#import "MJRefreshConst.h" + +@class MJRefreshHeader, MJRefreshFooter; + +@interface UIScrollView (MJRefresh) +/** 下拉刷新控件 */ +@property (strong, nonatomic) MJRefreshHeader *mj_header; +@property (strong, nonatomic) MJRefreshHeader *header MJRefreshDeprecated("使用mj_header"); +/** 上拉刷新控件 */ +@property (strong, nonatomic) MJRefreshFooter *mj_footer; +@property (strong, nonatomic) MJRefreshFooter *footer MJRefreshDeprecated("使用mj_footer"); + +#pragma mark - other +- (NSInteger)mj_totalDataCount; +@property (copy, nonatomic) void (^mj_reloadDataBlock)(NSInteger totalDataCount); +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.m b/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.m new file mode 100644 index 0000000..635022f --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/UIScrollView+MJRefresh.m @@ -0,0 +1,163 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// UIScrollView+MJRefresh.m +// MJRefreshExample +// +// Created by MJ Lee on 15/3/4. +// Copyright (c) 2015年 小码哥. All rights reserved. +// + +#import "UIScrollView+MJRefresh.h" +#import "MJRefreshHeader.h" +#import "MJRefreshFooter.h" +#import + +@implementation NSObject (MJRefresh) + ++ (void)exchangeInstanceMethod1:(SEL)method1 method2:(SEL)method2 +{ + method_exchangeImplementations(class_getInstanceMethod(self, method1), class_getInstanceMethod(self, method2)); +} + ++ (void)exchangeClassMethod1:(SEL)method1 method2:(SEL)method2 +{ + method_exchangeImplementations(class_getClassMethod(self, method1), class_getClassMethod(self, method2)); +} + +@end + +@implementation UIScrollView (MJRefresh) + +#pragma mark - header +static const char MJRefreshHeaderKey = '\0'; +- (void)setMj_header:(MJRefreshHeader *)mj_header +{ + if (mj_header != self.mj_header) { + // 删除旧的,添加新的 + [self.mj_header removeFromSuperview]; + [self insertSubview:mj_header atIndex:0]; + + // 存储新的 + [self willChangeValueForKey:@"mj_header"]; // KVO + objc_setAssociatedObject(self, &MJRefreshHeaderKey, + mj_header, OBJC_ASSOCIATION_ASSIGN); + [self didChangeValueForKey:@"mj_header"]; // KVO + } +} + +- (MJRefreshHeader *)mj_header +{ + return objc_getAssociatedObject(self, &MJRefreshHeaderKey); +} + +#pragma mark - footer +static const char MJRefreshFooterKey = '\0'; +- (void)setMj_footer:(MJRefreshFooter *)mj_footer +{ + if (mj_footer != self.mj_footer) { + // 删除旧的,添加新的 + [self.mj_footer removeFromSuperview]; + [self addSubview:mj_footer]; + + // 存储新的 + [self willChangeValueForKey:@"mj_footer"]; // KVO + objc_setAssociatedObject(self, &MJRefreshFooterKey, + mj_footer, OBJC_ASSOCIATION_ASSIGN); + [self didChangeValueForKey:@"mj_footer"]; // KVO + } +} + +- (MJRefreshFooter *)mj_footer +{ + return objc_getAssociatedObject(self, &MJRefreshFooterKey); +} + +#pragma mark - 过期 +- (void)setFooter:(MJRefreshFooter *)footer +{ + self.mj_footer = footer; +} + +- (MJRefreshFooter *)footer +{ + return self.mj_footer; +} + +- (void)setHeader:(MJRefreshHeader *)header +{ + self.mj_header = header; +} + +- (MJRefreshHeader *)header +{ + return self.mj_header; +} + +#pragma mark - other +- (NSInteger)mj_totalDataCount +{ + NSInteger totalCount = 0; + if ([self isKindOfClass:[UITableView class]]) { + UITableView *tableView = (UITableView *)self; + + for (NSInteger section = 0; section + +@interface UIView (MJExtension) +@property (assign, nonatomic) CGFloat mj_x; +@property (assign, nonatomic) CGFloat mj_y; +@property (assign, nonatomic) CGFloat mj_w; +@property (assign, nonatomic) CGFloat mj_h; +@property (assign, nonatomic) CGSize mj_size; +@property (assign, nonatomic) CGPoint mj_origin; +@end diff --git a/KtTableView/Pods/MJRefresh/MJRefresh/UIView+MJExtension.m b/KtTableView/Pods/MJRefresh/MJRefresh/UIView+MJExtension.m new file mode 100644 index 0000000..7e8eda2 --- /dev/null +++ b/KtTableView/Pods/MJRefresh/MJRefresh/UIView+MJExtension.m @@ -0,0 +1,84 @@ +// 代码地址: https://github.com/CoderMJLee/MJRefresh +// 代码地址: http://code4app.com/ios/%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90%E4%B8%8B%E6%8B%89%E4%B8%8A%E6%8B%89%E5%88%B7%E6%96%B0/52326ce26803fabc46000000 +// UIView+Extension.m +// MJRefreshExample +// +// Created by MJ Lee on 14-5-28. +// Copyright (c) 2014年 小码哥. All rights reserved. +// + +#import "UIView+MJExtension.h" + +@implementation UIView (MJExtension) +- (void)setMj_x:(CGFloat)mj_x +{ + CGRect frame = self.frame; + frame.origin.x = mj_x; + self.frame = frame; +} + +- (CGFloat)mj_x +{ + return self.frame.origin.x; +} + +- (void)setMj_y:(CGFloat)mj_y +{ + CGRect frame = self.frame; + frame.origin.y = mj_y; + self.frame = frame; +} + +- (CGFloat)mj_y +{ + return self.frame.origin.y; +} + +- (void)setMj_w:(CGFloat)mj_w +{ + CGRect frame = self.frame; + frame.size.width = mj_w; + self.frame = frame; +} + +- (CGFloat)mj_w +{ + return self.frame.size.width; +} + +- (void)setMj_h:(CGFloat)mj_h +{ + CGRect frame = self.frame; + frame.size.height = mj_h; + self.frame = frame; +} + +- (CGFloat)mj_h +{ + return self.frame.size.height; +} + +- (void)setMj_size:(CGSize)mj_size +{ + CGRect frame = self.frame; + frame.size = mj_size; + self.frame = frame; +} + +- (CGSize)mj_size +{ + return self.frame.size; +} + +- (void)setMj_origin:(CGPoint)mj_origin +{ + CGRect frame = self.frame; + frame.origin = mj_origin; + self.frame = frame; +} + +- (CGPoint)mj_origin +{ + return self.frame.origin; +} +@end diff --git a/KtTableView/Pods/MJRefresh/README.md b/KtTableView/Pods/MJRefresh/README.md new file mode 100644 index 0000000..88ac1fd --- /dev/null +++ b/KtTableView/Pods/MJRefresh/README.md @@ -0,0 +1,358 @@ +![(logo)](http://images.cnitblog.com/blog2015/497279/201505/051004492043385.png) +## MJRefresh +* An easy way to use pull-to-refresh +* 用法简单的下拉刷新框架:一行代码搞定 + +## Contents +* Getting Started + * [Features【支持哪些控件的刷新】](#支持哪些控件的刷新) + * [Installation【如何使用MJRefresh】](#如何使用MJRefresh) + * [Who's using【已经超过上百个App正在使用MJRefresh】](#已经超过上百个App正在使用MJRefresh) + * [Classes【MJRefresh类结构图】](#MJRefresh类结构图) +* 常见API + * [MJRefreshComponent.h](#MJRefreshComponent.h) + * [MJRefreshHeader.h](#MJRefreshHeader.h) + * [MJRefreshFooter.h](#MJRefreshFooter.h) + * [MJRefreshAutoFooter.h](#MJRefreshAutoFooter.h) +* Examples + * [Reference【参考】](#参考) + * [下拉刷新01-默认](#下拉刷新01-默认) + * [下拉刷新02-动画图片](#下拉刷新02-动画图片) + * [下拉刷新03-隐藏时间](#下拉刷新03-隐藏时间) + * [下拉刷新04-隐藏状态和时间](#下拉刷新04-隐藏状态和时间) + * [下拉刷新05-自定义文字](#下拉刷新05-自定义文字) + * [下拉刷新06-自定义刷新控件](#下拉刷新06-自定义刷新控件) + * [上拉刷新01-默认](#上拉刷新01-默认) + * [上拉刷新02-动画图片](#上拉刷新02-动画图片) + * [上拉刷新03-隐藏刷新状态的文字](#上拉刷新03-隐藏刷新状态的文字) + * [上拉刷新04-全部加载完毕](#上拉刷新04-全部加载完毕) + * [上拉刷新05-自定义文字](#上拉刷新05-自定义文字) + * [上拉刷新06-加载后隐藏](#上拉刷新06-加载后隐藏) + * [上拉刷新07-自动回弹的上拉01](#上拉刷新07-自动回弹的上拉01) + * [上拉刷新08-自动回弹的上拉02](#上拉刷新08-自动回弹的上拉02) + * [上拉刷新09-自定义刷新控件(自动刷新)](#上拉刷新09-自定义刷新控件(自动刷新)) + * [上拉刷新10-自定义刷新控件(自动回弹)](#上拉刷新10-自定义刷新控件(自动回弹)) + * [UICollectionView01-上下拉刷新](#UICollectionView01-上下拉刷新) + * [UIWebView01-下拉刷新](#UIWebView01-下拉刷新) +* [期待](#期待) + +## 支持哪些控件的刷新 +* `UIScrollView`、`UITableView`、`UICollectionView`、`UIWebView` + +## 如何使用MJRefresh +* cocoapods导入:`pod 'MJRefresh'` +* 手动导入: + * 将`MJRefresh`文件夹中的所有文件拽入项目中 + * 导入主头文件:`#import "MJRefresh.h"` + +```objc +Base Custom +MJRefresh.bundle MJRefresh.h +MJRefreshConst.h MJRefreshConst.m +UIScrollView+MJExtension.h UIScrollView+MJExtension.m +UIScrollView+MJRefresh.h UIScrollView+MJRefresh.m +UIView+MJExtension.h UIView+MJExtension.m +``` + +## 已经超过上百个App正在使用MJRefresh + +* 更多App信息可以关注:[M了个J-博客园](http://www.cnblogs.com/mjios/p/4409853.html) + +## MJRefresh类结构图 +![](http://images0.cnblogs.com/blog2015/497279/201506/132232456139177.png) +- 图中`红色文字的类`:可以直接拿来用 + - 下拉刷新控件的种类 + - 默认(Normal):`MJRefreshNormalHeader` + - 动图(Gif):`MJRefreshGifHeader` + - 上拉刷新控件的种类 + - 自动刷新(Auto) + - 默认(Normal):`MJRefreshAutoNormalFooter` + - 动图(Gif):`MJRefreshAutoGifFooter` + - 自动回弹(Back) + - 默认(Normal):`MJRefreshBackNormalFooter` + - 动图(Gif):`MJRefreshBackGifFooter` +- 图中`非红色文字的类`:拿来继承,用于自定义刷新控件 +- 关于如何自定义刷新控件,可以参考下图的类
+ + +## MJRefreshComponent.h +```objc +/** 刷新控件的基类 */ +@interface MJRefreshComponent : UIView +#pragma mark - 刷新状态控制 +/** 进入刷新状态 */ +- (void)beginRefreshing; +/** 结束刷新状态 */ +- (void)endRefreshing; +/** 是否正在刷新 */ +- (BOOL)isRefreshing; + +#pragma mark - 其他 +/** 根据拖拽比例自动切换透明度 */ +@property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha; +@end +``` + +## MJRefreshHeader.h +```objc +@interface MJRefreshHeader : MJRefreshComponent +/** 创建header */ ++ (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; +/** 创建header */ ++ (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; + +/** 这个key用来存储上一次下拉刷新成功的时间 */ +@property (copy, nonatomic) NSString *lastUpdatedTimeKey; +/** 上一次下拉刷新成功的时间 */ +@property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; + +/** 忽略多少scrollView的contentInset的top */ +@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop; +@end +``` + +## MJRefreshFooter.h +```objc +@interface MJRefreshFooter : MJRefreshComponent +/** 创建footer */ ++ (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock; +/** 创建footer */ ++ (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; + +/** 提示没有更多的数据 */ +- (void)endRefreshingWithNoMoreData; +/** 重置没有更多的数据(消除没有更多数据的状态) */ +- (void)resetNoMoreData; + +/** 忽略多少scrollView的contentInset的bottom */ +@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; + +/** 自动根据有无数据来显示和隐藏(有数据就显示,没有数据隐藏) */ +@property (assign, nonatomic) BOOL automaticallyHidden; +@end +``` + +## MJRefreshAutoFooter.h +```objc +@interface MJRefreshAutoFooter : MJRefreshFooter +/** 是否自动刷新(默认为YES) */ +@property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; + +/** 当底部控件出现多少时就自动刷新(默认为1.0,也就是底部控件完全出现时,才会自动刷新) */ +@property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent; +@end +``` + +## 参考 +```objc +* 由于这个框架的功能较多,就不写具体文字描述其用法 +* 大家可以直接参考示例中的MJTableViewController、MJCollectionViewController、MJWebViewController,更为直观快速 +``` + + +## 下拉刷新01-默认 +```objc +self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ + // 进入刷新状态后会自动调用这个block +}]; +或 +// 设置回调(一旦进入刷新状态,就调用target的action,也就是调用self的loadNewData方法) +self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; + +// 马上进入刷新状态 +[self.tableView.header beginRefreshing]; +``` +![(下拉刷新01-普通)](http://images0.cnblogs.com/blog2015/497279/201506/141204343486151.gif) + +## 下拉刷新02-动画图片 +```objc +// 设置回调(一旦进入刷新状态,就调用target的action,也就是调用self的loadNewData方法) +MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; +// 设置普通状态的动画图片 +[header setImages:idleImages forState:MJRefreshStateIdle]; +// 设置即将刷新状态的动画图片(一松开就会刷新的状态) +[header setImages:pullingImages forState:MJRefreshStatePulling]; +// 设置正在刷新状态的动画图片 +[header setImages:refreshingImages forState:MJRefreshStateRefreshing]; +// 设置header +self.tableView.mj_header = header; +``` +![(下拉刷新02-动画图片)](http://images0.cnblogs.com/blog2015/497279/201506/141204402238389.gif) + +## 下拉刷新03-隐藏时间 +```objc +// 隐藏时间 +header.lastUpdatedTimeLabel.hidden = YES; +``` +![(下拉刷新03-隐藏时间)](http://images0.cnblogs.com/blog2015/497279/201506/141204456132944.gif) + +## 下拉刷新04-隐藏状态和时间 +```objc +// 隐藏时间 +header.lastUpdatedTimeLabel.hidden = YES; + +// 隐藏状态 +header.stateLabel.hidden = YES; +``` +![(下拉刷新04-隐藏状态和时间0)](http://images0.cnblogs.com/blog2015/497279/201506/141204508639539.gif) + +## 下拉刷新05-自定义文字 +```objc +// 设置文字 +[header setTitle:@"Pull down to refresh" forState:MJRefreshStateIdle]; +[header setTitle:@"Release to refresh" forState:MJRefreshStatePulling]; +[header setTitle:@"Loading ..." forState:MJRefreshStateRefreshing]; + +// 设置字体 +header.stateLabel.font = [UIFont systemFontOfSize:15]; +header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:14]; + +// 设置颜色 +header.stateLabel.textColor = [UIColor redColor]; +header.lastUpdatedTimeLabel.textColor = [UIColor blueColor]; +``` +![(下拉刷新05-自定义文字)](http://images0.cnblogs.com/blog2015/497279/201506/141204563633593.gif) + +## 下拉刷新06-自定义刷新控件 +```objc +self.tableView.mj_header = [MJDIYHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; +// 具体实现参考MJDIYHeader.h和MJDIYHeader.m +``` +![(下拉刷新06-自定义刷新控件)](http://images0.cnblogs.com/blog2015/497279/201506/141205019261159.gif) + +## 上拉刷新01-默认 +```objc +self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ + // 进入刷新状态后会自动调用这个block +}]; +或 +// 设置回调(一旦进入刷新状态,就调用target的action,也就是调用self的loadMoreData方法) +self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; +``` +![(上拉刷新01-默认)](http://images0.cnblogs.com/blog2015/497279/201506/141205090047696.gif) + +## 上拉刷新02-动画图片 +```objc +// 设置回调(一旦进入刷新状态,就调用target的action,也就是调用self的loadMoreData方法) +MJRefreshAutoGifFooter *footer = [MJRefreshAutoGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; + +// 设置刷新图片 +[footer setImages:refreshingImages forState:MJRefreshStateRefreshing]; + +// 设置尾部 +self.tableView.mj_footer = footer; +``` +![(上拉刷新02-动画图片)](http://images0.cnblogs.com/blog2015/497279/201506/141205141445793.gif) + +## 上拉刷新03-隐藏刷新状态的文字 +```objc +// 隐藏刷新状态的文字 +footer.refreshingTitleHidden = YES; +// 如果没有上面的方法,就用footer.stateLabel.hidden = YES; +``` +![(上拉刷新03-隐藏刷新状态的文字)](http://images0.cnblogs.com/blog2015/497279/201506/141205200985774.gif) + +## 上拉刷新04-全部加载完毕 +```objc +// 变为没有更多数据的状态 +[footer endRefreshingWithNoMoreData]; +``` +![(上拉刷新04-全部加载完毕)](http://images0.cnblogs.com/blog2015/497279/201506/141205248634686.gif) + +## 上拉刷新05-自定义文字 +```objc +// 设置文字 +[footer setTitle:@"Click or drag up to refresh" forState:MJRefreshStateIdle]; +[footer setTitle:@"Loading more ..." forState:MJRefreshStateRefreshing]; +[footer setTitle:@"No more data" forState:MJRefreshStateNoMoreData]; + +// 设置字体 +footer.stateLabel.font = [UIFont systemFontOfSize:17]; + +// 设置颜色 +footer.stateLabel.textColor = [UIColor blueColor]; +``` +![(上拉刷新05-自定义文字)](http://images0.cnblogs.com/blog2015/497279/201506/141205295511153.gif) + +## 上拉刷新06-加载后隐藏 +```objc +// 隐藏当前的上拉刷新控件 +self.tableView.mj_footer.hidden = YES; +``` +![(上拉刷新06-加载后隐藏)](http://images0.cnblogs.com/blog2015/497279/201506/141205343481821.gif) + +## 上拉刷新07-自动回弹的上拉01 +```objc +self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; +``` +![(上拉刷新07-自动回弹的上拉01)](http://images0.cnblogs.com/blog2015/497279/201506/141205392239231.gif) + +## 上拉刷新08-自动回弹的上拉02 +```objc +MJRefreshBackGifFooter *footer = [MJRefreshBackGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; + +// 设置普通状态的动画图片 +[footer setImages:idleImages forState:MJRefreshStateIdle]; +// 设置即将刷新状态的动画图片(一松开就会刷新的状态) +[footer setImages:pullingImages forState:MJRefreshStatePulling]; +// 设置正在刷新状态的动画图片 +[footer setImages:refreshingImages forState:MJRefreshStateRefreshing]; + +// 设置尾部 +self.tableView.mj_footer = footer; +``` +![(上拉刷新07-自动回弹的上拉02)](http://images0.cnblogs.com/blog2015/497279/201506/141205441443628.gif) + +## 上拉刷新09-自定义刷新控件(自动刷新) +```objc +self.tableView.mj_footer = [MJDIYAutoFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; +// 具体实现参考MJDIYAutoFooter.h和MJDIYAutoFooter.m +``` +![(上拉刷新09-自定义刷新控件(自动刷新))](http://images0.cnblogs.com/blog2015/497279/201506/141205500195866.gif) + +## 上拉刷新10-自定义刷新控件(自动回弹) +```objc +self.tableView.mj_footer = [MJDIYBackFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; +// 具体实现参考MJDIYBackFooter.h和MJDIYBackFooter.m +``` +![(上拉刷新10-自定义刷新控件(自动回弹))](http://images0.cnblogs.com/blog2015/497279/201506/141205560666819.gif) + +## UICollectionView01-上下拉刷新 +```objc +// 下拉刷新 +self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ + // 进入刷新状态后会自动调用这个block +}]; + +// 上拉刷新 +self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{ + // 进入刷新状态后会自动调用这个block +}]; +``` +![(UICollectionView01-上下拉刷新)](http://images0.cnblogs.com/blog2015/497279/201506/141206021603758.gif) + +## UIWebView01-下拉刷新 +```objc +// 添加下拉刷新控件 +self.webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ + // 进入刷新状态后会自动调用这个block +}]; +``` +![(UICollectionView01-上下拉刷新)](http://images0.cnblogs.com/blog2015/497279/201506/141206080514524.gif) + +## 提醒 +* 本框架纯ARC,兼容的系统>=iOS6.0、iPhone\iPad横竖屏 + +## 期待 +* 如果在使用过程中遇到BUG,希望你能Issues我,谢谢(或者尝试下载最新的框架代码看看BUG修复没有) +* 如果在使用过程中发现功能不够用,希望你能Issues我,我非常想为这个框架增加更多好用的功能,谢谢 +* 如果你想为MJRefresh输出代码,请拼命Pull Requests我 +* 如果你开发的应用中用到了MJRefresh,希望你能到[CocoaControls](https://www.cocoacontrols.com/controls/mjrefresh)添加你应用的iTunes路径,我将会安装使用你的应用,并且根据众多应用的使用情况,对MJRefresh进行一个更好的设计和完善,提供更多好用的功能,谢谢 + * 步骤01(微信是举个例子,百度“你的应用名称 itunes”) +![(step01)](http://ww4.sinaimg.cn/mw1024/800cdf9ctw1eq0viiv5rsj20sm0ea41t.jpg) + * 步骤02 +![(step02)](http://ww2.sinaimg.cn/mw1024/800cdf9ctw1eq0vilejxlj20tu0me7a0.jpg) + * 步骤03 +![(step03)](http://ww1.sinaimg.cn/mw1024/800cdf9ctw1eq0viocpo5j20wc0dc0un.jpg) + * 步骤04 +![(step04)](http://ww3.sinaimg.cn/mw1024/800cdf9ctw1eq0vir137xj20si0gewgu.jpg) diff --git a/KtTableView/Pods/Manifest.lock b/KtTableView/Pods/Manifest.lock new file mode 100644 index 0000000..fac681a --- /dev/null +++ b/KtTableView/Pods/Manifest.lock @@ -0,0 +1,27 @@ +PODS: + - AFNetworking (3.1.0): + - AFNetworking/NSURLSession (= 3.1.0) + - AFNetworking/Reachability (= 3.1.0) + - AFNetworking/Security (= 3.1.0) + - AFNetworking/Serialization (= 3.1.0) + - AFNetworking/UIKit (= 3.1.0) + - AFNetworking/NSURLSession (3.1.0): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (3.1.0) + - AFNetworking/Security (3.1.0) + - AFNetworking/Serialization (3.1.0) + - AFNetworking/UIKit (3.1.0): + - AFNetworking/NSURLSession + - MJRefresh (3.1.0) + +DEPENDENCIES: + - AFNetworking (~> 3.0) + - MJRefresh + +SPEC CHECKSUMS: + AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 + MJRefresh: 743e6404967d1c2c688472ea3ecfde247d872db4 + +COCOAPODS: 0.39.0 diff --git a/KtTableView/Pods/Pods.xcodeproj/project.pbxproj b/KtTableView/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..6f2b77d --- /dev/null +++ b/KtTableView/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,3256 @@ + + + + + archiveVersion + 1 + classes + + objectVersion + 46 + objects + + 000D07DC2737A4648E1CD9D2D1294CBF + + children + + 0FF2C40B2066C078D66B8C5479DA89F8 + 1548803AE5D9CADA5820DB1612E34E11 + 8F6775452919B948C627BD12821F0D28 + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/MJRefresh + sourceTree + <group> + + 00F09DB5E05D1208F27161E2F016FE36 + + fileRef + C2B240D99C3FC6A7DC6C66A2434CA799 + isa + PBXBuildFile + + 022B549F10007177A43FAB1DD5114F7D + + fileRef + A19DF616941A51576DD057A9FD8F4AD8 + isa + PBXBuildFile + + 037C0CA694176A3C0915F62C9D20B3E6 + + children + + B3D1D13E0C6553800746CB8FD61CF946 + + isa + PBXGroup + name + Targets Support Files + sourceTree + <group> + + 06368923FB85F3210C47762DB41DDC44 + + explicitFileType + archive.ar + includeInIndex + 0 + isa + PBXFileReference + name + libAFNetworking.a + path + libAFNetworking.a + sourceTree + BUILT_PRODUCTS_DIR + + 073DD9349F6203BB682696DE215CED6B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshStateHeader.h + path + MJRefresh/Custom/Header/MJRefreshStateHeader.h + sourceTree + <group> + + 08802A6DF042F6CA833289403FF4F4A4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIView+MJExtension.m + path + MJRefresh/UIView+MJExtension.m + sourceTree + <group> + + 09D04A9AB71B5A4FE9175F80496EA5FD + + fileRef + 2E781167DFE2565306F953E0F8F217E7 + isa + PBXBuildFile + + 0A08FC71C4E3B8E0F8734BCDA7CCA7CB + + fileRef + 8E65D8BB285E4B1873D24CEF9CE89752 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 0B678E4E7D716E2C6EC64BDB96418C7E + + buildActionMask + 2147483647 + files + + D054768D94E678B8A0D7F2AB4FF45E54 + FF1FEB28260D52C222E2F87FBBC05277 + EFCDCCD66269CA908494B11E024DC736 + 9BF8D708AC9892125B0AA4E540361FF8 + C66A994F14BA080776BB3E2AD8CC55B4 + B5A8A60810B99D763E3A3F076F63509D + 6CF9B693754B004AD7FB2F8A6C0C8F36 + 6E80858B842657D04234289E938017AC + F58455418F190BC37D1FD19EA3EA5B01 + F432A374A040EBAB69C9EABC6C4D699A + F7B852F0917A6D6540DAB54F736D681B + 44F50504254959A81B2E96AD6261B2A9 + D595C17C62C58E80EEC6F9EBCCF4050A + EA03AF12E0E3E8ADC50DA70F2C5BF39E + C67F32FF951D1979EF0E6B4ADED5E8A8 + 444602F3A422E5EC1DA8EF2A3DFA01EB + B9B44F1EDC36C095666CA0AE98371C09 + 904EC3379A9E226064CB03DC1ACA2EEA + 77F797A5A72065EE7351CF41728C2EC3 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 0EB5E89BB17510AE9D4971A42147A390 + + baseConfigurationReference + 321E66BDB33DD3AC0111552889CE84F5 + buildSettings + + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/AFNetworking/AFNetworking-prefix.pch + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PRIVATE_HEADERS_FOLDER_PATH + + PRODUCT_NAME + $(TARGET_NAME) + PUBLIC_HEADERS_FOLDER_PATH + + SDKROOT + iphoneos + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Release + + 0F178FF4DA6AF2436D12F0D491C847BA + + children + + 136783F7D841600FCC96701D3AF638D1 + E1902FB573FD0FD999974D15601ED37A + + isa + PBXGroup + name + Pods + sourceTree + <group> + + 0FF2C40B2066C078D66B8C5479DA89F8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + MJRefresh.xcconfig + sourceTree + <group> + + 10834806BD7B412BC24F347361FA2C8E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Pods-acknowledgements.plist + sourceTree + <group> + + 10C32B6063CB8FCC7AA7C232A3EC1968 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshNormalHeader.m + path + MJRefresh/Custom/Header/MJRefreshNormalHeader.m + sourceTree + <group> + + 1100B0258FA1D8A45F1FABF12E8DCB46 + + isa + PBXTargetDependency + name + AFNetworking + target + 928353533005A4198EBDA5B700D37B64 + targetProxy + E2696D9ECE420BE07FC8D60746BE0326 + + 1113E422399B9F02C00AD2082D74F1C8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshAutoFooter.m + path + MJRefresh/Base/MJRefreshAutoFooter.m + sourceTree + <group> + + 12B7B28C4B02173D4DCDA6E555A4A295 + + children + + 3816E2DBB35FD18D7D736AB2C25A562F + 500F05087AC46188E8C6433011404026 + 8EA8E5C91690482F098D171648ACB518 + 6C89DAAC7551D8A93F0B9D10042DD1D4 + + isa + PBXGroup + name + Serialization + sourceTree + <group> + + 133B30495D945B737235B107AAE7DAAB + + fileRef + 4B5E09720919B968FDE1AE5A31E5601D + isa + PBXBuildFile + + 136783F7D841600FCC96701D3AF638D1 + + children + + 8E65D8BB285E4B1873D24CEF9CE89752 + 57907B8276E9F629BE2F7CDB39E5C9B5 + 8582AABBE144740D377D61891ADFC1A6 + D0E21F6081D751169836C6324483CA69 + 12B7B28C4B02173D4DCDA6E555A4A295 + D96F2710D78051BBE8A22541FCB1D871 + A991D45DDE7457BFED68BEEC5786C519 + + isa + PBXGroup + name + AFNetworking + path + AFNetworking + sourceTree + <group> + + 13966E5B637944E1DE3144EF3CAF0FC4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFNetworkActivityIndicatorManager.h + path + UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h + sourceTree + <group> + + 1456D0651D05838A6AA7338F8F0DD470 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshFooter.h + path + MJRefresh/Base/MJRefreshFooter.h + sourceTree + <group> + + 14CD3DFB4A25BAEFB205730FA6750025 + + fileRef + 28187854DC01618EEE9C133AAE81347B + isa + PBXBuildFile + + 14D4CFD102AA79373F35EA51B06E3C7D + + explicitFileType + archive.ar + includeInIndex + 0 + isa + PBXFileReference + name + libMJRefresh.a + path + libMJRefresh.a + sourceTree + BUILT_PRODUCTS_DIR + + 15460ABD372C937E2A07A2FCDF98C473 + + fileRef + D6D5BE0EB66BDB0CCFB75F9C14F387BF + isa + PBXBuildFile + + 1548803AE5D9CADA5820DB1612E34E11 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + MJRefresh-dummy.m + sourceTree + <group> + + 162B149B0DD54501D7C75154E5B604EE + + baseConfigurationReference + 321E66BDB33DD3AC0111552889CE84F5 + buildSettings + + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/AFNetworking/AFNetworking-prefix.pch + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + MTL_ENABLE_DEBUG_INFO + YES + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PRIVATE_HEADERS_FOLDER_PATH + + PRODUCT_NAME + $(TARGET_NAME) + PUBLIC_HEADERS_FOLDER_PATH + + SDKROOT + iphoneos + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Debug + + 19E6319F6ECED7539AABBD9A211F7AEC + + fileRef + 4F0B1EE3B8691E40E373D83BFB8911E0 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 1BA3D9FB5D5145BF698C941C0F843518 + + fileRef + 2DEC36674865A8A575C354765F6FE523 + isa + PBXBuildFile + + 1D6FC9B841D6C0D885442F9FD764B17E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshAutoStateFooter.h + path + MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.h + sourceTree + <group> + + 1E4635EDB9C4D5FDF86C0FE10A5D1F14 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshBackNormalFooter.m + path + MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.m + sourceTree + <group> + + 1FDBB5F81C39BBB738BAE9B3D3DA27A3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshAutoGifFooter.h + path + MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.h + sourceTree + <group> + + 200CA5D919CC71EA6A769541C92716D3 + + fileRef + 914A2790C594EC9CDE818A18843BC5D7 + isa + PBXBuildFile + + 2053D71CF543C3A3CC47C5409D61923C + + fileRef + 57F2B5E013FD1D42752E768761E043FC + isa + PBXBuildFile + + 20B56609144CE204DFA8221F742B2D76 + + children + + FFD977C5D23FB16656C5D57197BAA49C + + isa + PBXGroup + name + Frameworks + sourceTree + <group> + + 2280D55B18C853A6AA3AE9565EE91F19 + + fileRef + 08802A6DF042F6CA833289403FF4F4A4 + isa + PBXBuildFile + + 23415204AA48A02959E4E5245CF96037 + + fileRef + 7125517479B3877B4CBC715247131B6C + isa + PBXBuildFile + + 2359387620C5E815BF0594BC40311734 + + fileRef + 3816E2DBB35FD18D7D736AB2C25A562F + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 272643F56613CA0D336AE3DBF19DC404 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Pods-dummy.m + sourceTree + <group> + + 27EAC25242A69C58BBF8A63D030D30CB + + baseConfigurationReference + 0FF2C40B2066C078D66B8C5479DA89F8 + buildSettings + + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/MJRefresh/MJRefresh-prefix.pch + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PRIVATE_HEADERS_FOLDER_PATH + + PRODUCT_NAME + $(TARGET_NAME) + PUBLIC_HEADERS_FOLDER_PATH + + SDKROOT + iphoneos + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Release + + 28187854DC01618EEE9C133AAE81347B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFAutoPurgingImageCache.m + path + UIKit+AFNetworking/AFAutoPurgingImageCache.m + sourceTree + <group> + + 2894369EF8D702DF360B6763B36E8444 + + fileRef + 1113E422399B9F02C00AD2082D74F1C8 + isa + PBXBuildFile + + 2A552CE73CFAE55C9C995F61D1D74414 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFSecurityPolicy.h + path + AFNetworking/AFSecurityPolicy.h + sourceTree + <group> + + 2D8E8EC45A3A1A1D94AE762CB5028504 + + buildConfigurations + + A70CDAD61F90AC503C7D04CC22DA2923 + FB45FFD90572718D82AB9092B750F0CA + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 2DEC36674865A8A575C354765F6FE523 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshBackGifFooter.m + path + MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.m + sourceTree + <group> + + 2E781167DFE2565306F953E0F8F217E7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIScrollView+MJRefresh.m + path + MJRefresh/UIScrollView+MJRefresh.m + sourceTree + <group> + + 2E9869A1CA223100019EAB21CE879480 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshGifHeader.m + path + MJRefresh/Custom/Header/MJRefreshGifHeader.m + sourceTree + <group> + + 311E5200832E4AE174A193851A2C6317 + + fileRef + C775B9A146FD7AC6E3F84A6A59E01E3A + isa + PBXBuildFile + + 321E66BDB33DD3AC0111552889CE84F5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + AFNetworking.xcconfig + sourceTree + <group> + + 326A543AD4E39A2DAECA1CD385E3AEA2 + + fileRef + 4F1F0AC5DF16ED51C88500550CFB0716 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 33E247F7C06EBE2DE18149165E77DEDC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshBackStateFooter.h + path + MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.h + sourceTree + <group> + + 346003011339A97DDE1A394DF0A3BB91 + + buildActionMask + 2147483647 + files + + 8F68B37533C5AC9C8588BD0449D32673 + 2894369EF8D702DF360B6763B36E8444 + DA8BAA5F8E5949555BC8B94E309E23D8 + E0529B7C623EB5752662665A05DAAFBA + 5FBA673E534DD7485FD75764258C8046 + A89B33DBDA4E99005E1F1BDB95A296CC + 1BA3D9FB5D5145BF698C941C0F843518 + F0D01ED940723EED434E4EF4BCFF53F9 + 200CA5D919CC71EA6A769541C92716D3 + 9230119085130B273ECF20F076081DA1 + 922ACEFE37E22A36A6F0209742B7B51A + 6EE360D085C7EDD97B0A48A415012D37 + 585CDAC34F08FB220FF26FF55CA899B7 + 133B30495D945B737235B107AAE7DAAB + B19CA8B0FD349AEAD2D5A1C6B46AF47D + 5CBFDC026AAED77902F3CAC48A96FE69 + 932430D4A2289A39BE7C50EEAA60246A + 09D04A9AB71B5A4FE9175F80496EA5FD + 2280D55B18C853A6AA3AE9565EE91F19 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 3511AE7ADBB71D05565854F0E70B7D08 + + fileRef + 868FEB83BE0848F6A0AF14E8C1D315ED + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 35FC344065C20368F6D1E8CFC71DAE28 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshConst.h + path + MJRefresh/MJRefreshConst.h + sourceTree + <group> + + 376BAF62B3325FE4A8AA7F1139273861 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshComponent.m + path + MJRefresh/Base/MJRefreshComponent.m + sourceTree + <group> + + 37DB56D75062CC75FCB0966E1C6E8A8E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text + path + Pods-acknowledgements.markdown + sourceTree + <group> + + 3816E2DBB35FD18D7D736AB2C25A562F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLRequestSerialization.h + path + AFNetworking/AFURLRequestSerialization.h + sourceTree + <group> + + 38EEA9ED6B922946C54AD6BAC93B73AD + + fileRef + 68FBFF221006BE97930F3D965BE3A102 + isa + PBXBuildFile + + 3939531EB270B4145C7ADFBAB2E5695F + + fileRef + 13966E5B637944E1DE3144EF3CAF0FC4 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 3D32356147D239362A3FF7DCAB918205 + + buildConfigurations + + 7E9A67AE8C4941B71EBA1854861BC552 + 27EAC25242A69C58BBF8A63D030D30CB + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 3D3BFFB9C3E6111C5DFA6B37B71AC708 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshConst.m + path + MJRefresh/MJRefreshConst.m + sourceTree + <group> + + 43098B12DF5546CB576986E68DBCAFCA + + fileRef + 84BAF48B49D3C089AF584F1AE6F0AAA7 + isa + PBXBuildFile + + 444602F3A422E5EC1DA8EF2A3DFA01EB + + fileRef + 073DD9349F6203BB682696DE215CED6B + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 44F50504254959A81B2E96AD6261B2A9 + + fileRef + 1456D0651D05838A6AA7338F8F0DD470 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 497F1C6DA9BF82AF233A55F720A0D064 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIImage+AFNetworking.h + path + UIKit+AFNetworking/UIImage+AFNetworking.h + sourceTree + <group> + + 4A8ECA03DAD4E43C6DEFE6D152E95E00 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + AFNetworking-dummy.m + sourceTree + <group> + + 4B5E09720919B968FDE1AE5A31E5601D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshHeader.m + path + MJRefresh/Base/MJRefreshHeader.m + sourceTree + <group> + + 4BA19F7DD8F9FDA648137B2CE89E7588 + + fileRef + 8BF89C9A7F3CE77FDC867779636F4958 + isa + PBXBuildFile + + 4C653B48014092A02E07DF6439027162 + + fileRef + 272643F56613CA0D336AE3DBF19DC404 + isa + PBXBuildFile + + 4D9A31EBF326978CF8832BBCAE980EF7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFNetworkReachabilityManager.h + path + AFNetworking/AFNetworkReachabilityManager.h + sourceTree + <group> + + 4E762F23EC34ED4A6FF3312D84E33A40 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods.debug.xcconfig + sourceTree + <group> + + 4F0B1EE3B8691E40E373D83BFB8911E0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFAutoPurgingImageCache.h + path + UIKit+AFNetworking/AFAutoPurgingImageCache.h + sourceTree + <group> + + 4F1F0AC5DF16ED51C88500550CFB0716 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFImageDownloader.h + path + UIKit+AFNetworking/AFImageDownloader.h + sourceTree + <group> + + 500F05087AC46188E8C6433011404026 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFURLRequestSerialization.m + path + AFNetworking/AFURLRequestSerialization.m + sourceTree + <group> + + 508C962B3E08E8DA04956BF349A3CDFD + + buildActionMask + 2147483647 + files + + 2053D71CF543C3A3CC47C5409D61923C + 6083F51989A0009C740D92767F4DC1FC + 00F09DB5E05D1208F27161E2F016FE36 + 022B549F10007177A43FAB1DD5114F7D + CE8965366A3B07A6C0615055A31B8B83 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 5497A672D317A51CC17B4100B14BCC4D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFImageDownloader.m + path + UIKit+AFNetworking/AFImageDownloader.m + sourceTree + <group> + + 57907B8276E9F629BE2F7CDB39E5C9B5 + + children + + C4FEF549DD2F1B70658CEAFE55B787C1 + 7125517479B3877B4CBC715247131B6C + 868FEB83BE0848F6A0AF14E8C1D315ED + 8BBF8276362D9E840F6CFBF0104E26E7 + + isa + PBXGroup + name + NSURLSession + sourceTree + <group> + + 57F2B5E013FD1D42752E768761E043FC + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + CoreGraphics.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/CoreGraphics.framework + sourceTree + DEVELOPER_DIR + + 585CDAC34F08FB220FF26FF55CA899B7 + + fileRef + 2E9869A1CA223100019EAB21CE879480 + isa + PBXBuildFile + + 5B0CEF515306EA1C3F10222386D38532 + + explicitFileType + archive.ar + includeInIndex + 0 + isa + PBXFileReference + name + libPods.a + path + libPods.a + sourceTree + BUILT_PRODUCTS_DIR + + 5CBFDC026AAED77902F3CAC48A96FE69 + + fileRef + ECF432CDF783726972AECCAAB7D42EB4 + isa + PBXBuildFile + + 5D52DB6DF2E6C24CECB0015A9177A2E1 + + fileRef + 8FBFF0F9173E586E6DEE2431D020F6D9 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 5FBA673E534DD7485FD75764258C8046 + + fileRef + A717DA93F3376F7295C7B0CCB0580AA9 + isa + PBXBuildFile + + 6083F51989A0009C740D92767F4DC1FC + + fileRef + 9C31A9B26388001B26382C7C355DA572 + isa + PBXBuildFile + + 687177D06792F86CAA08485545B35CD8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIImageView+AFNetworking.h + path + UIKit+AFNetworking/UIImageView+AFNetworking.h + sourceTree + <group> + + 68FBFF221006BE97930F3D965BE3A102 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIProgressView+AFNetworking.m + path + UIKit+AFNetworking/UIProgressView+AFNetworking.m + sourceTree + <group> + + 6911BECA35E7518D864239B7E898EEF3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-frameworks.sh + sourceTree + <group> + + 6A19A6966D9D671F0309BC262DAD7BA5 + + children + + 06368923FB85F3210C47762DB41DDC44 + 14D4CFD102AA79373F35EA51B06E3C7D + 5B0CEF515306EA1C3F10222386D38532 + + isa + PBXGroup + name + Products + sourceTree + <group> + + 6C89DAAC7551D8A93F0B9D10042DD1D4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFURLResponseSerialization.m + path + AFNetworking/AFURLResponseSerialization.m + sourceTree + <group> + + 6CF9B693754B004AD7FB2F8A6C0C8F36 + + fileRef + 8BC29314DFF0EB71BBB58D391D5D52C0 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 6E80858B842657D04234289E938017AC + + fileRef + DC7F115ECE6270A9A9F3CD38D8AEF2D3 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 6EC97BDB3FC508526F9E388095A7DDCC + + fileRef + 687177D06792F86CAA08485545B35CD8 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 6EE360D085C7EDD97B0A48A415012D37 + + fileRef + CAF84208B94B9689E85746D43B79D4DC + isa + PBXBuildFile + + 7125517479B3877B4CBC715247131B6C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFHTTPSessionManager.m + path + AFNetworking/AFHTTPSessionManager.m + sourceTree + <group> + + 72BF357FC2C775C7B09609A7A4843E1E + + fileRef + 9C31A9B26388001B26382C7C355DA572 + isa + PBXBuildFile + + 757DD7BAB758057348FD5C89E96BE6AB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshBackFooter.h + path + MJRefresh/Base/MJRefreshBackFooter.h + sourceTree + <group> + + 77CF2A7107BC61A2E90025871305961D + + buildConfigurations + + 162B149B0DD54501D7C75154E5B604EE + 0EB5E89BB17510AE9D4971A42147A390 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 77F797A5A72065EE7351CF41728C2EC3 + + fileRef + EA1AE46123526C651995EA61F45C5072 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 78940A6980F359C4304C695EF6E67C5D + + fileRef + DC7633297196443A74F02991B35EB911 + isa + PBXBuildFile + + 7B77EB4FC3B78F5403EA5BF422B5A188 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIKit+AFNetworking.h + path + UIKit+AFNetworking/UIKit+AFNetworking.h + sourceTree + <group> + + 7C168D5DBDB78691493E24B13EF6B6A8 + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + SystemConfiguration.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/SystemConfiguration.framework + sourceTree + DEVELOPER_DIR + + 7DB346D0F39D3F0E887471402A8071AB + + children + + BA6428E9F66FD5A23C0A2E06ED26CD2F + 20B56609144CE204DFA8221F742B2D76 + 0F178FF4DA6AF2436D12F0D491C847BA + 6A19A6966D9D671F0309BC262DAD7BA5 + 037C0CA694176A3C0915F62C9D20B3E6 + + isa + PBXGroup + sourceTree + <group> + + 7E9A67AE8C4941B71EBA1854861BC552 + + baseConfigurationReference + 0FF2C40B2066C078D66B8C5479DA89F8 + buildSettings + + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_PREFIX_HEADER + Target Support Files/MJRefresh/MJRefresh-prefix.pch + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + MTL_ENABLE_DEBUG_INFO + YES + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PRIVATE_HEADERS_FOLDER_PATH + + PRODUCT_NAME + $(TARGET_NAME) + PUBLIC_HEADERS_FOLDER_PATH + + SDKROOT + iphoneos + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Debug + + 7F0578A0258E02384F6229C678E60D31 + + fileRef + A5933D56C412CA7F8F3333EA0E8D0AFE + isa + PBXBuildFile + + 7F19AC3B98DAEF7B56822FCFEEFE579B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshAutoNormalFooter.h + path + MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.h + sourceTree + <group> + + 81ED1C23CAE1C5A7F39086216FA7407C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshBackFooter.m + path + MJRefresh/Base/MJRefreshBackFooter.m + sourceTree + <group> + + 830050886B18F54E17F117FD8EFC717B + + fileRef + CE92DFDBD1B21FD8BDD698E4068B21BD + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 83E4F721FD7D05DB9502ADC4925879B2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIScrollView+MJExtension.h + path + MJRefresh/UIScrollView+MJExtension.h + sourceTree + <group> + + 84BAF48B49D3C089AF584F1AE6F0AAA7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFNetworkReachabilityManager.m + path + AFNetworking/AFNetworkReachabilityManager.m + sourceTree + <group> + + 84BCB7A2F0892F6B63BE88C7CD85056D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIButton+AFNetworking.h + path + UIKit+AFNetworking/UIButton+AFNetworking.h + sourceTree + <group> + + 8582AABBE144740D377D61891ADFC1A6 + + children + + 4D9A31EBF326978CF8832BBCAE980EF7 + 84BAF48B49D3C089AF584F1AE6F0AAA7 + + isa + PBXGroup + name + Reachability + sourceTree + <group> + + 85FAB6F1D2FE0598BF2E61D7BB084B8D + + fileRef + 7B77EB4FC3B78F5403EA5BF422B5A188 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 868FEB83BE0848F6A0AF14E8C1D315ED + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLSessionManager.h + path + AFNetworking/AFURLSessionManager.h + sourceTree + <group> + + 8BBF8276362D9E840F6CFBF0104E26E7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFURLSessionManager.m + path + AFNetworking/AFURLSessionManager.m + sourceTree + <group> + + 8BC29314DFF0EB71BBB58D391D5D52C0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshBackGifFooter.h + path + MJRefresh/Custom/Footer/Back/MJRefreshBackGifFooter.h + sourceTree + <group> + + 8BF89C9A7F3CE77FDC867779636F4958 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFNetworkActivityIndicatorManager.m + path + UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m + sourceTree + <group> + + 8E65D8BB285E4B1873D24CEF9CE89752 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFNetworking.h + path + AFNetworking/AFNetworking.h + sourceTree + <group> + + 8E82178CC9BD8BE3DBF2C10E33807AEB + + fileRef + 500F05087AC46188E8C6433011404026 + isa + PBXBuildFile + + 8EA8E5C91690482F098D171648ACB518 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFURLResponseSerialization.h + path + AFNetworking/AFURLResponseSerialization.h + sourceTree + <group> + + 8F6775452919B948C627BD12821F0D28 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + MJRefresh-prefix.pch + sourceTree + <group> + + 8F68B37533C5AC9C8588BD0449D32673 + + fileRef + 1548803AE5D9CADA5820DB1612E34E11 + isa + PBXBuildFile + + 8F74D9EA91F4C43190670066BAC37D44 + + buildConfigurationList + 3D32356147D239362A3FF7DCAB918205 + buildPhases + + 346003011339A97DDE1A394DF0A3BB91 + F6AAF5593D0C5E24B3377E5C3999D0AA + 0B678E4E7D716E2C6EC64BDB96418C7E + + buildRules + + dependencies + + isa + PBXNativeTarget + name + MJRefresh + productName + MJRefresh + productReference + 14D4CFD102AA79373F35EA51B06E3C7D + productType + com.apple.product-type.library.static + + 8FBFF0F9173E586E6DEE2431D020F6D9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIProgressView+AFNetworking.h + path + UIKit+AFNetworking/UIProgressView+AFNetworking.h + sourceTree + <group> + + 902A039891A5E63011F1103CFB2CF673 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + AFNetworking-prefix.pch + sourceTree + <group> + + 904EC3379A9E226064CB03DC1ACA2EEA + + fileRef + C467F17AE48139BC2AA38E527854B004 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 91433C576CE041B9D0AE2E81E13458CC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIWebView+AFNetworking.m + path + UIKit+AFNetworking/UIWebView+AFNetworking.m + sourceTree + <group> + + 914A2790C594EC9CDE818A18843BC5D7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshBackStateFooter.m + path + MJRefresh/Custom/Footer/Back/MJRefreshBackStateFooter.m + sourceTree + <group> + + 922ACEFE37E22A36A6F0209742B7B51A + + fileRef + 3D3BFFB9C3E6111C5DFA6B37B71AC708 + isa + PBXBuildFile + + 9230119085130B273ECF20F076081DA1 + + fileRef + 376BAF62B3325FE4A8AA7F1139273861 + isa + PBXBuildFile + + 928353533005A4198EBDA5B700D37B64 + + buildConfigurationList + 77CF2A7107BC61A2E90025871305961D + buildPhases + + DE0BAD758C6F291CE7E10DA077987C62 + 508C962B3E08E8DA04956BF349A3CDFD + B981229135DBE9773A86BDB116C368D1 + + buildRules + + dependencies + + isa + PBXNativeTarget + name + AFNetworking + productName + AFNetworking + productReference + 06368923FB85F3210C47762DB41DDC44 + productType + com.apple.product-type.library.static + + 932430D4A2289A39BE7C50EEAA60246A + + fileRef + EE382DEF2FEB230B042F4781472235B4 + isa + PBXBuildFile + + 948F7C653B9E3FF473E01886D0175F72 + + baseConfigurationReference + 4E762F23EC34ED4A6FF3312D84E33A40 + buildSettings + + ENABLE_STRICT_OBJC_MSGSEND + YES + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + MACH_O_TYPE + staticlib + MTL_ENABLE_DEBUG_INFO + YES + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_NAME + $(TARGET_NAME) + SDKROOT + iphoneos + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Debug + + 94D4941DEB0665222B7DC3EB673F8D07 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshComponent.h + path + MJRefresh/Base/MJRefreshComponent.h + sourceTree + <group> + + 98C98CDFB3F20F2925F6CD1F141BB14F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods.release.xcconfig + sourceTree + <group> + + 9BF8D708AC9892125B0AA4E540361FF8 + + fileRef + 7F19AC3B98DAEF7B56822FCFEEFE579B + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 9C31A9B26388001B26382C7C355DA572 + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + Foundation.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/Foundation.framework + sourceTree + DEVELOPER_DIR + + 9FE8B40150564209AEECFDDAAE290511 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIImageView+AFNetworking.m + path + UIKit+AFNetworking/UIImageView+AFNetworking.m + sourceTree + <group> + + A19DF616941A51576DD057A9FD8F4AD8 + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + Security.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/Security.framework + sourceTree + DEVELOPER_DIR + + A1A36D34413696BE466E2CA0AFF194DA + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-resources.sh + sourceTree + <group> + + A1BDA1E9A547DE102E82008146D0CE3F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshAutoFooter.h + path + MJRefresh/Base/MJRefreshAutoFooter.h + sourceTree + <group> + + A5933D56C412CA7F8F3333EA0E8D0AFE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIRefreshControl+AFNetworking.m + path + UIKit+AFNetworking/UIRefreshControl+AFNetworking.m + sourceTree + <group> + + A70CDAD61F90AC503C7D04CC22DA2923 + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_DYNAMIC_NO_PIC + NO + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PREPROCESSOR_DEFINITIONS + + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + ONLY_ACTIVE_ARCH + YES + STRIP_INSTALLED_PRODUCT + NO + SYMROOT + ${SRCROOT}/../build + + isa + XCBuildConfiguration + name + Debug + + A717DA93F3376F7295C7B0CCB0580AA9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshAutoStateFooter.m + path + MJRefresh/Custom/Footer/Auto/MJRefreshAutoStateFooter.m + sourceTree + <group> + + A849B4765BBAB5464AC3E6FE52F4F753 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 8F74D9EA91F4C43190670066BAC37D44 + remoteInfo + MJRefresh + + A89B33DBDA4E99005E1F1BDB95A296CC + + fileRef + 81ED1C23CAE1C5A7F39086216FA7407C + isa + PBXBuildFile + + A8FC6A53F6C1CB4DEFD972664E1AF3B1 + + fileRef + 4A8ECA03DAD4E43C6DEFE6D152E95E00 + isa + PBXBuildFile + + A991D45DDE7457BFED68BEEC5786C519 + + children + + 4F0B1EE3B8691E40E373D83BFB8911E0 + 28187854DC01618EEE9C133AAE81347B + 4F1F0AC5DF16ED51C88500550CFB0716 + 5497A672D317A51CC17B4100B14BCC4D + 13966E5B637944E1DE3144EF3CAF0FC4 + 8BF89C9A7F3CE77FDC867779636F4958 + CE92DFDBD1B21FD8BDD698E4068B21BD + D6D5BE0EB66BDB0CCFB75F9C14F387BF + 84BCB7A2F0892F6B63BE88C7CD85056D + DC7633297196443A74F02991B35EB911 + 497F1C6DA9BF82AF233A55F720A0D064 + 687177D06792F86CAA08485545B35CD8 + 9FE8B40150564209AEECFDDAAE290511 + 7B77EB4FC3B78F5403EA5BF422B5A188 + 8FBFF0F9173E586E6DEE2431D020F6D9 + 68FBFF221006BE97930F3D965BE3A102 + EA9F4D8C11F43F5B0ABE40C74FAAEB5E + A5933D56C412CA7F8F3333EA0E8D0AFE + C9AAD944776BC225E695EA3A4FE04291 + 91433C576CE041B9D0AE2E81E13458CC + + isa + PBXGroup + name + UIKit + sourceTree + <group> + + A9D64E19ABF27D46F3E4920E44686CB7 + + isa + PBXTargetDependency + name + MJRefresh + target + 8F74D9EA91F4C43190670066BAC37D44 + targetProxy + A849B4765BBAB5464AC3E6FE52F4F753 + + ACE9C1A6E8D5121C6C5F907C7A9CFCC9 + + fileRef + EA9F4D8C11F43F5B0ABE40C74FAAEB5E + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + AD359A96DD4AA2C962E50A5CD5524F54 + + fileRef + 91433C576CE041B9D0AE2E81E13458CC + isa + PBXBuildFile + + B0BE398350F83A7B0102C3BBAFC51428 + + fileRef + 9FE8B40150564209AEECFDDAAE290511 + isa + PBXBuildFile + + B19CA8B0FD349AEAD2D5A1C6B46AF47D + + fileRef + 10C32B6063CB8FCC7AA7C232A3EC1968 + isa + PBXBuildFile + + B3D1D13E0C6553800746CB8FD61CF946 + + children + + 37DB56D75062CC75FCB0966E1C6E8A8E + 10834806BD7B412BC24F347361FA2C8E + 272643F56613CA0D336AE3DBF19DC404 + 6911BECA35E7518D864239B7E898EEF3 + A1A36D34413696BE466E2CA0AFF194DA + 4E762F23EC34ED4A6FF3312D84E33A40 + 98C98CDFB3F20F2925F6CD1F141BB14F + + isa + PBXGroup + name + Pods + path + Target Support Files/Pods + sourceTree + <group> + + B51AA1F7701DCDBCC9B88A15320F9C2C + + fileRef + 8EA8E5C91690482F098D171648ACB518 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + B5A8A60810B99D763E3A3F076F63509D + + fileRef + 757DD7BAB758057348FD5C89E96BE6AB + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + B5CF67F7870BAB70A76E57479B706B42 + + fileRef + C9AAD944776BC225E695EA3A4FE04291 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + B981229135DBE9773A86BDB116C368D1 + + buildActionMask + 2147483647 + files + + 19E6319F6ECED7539AABBD9A211F7AEC + F3774B1449FCE5B3CA3E1B336E11D284 + 326A543AD4E39A2DAECA1CD385E3AEA2 + 3939531EB270B4145C7ADFBAB2E5695F + 0A08FC71C4E3B8E0F8734BCDA7CCA7CB + ED69D9B5A342FE9BD3F170D5CDDEC948 + DFDAC8245626953C4BCE5A2DA6BE2A5B + 2359387620C5E815BF0594BC40311734 + B51AA1F7701DCDBCC9B88A15320F9C2C + 3511AE7ADBB71D05565854F0E70B7D08 + 830050886B18F54E17F117FD8EFC717B + E212C2AA95E8F6EFB69A5F1455F291F8 + C1B65C3D849FEE4FB5298A8135A765DA + 6EC97BDB3FC508526F9E388095A7DDCC + 85FAB6F1D2FE0598BF2E61D7BB084B8D + 5D52DB6DF2E6C24CECB0015A9177A2E1 + ACE9C1A6E8D5121C6C5F907C7A9CFCC9 + B5CF67F7870BAB70A76E57479B706B42 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + B9B44F1EDC36C095666CA0AE98371C09 + + fileRef + 83E4F721FD7D05DB9502ADC4925879B2 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + BA6428E9F66FD5A23C0A2E06ED26CD2F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text + name + Podfile + path + ../Podfile + sourceTree + SOURCE_ROOT + xcLanguageSpecificationIdentifier + xcode.lang.ruby + + BD61EDB0DCF0DFC2AD3695452D438D60 + + children + + F1C17412EF360EB764F781E09B98A675 + + isa + PBXGroup + name + Resources + sourceTree + <group> + + C1B65C3D849FEE4FB5298A8135A765DA + + fileRef + 497F1C6DA9BF82AF233A55F720A0D064 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + C1DAA515EEE44666FC7C3CCAB35036F9 + + fileRef + 9C31A9B26388001B26382C7C355DA572 + isa + PBXBuildFile + + C21810C18E98604F6366CC1A4FC1898F + + buildActionMask + 2147483647 + files + + 4C653B48014092A02E07DF6439027162 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + C2201E34603B014192F0967473518496 + + fileRef + 6C89DAAC7551D8A93F0B9D10042DD1D4 + isa + PBXBuildFile + + C2B240D99C3FC6A7DC6C66A2434CA799 + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + MobileCoreServices.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/MobileCoreServices.framework + sourceTree + DEVELOPER_DIR + + C467F17AE48139BC2AA38E527854B004 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIScrollView+MJRefresh.h + path + MJRefresh/UIScrollView+MJRefresh.h + sourceTree + <group> + + C4FEF549DD2F1B70658CEAFE55B787C1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + AFHTTPSessionManager.h + path + AFNetworking/AFHTTPSessionManager.h + sourceTree + <group> + + C66A994F14BA080776BB3E2AD8CC55B4 + + fileRef + 1D6FC9B841D6C0D885442F9FD764B17E + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + C67F32FF951D1979EF0E6B4ADED5E8A8 + + fileRef + D0FE43465B18C05D14244A4F58B81AD1 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + C70E62BFCC3D2E65035D5C7108E1DFC3 + + baseConfigurationReference + 98C98CDFB3F20F2925F6CD1F141BB14F + buildSettings + + ENABLE_STRICT_OBJC_MSGSEND + YES + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + MACH_O_TYPE + staticlib + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_NAME + $(TARGET_NAME) + SDKROOT + iphoneos + SKIP_INSTALL + YES + + isa + XCBuildConfiguration + name + Release + + C775B9A146FD7AC6E3F84A6A59E01E3A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + AFSecurityPolicy.m + path + AFNetworking/AFSecurityPolicy.m + sourceTree + <group> + + C9504968018BD311EF76CE754403D69A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshHeader.h + path + MJRefresh/Base/MJRefreshHeader.h + sourceTree + <group> + + C9AAD944776BC225E695EA3A4FE04291 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIWebView+AFNetworking.h + path + UIKit+AFNetworking/UIWebView+AFNetworking.h + sourceTree + <group> + + CAF84208B94B9689E85746D43B79D4DC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshFooter.m + path + MJRefresh/Base/MJRefreshFooter.m + sourceTree + <group> + + CE8965366A3B07A6C0615055A31B8B83 + + fileRef + 7C168D5DBDB78691493E24B13EF6B6A8 + isa + PBXBuildFile + + CE92DFDBD1B21FD8BDD698E4068B21BD + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIActivityIndicatorView+AFNetworking.h + path + UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h + sourceTree + <group> + + D054768D94E678B8A0D7F2AB4FF45E54 + + fileRef + DF030629DFE58678657B00A25D030CA0 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + D0E21F6081D751169836C6324483CA69 + + children + + 2A552CE73CFAE55C9C995F61D1D74414 + C775B9A146FD7AC6E3F84A6A59E01E3A + + isa + PBXGroup + name + Security + sourceTree + <group> + + D0FE43465B18C05D14244A4F58B81AD1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshNormalHeader.h + path + MJRefresh/Custom/Header/MJRefreshNormalHeader.h + sourceTree + <group> + + D31FEE51AF4BE2A6CC059F80B983CD3B + + fileRef + 5497A672D317A51CC17B4100B14BCC4D + isa + PBXBuildFile + + D41D8CD98F00B204E9800998ECF8427E + + attributes + + LastSwiftUpdateCheck + 0700 + LastUpgradeCheck + 0700 + + buildConfigurationList + 2D8E8EC45A3A1A1D94AE762CB5028504 + compatibilityVersion + Xcode 3.2 + developmentRegion + English + hasScannedForEncodings + 0 + isa + PBXProject + knownRegions + + en + + mainGroup + 7DB346D0F39D3F0E887471402A8071AB + productRefGroup + 6A19A6966D9D671F0309BC262DAD7BA5 + projectDirPath + + projectReferences + + projectRoot + + targets + + 928353533005A4198EBDA5B700D37B64 + 8F74D9EA91F4C43190670066BAC37D44 + F849236A7E253E981131C345B30297E8 + + + D595C17C62C58E80EEC6F9EBCCF4050A + + fileRef + F5393D1AC612D8A99F84492793101CBC + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + D6D5BE0EB66BDB0CCFB75F9C14F387BF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIActivityIndicatorView+AFNetworking.m + path + UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m + sourceTree + <group> + + D96F2710D78051BBE8A22541FCB1D871 + + children + + 321E66BDB33DD3AC0111552889CE84F5 + 4A8ECA03DAD4E43C6DEFE6D152E95E00 + 902A039891A5E63011F1103CFB2CF673 + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/AFNetworking + sourceTree + <group> + + DA8BAA5F8E5949555BC8B94E309E23D8 + + fileRef + F3D32A889E22686A56EB06437FDBB455 + isa + PBXBuildFile + + DC7633297196443A74F02991B35EB911 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIButton+AFNetworking.m + path + UIKit+AFNetworking/UIButton+AFNetworking.m + sourceTree + <group> + + DC7F115ECE6270A9A9F3CD38D8AEF2D3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshBackNormalFooter.h + path + MJRefresh/Custom/Footer/Back/MJRefreshBackNormalFooter.h + sourceTree + <group> + + DE0BAD758C6F291CE7E10DA077987C62 + + buildActionMask + 2147483647 + files + + 14CD3DFB4A25BAEFB205730FA6750025 + 23415204AA48A02959E4E5245CF96037 + D31FEE51AF4BE2A6CC059F80B983CD3B + 4BA19F7DD8F9FDA648137B2CE89E7588 + A8FC6A53F6C1CB4DEFD972664E1AF3B1 + 43098B12DF5546CB576986E68DBCAFCA + 311E5200832E4AE174A193851A2C6317 + 8E82178CC9BD8BE3DBF2C10E33807AEB + C2201E34603B014192F0967473518496 + FCDDD3BC67EA205C87238A2A87D5C36C + 15460ABD372C937E2A07A2FCDF98C473 + 78940A6980F359C4304C695EF6E67C5D + B0BE398350F83A7B0102C3BBAFC51428 + 38EEA9ED6B922946C54AD6BAC93B73AD + 7F0578A0258E02384F6229C678E60D31 + AD359A96DD4AA2C962E50A5CD5524F54 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + DF030629DFE58678657B00A25D030CA0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefresh.h + path + MJRefresh/MJRefresh.h + sourceTree + <group> + + DFDAC8245626953C4BCE5A2DA6BE2A5B + + fileRef + 2A552CE73CFAE55C9C995F61D1D74414 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + E0529B7C623EB5752662665A05DAAFBA + + fileRef + E07B48C0206EB922CF19938E30019BDA + isa + PBXBuildFile + + E07B48C0206EB922CF19938E30019BDA + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshAutoNormalFooter.m + path + MJRefresh/Custom/Footer/Auto/MJRefreshAutoNormalFooter.m + sourceTree + <group> + + E1902FB573FD0FD999974D15601ED37A + + children + + DF030629DFE58678657B00A25D030CA0 + A1BDA1E9A547DE102E82008146D0CE3F + 1113E422399B9F02C00AD2082D74F1C8 + 1FDBB5F81C39BBB738BAE9B3D3DA27A3 + F3D32A889E22686A56EB06437FDBB455 + 7F19AC3B98DAEF7B56822FCFEEFE579B + E07B48C0206EB922CF19938E30019BDA + 1D6FC9B841D6C0D885442F9FD764B17E + A717DA93F3376F7295C7B0CCB0580AA9 + 757DD7BAB758057348FD5C89E96BE6AB + 81ED1C23CAE1C5A7F39086216FA7407C + 8BC29314DFF0EB71BBB58D391D5D52C0 + 2DEC36674865A8A575C354765F6FE523 + DC7F115ECE6270A9A9F3CD38D8AEF2D3 + 1E4635EDB9C4D5FDF86C0FE10A5D1F14 + 33E247F7C06EBE2DE18149165E77DEDC + 914A2790C594EC9CDE818A18843BC5D7 + 94D4941DEB0665222B7DC3EB673F8D07 + 376BAF62B3325FE4A8AA7F1139273861 + 35FC344065C20368F6D1E8CFC71DAE28 + 3D3BFFB9C3E6111C5DFA6B37B71AC708 + 1456D0651D05838A6AA7338F8F0DD470 + CAF84208B94B9689E85746D43B79D4DC + F5393D1AC612D8A99F84492793101CBC + 2E9869A1CA223100019EAB21CE879480 + C9504968018BD311EF76CE754403D69A + 4B5E09720919B968FDE1AE5A31E5601D + D0FE43465B18C05D14244A4F58B81AD1 + 10C32B6063CB8FCC7AA7C232A3EC1968 + 073DD9349F6203BB682696DE215CED6B + ECF432CDF783726972AECCAAB7D42EB4 + 83E4F721FD7D05DB9502ADC4925879B2 + EE382DEF2FEB230B042F4781472235B4 + C467F17AE48139BC2AA38E527854B004 + 2E781167DFE2565306F953E0F8F217E7 + EA1AE46123526C651995EA61F45C5072 + 08802A6DF042F6CA833289403FF4F4A4 + BD61EDB0DCF0DFC2AD3695452D438D60 + 000D07DC2737A4648E1CD9D2D1294CBF + + isa + PBXGroup + name + MJRefresh + path + MJRefresh + sourceTree + <group> + + E212C2AA95E8F6EFB69A5F1455F291F8 + + fileRef + 84BCB7A2F0892F6B63BE88C7CD85056D + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + E2696D9ECE420BE07FC8D60746BE0326 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 928353533005A4198EBDA5B700D37B64 + remoteInfo + AFNetworking + + EA03AF12E0E3E8ADC50DA70F2C5BF39E + + fileRef + C9504968018BD311EF76CE754403D69A + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + EA1AE46123526C651995EA61F45C5072 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIView+MJExtension.h + path + MJRefresh/UIView+MJExtension.h + sourceTree + <group> + + EA9F4D8C11F43F5B0ABE40C74FAAEB5E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + UIRefreshControl+AFNetworking.h + path + UIKit+AFNetworking/UIRefreshControl+AFNetworking.h + sourceTree + <group> + + ECF432CDF783726972AECCAAB7D42EB4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshStateHeader.m + path + MJRefresh/Custom/Header/MJRefreshStateHeader.m + sourceTree + <group> + + ED69D9B5A342FE9BD3F170D5CDDEC948 + + fileRef + 4D9A31EBF326978CF8832BBCAE980EF7 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + EE382DEF2FEB230B042F4781472235B4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + UIScrollView+MJExtension.m + path + MJRefresh/UIScrollView+MJExtension.m + sourceTree + <group> + + EFCDCCD66269CA908494B11E024DC736 + + fileRef + 1FDBB5F81C39BBB738BAE9B3D3DA27A3 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + F0D01ED940723EED434E4EF4BCFF53F9 + + fileRef + 1E4635EDB9C4D5FDF86C0FE10A5D1F14 + isa + PBXBuildFile + + F1C17412EF360EB764F781E09B98A675 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + wrapper.plug-in + name + MJRefresh.bundle + path + MJRefresh/MJRefresh.bundle + sourceTree + <group> + + F3774B1449FCE5B3CA3E1B336E11D284 + + fileRef + C4FEF549DD2F1B70658CEAFE55B787C1 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + F3D32A889E22686A56EB06437FDBB455 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + MJRefreshAutoGifFooter.m + path + MJRefresh/Custom/Footer/Auto/MJRefreshAutoGifFooter.m + sourceTree + <group> + + F432A374A040EBAB69C9EABC6C4D699A + + fileRef + 94D4941DEB0665222B7DC3EB673F8D07 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + F5393D1AC612D8A99F84492793101CBC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + MJRefreshGifHeader.h + path + MJRefresh/Custom/Header/MJRefreshGifHeader.h + sourceTree + <group> + + F58455418F190BC37D1FD19EA3EA5B01 + + fileRef + 33E247F7C06EBE2DE18149165E77DEDC + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + F6AAF5593D0C5E24B3377E5C3999D0AA + + buildActionMask + 2147483647 + files + + C1DAA515EEE44666FC7C3CCAB35036F9 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + F7B852F0917A6D6540DAB54F736D681B + + fileRef + 35FC344065C20368F6D1E8CFC71DAE28 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + F849236A7E253E981131C345B30297E8 + + buildConfigurationList + FF083BB01010CBC4341DB06A44257E58 + buildPhases + + C21810C18E98604F6366CC1A4FC1898F + FD6DA91957E48385DA14BCB5AABE28B9 + + buildRules + + dependencies + + 1100B0258FA1D8A45F1FABF12E8DCB46 + A9D64E19ABF27D46F3E4920E44686CB7 + + isa + PBXNativeTarget + name + Pods + productName + Pods + productReference + 5B0CEF515306EA1C3F10222386D38532 + productType + com.apple.product-type.library.static + + FB45FFD90572718D82AB9092B750F0CA + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + YES + ENABLE_NS_ASSERTIONS + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_PREPROCESSOR_DEFINITIONS + + RELEASE=1 + + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + STRIP_INSTALLED_PRODUCT + NO + SYMROOT + ${SRCROOT}/../build + VALIDATE_PRODUCT + YES + + isa + XCBuildConfiguration + name + Release + + FCDDD3BC67EA205C87238A2A87D5C36C + + fileRef + 8BBF8276362D9E840F6CFBF0104E26E7 + isa + PBXBuildFile + + FD6DA91957E48385DA14BCB5AABE28B9 + + buildActionMask + 2147483647 + files + + 72BF357FC2C775C7B09609A7A4843E1E + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + FF083BB01010CBC4341DB06A44257E58 + + buildConfigurations + + 948F7C653B9E3FF473E01886D0175F72 + C70E62BFCC3D2E65035D5C7108E1DFC3 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + FF1FEB28260D52C222E2F87FBBC05277 + + fileRef + A1BDA1E9A547DE102E82008146D0CE3F + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + FFD977C5D23FB16656C5D57197BAA49C + + children + + 57F2B5E013FD1D42752E768761E043FC + 9C31A9B26388001B26382C7C355DA572 + C2B240D99C3FC6A7DC6C66A2434CA799 + A19DF616941A51576DD057A9FD8F4AD8 + 7C168D5DBDB78691493E24B13EF6B6A8 + + isa + PBXGroup + name + iOS + sourceTree + <group> + + + rootObject + D41D8CD98F00B204E9800998ECF8427E + + diff --git a/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m b/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m new file mode 100644 index 0000000..6a29cf8 --- /dev/null +++ b/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_AFNetworking : NSObject +@end +@implementation PodsDummy_AFNetworking +@end diff --git a/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch b/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch new file mode 100644 index 0000000..b52cf0d --- /dev/null +++ b/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch @@ -0,0 +1,15 @@ +#ifdef __OBJC__ +#import +#endif + +#ifndef TARGET_OS_IOS + #define TARGET_OS_IOS TARGET_OS_IPHONE +#endif + +#ifndef TARGET_OS_WATCH + #define TARGET_OS_WATCH 0 +#endif + +#ifndef TARGET_OS_TV + #define TARGET_OS_TV 0 +#endif diff --git a/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig b/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig new file mode 100644 index 0000000..595b9e9 --- /dev/null +++ b/KtTableView/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MJRefresh" +OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh-dummy.m b/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh-dummy.m new file mode 100644 index 0000000..d43259d --- /dev/null +++ b/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_MJRefresh : NSObject +@end +@implementation PodsDummy_MJRefresh +@end diff --git a/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh-prefix.pch b/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh.xcconfig b/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh.xcconfig new file mode 100644 index 0000000..49b62f0 --- /dev/null +++ b/KtTableView/Pods/Target Support Files/MJRefresh/MJRefresh.xcconfig @@ -0,0 +1,4 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/MJRefresh" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MJRefresh" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/KtTableView/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown b/KtTableView/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown new file mode 100644 index 0000000..859bb41 --- /dev/null +++ b/KtTableView/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown @@ -0,0 +1,49 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## AFNetworking + +Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +## MJRefresh + +Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Generated by CocoaPods - http://cocoapods.org diff --git a/KtTableView/Pods/Target Support Files/Pods/Pods-acknowledgements.plist b/KtTableView/Pods/Target Support Files/Pods/Pods-acknowledgements.plist new file mode 100644 index 0000000..e569293 --- /dev/null +++ b/KtTableView/Pods/Target Support Files/Pods/Pods-acknowledgements.plist @@ -0,0 +1,83 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011–2016 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + Title + AFNetworking + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2013-2015 MJRefresh (https://github.com/CoderMJLee/MJRefresh) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + Title + MJRefresh + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - http://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/KtTableView/Pods/Target Support Files/Pods/Pods-dummy.m b/KtTableView/Pods/Target Support Files/Pods/Pods-dummy.m new file mode 100644 index 0000000..ade64bd --- /dev/null +++ b/KtTableView/Pods/Target Support Files/Pods/Pods-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods : NSObject +@end +@implementation PodsDummy_Pods +@end diff --git a/KtTableView/Pods/Target Support Files/Pods/Pods-frameworks.sh b/KtTableView/Pods/Target Support Files/Pods/Pods-frameworks.sh new file mode 100755 index 0000000..6f76344 --- /dev/null +++ b/KtTableView/Pods/Target Support Files/Pods/Pods-frameworks.sh @@ -0,0 +1,84 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # use filter instead of exclude so missing patterns dont' throw errors + echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" + /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current file + archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + stripped="" + for arch in $archs; do + if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi +} + diff --git a/KtTableView/Pods/Target Support Files/Pods/Pods-resources.sh b/KtTableView/Pods/Target Support Files/Pods/Pods-resources.sh new file mode 100755 index 0000000..7814104 --- /dev/null +++ b/KtTableView/Pods/Target Support Files/Pods/Pods-resources.sh @@ -0,0 +1,101 @@ +#!/bin/sh +set -e + +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +realpath() { + DIRECTORY="$(cd "${1%/*}" && pwd)" + FILENAME="${1##*/}" + echo "$DIRECTORY/$FILENAME" +} + +install_resource() +{ + case $1 in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" + ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" + ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" + ;; + *.framework) + echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" + xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" + xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" + xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + /*) + echo "$1" + echo "$1" >> "$RESOURCES_TO_COPY" + ;; + *) + echo "${PODS_ROOT}/$1" + echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" + ;; + esac +} +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_resource "MJRefresh/MJRefresh/MJRefresh.bundle" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_resource "MJRefresh/MJRefresh/MJRefresh.bundle" +fi + +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; + esac + + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "`realpath $PODS_ROOT`*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/KtTableView/Pods/Target Support Files/Pods/Pods.debug.xcconfig b/KtTableView/Pods/Target Support Files/Pods/Pods.debug.xcconfig new file mode 100644 index 0000000..07cc73a --- /dev/null +++ b/KtTableView/Pods/Target Support Files/Pods/Pods.debug.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MJRefresh" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/MJRefresh" +OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"MJRefresh" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/KtTableView/Pods/Target Support Files/Pods/Pods.release.xcconfig b/KtTableView/Pods/Target Support Files/Pods/Pods.release.xcconfig new file mode 100644 index 0000000..07cc73a --- /dev/null +++ b/KtTableView/Pods/Target Support Files/Pods/Pods.release.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/MJRefresh" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/MJRefresh" +OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"MJRefresh" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/KtTableView/README.md b/KtTableView/README.md new file mode 100644 index 0000000..02d5607 --- /dev/null +++ b/KtTableView/README.md @@ -0,0 +1,260 @@ +> 本文是直播分享的简单文字整理,视频地址:[优酷](http://v.youku.com/v_show/id_XMTUzNzQzMDU0NA==.html)、[YouTube](https://youtu.be/hPR67T9mbsY) +> Demo 地址:[KtTableView](https://github.com/bestswifter/MySampleCode/tree/master/KtTableView) + +# MVC + +讨论解耦之前,我们要弄明白 MVC 的核心:控制器(以下简称 C)负责模型(以下简称 M)和视图(以下简称 V)的交互。 + +这里所说的 M,通常不是一个单独的类,很多情况下它是由多个类构成的一个层。最上层的通常是以 `Model` 结尾的类,它直接被 C 持有。`Model` 类还可以持有两个对象: + +1. Item:它是实际存储数据的对象。它可以理解为一个字典,和 V 中的属性一一对应 +2. Cache:它可以缓存自己的 Item(如果有很多) + +常见的误区: + +1. 一般情况下数据的处理会放在 M 而不是 C(C 只做不能复用的事) +2. 解耦不只是把一段代码拿到外面去。而是关注是否能合并重复代码, 并且有良好的拖展性。 + +# 原始版 + +在 C 中,我们创建 `UITableView` 对象,然后将它的数据源和代理设置为自己。也就是自己管理着 UI 逻辑和数据存取的逻辑。在这种架构下,主要存在这些问题: + +1. 违背 MVC 模式,现在是 V 持有 C 和 M。 +2. C 管理了全部逻辑,耦合太严重。 +3. 其实绝大多数 UI 相关都是由 Cell 而不是 `UITableView` 自身完成的。 + +为了解决这些问题,我们首先弄明白,数据源和代理分别做了那些事。 + +### 数据源 + +它有两个必须实现的代理方法: + +```objc +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; +``` + +简单来说,只要实现了这个两个方法,一个简单的 `UITableView` 对象就算是完成了。 + +除此以外,它还负责管理 `section` 的数量,标题,某一个 `cell` 的编辑和移动等。 + +### 代理 + +代理主要涉及以下几个方面的内容: + +1. cell、headerView 等展示前、后的回调。 +2. cell、headerView 等的高度,点击事件。 + +最常用的也是两个方法: + +```objc +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; +``` + +提醒:绝大多数代理方法都有一个 `indexPath` 参数 + +# 优化数据源 + +最简单的思路是单独把数据源拿出来作为一个对象。 + +这种写法有一定的解耦作用,同时可以有效减少 C 中的代码量。然而总代码量会上升。我们的目标是减少不必要的代码。 + +比如获取每一个 `section` 的行数,它的实现逻辑总是高度类似。然而由于数据源的具体实现方式不统一,所以每个数据源都要重新实现一遍。 + +### SectionObject + +首先我们来思考一个问题,数据源作为 M,它持有的 Item 长什么样?答案是一个二维数组,每个元素保存了一个 `section` 所需要的全部信息。因此除了有自己的数组(给cell用)外,还有 section 的标题等,我们把这样的元素命名为 `SectionObject`: + +``` +@interface KtTableViewSectionObject : NSObject + +@property (nonatomic, copy) NSString *headerTitle; // UITableDataSource 协议中的 titleForHeaderInSection 方法可能会用到 +@property (nonatomic, copy) NSString *footerTitle; // UITableDataSource 协议中的 titleForFooterInSection 方法可能会用到 + +@property (nonatomic, retain) NSMutableArray *items; + +- (instancetype)initWithItemArray:(NSMutableArray *)items; + +@end +``` + +### Item + +其中的 `items` 数组,应该存储了每个 cell 所需要的 `Item`,考虑到 `Cell` 的特点,基类的 `BaseItem` 可以设计成这样: + +```objc +@interface KtTableViewBaseItem : NSObject + +@property (nonatomic, retain) NSString *itemIdentifier; +@property (nonatomic, retain) UIImage *itemImage; +@property (nonatomic, retain) NSString *itemTitle; +@property (nonatomic, retain) NSString *itemSubtitle; +@property (nonatomic, retain) UIImage *itemAccessoryImage; + +- (instancetype)initWithImage:(UIImage *)image Title:(NSString *)title SubTitle:(NSString *)subTitle AccessoryImage:(UIImage *)accessoryImage; + +@end +``` + +### 父类实现代码 + +规定好了统一的数据存储格式以后,我们就可以考虑在基类中完成某些方法了。以 `- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section` 方法为例,它可以这样实现: + +```objc +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + if (self.sections.count > section) { + KtTableViewSectionObject *sectionObject = [self.sections objectAtIndex:section]; + return sectionObject.items.count; + } + return 0; +} +``` + +比较困难的是创建 `cell`,因为我们不知道 `cell` 的类型,自然也就无法调用 `alloc` 方法。除此以外,`cell` 除了创建,还需要设置 UI,这些都是数据源不应该做的事。 + +这两个问题的解决方案如下: + +1. 定义一个协议,父类返回基类 `Cell`,子类视情况返回合适的类型。 +2. 为 `Cell` 添加一个 `setObject` 方法,用于解析 Item 并更新 UI。 + +### 优势 + +经过这一番折腾,好处是相当明显的: + +1. 子类的数据源只需要实现 `cellClassForObject` 方法即可。原来的数据源方法已经在父类中被统一实现了。 +2. 每一个 Cell 只要写好自己的 `setObject` 方法,然后坐等自己被创建,被调用这个方法即可。 +3. 子类通过 `objectForRowAtIndexPath` 方法可以快速获取 item,不用重写。 + +对照 demo(SHA-1:6475496),感受一下效果。 + +# 优化代理 + +我们以之前所说的,代理协议中常用的两个方法为例,看看怎么进行优化与解耦。 + +首先是计算高度,这个逻辑并不一定在 C 完成,由于涉及到 UI,所以由 Cell 负责实现即可。而计算高度的依据就是 Object,所以我们给基类的 Cell 加上一个类方法: + +```objc ++ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(KtTableViewBaseItem *)object; +``` + +另外一类问题是以处理点击事件为代表的代理方法, 它们的主要特点是都有 `indexPath` 参数用来表示位置。然而实际在处理过程中,我们并不关系位置,关心的是这个位置上的数据。 + +因此,我们对代理方法做一层封装,使得 C 调用的方法中都是带有数据参数的。因为这个数据对象可以从数据源拿到,所以我们需要能够在代理方法中获取到数据源对象。 + +为了实现这一点, 最好的办法就是继承 `UITableView`: + +```objc +@protocol KtTableViewDelegate + +@optional + +- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath; +- (UIView *)headerViewForSectionObject:(KtTableViewSectionObject *)sectionObject atSection:(NSInteger)section; + +// 将来可以有 cell 的编辑,交换,左滑等回调 +// 这个协议继承了UITableViewDelegate ,所以自己做一层中转,VC 依然需要实现某 + +@end + +@interface KtBaseTableView : UITableView + +@property (nonatomic, assign) id ktDataSource; +@property (nonatomic, assign) id ktDelegate; + +@end +``` + +cell 高度的实现如下,调用数据源的方法获取到数据: + +```ojbc +- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath { + id dataSource = (id)tableView.dataSource; + + KtTableViewBaseItem *object = [dataSource tableView:tableView objectForRowAtIndexPath:indexPath]; + Class cls = [dataSource tableView:tableView cellClassForObject:object]; + + return [cls tableView:tableView rowHeightForObject:object]; +} +``` + +### 优势 + +通过对 `UITableViewDelegate` 的封装(其实主要是通过 `UITableView` 完成),我们获得了以下特性: + +1. C 不用关心 Cell 高度了,这个由每个 Cell 类自己负责 +2. 如果数据本身存在数据源中,那么在代理协议中它可以被传给 C,免去了 C 重新访问数据源的操作。 +3. 如果数据不存在于数据源,那么代理协议的方法会被正常转发(因为自定义的代理协议继承自 `UITableViewDelegate `) + +对照 demo(SHA-1:ca9b261),感受一下效果。 + +# 更加 MVC,更加简洁 + +在上面的两次封装中,其实我们是把 `UITableView` 持有原生的代理和数据源,改成了 `KtTableView` 持有自定义的代理和数据源。并且默认实现了很多系统的方法。 + +到目前为止,看上去一切都已经完成了,然而实际上还是存在一些可以改进的地方: + +1. 目前仍然不是 MVC 模式! +2. C 的逻辑和实现依然可以进一步简化 + +基于以上考虑, 我们实现一个 `UIViewController` 的子类,并且把数据源和代理封装到 C 中。 + +```objc +@interface KtTableViewController : UIViewController + +@property (nonatomic, strong) KtBaseTableView *tableView; +@property (nonatomic, strong) KtTableViewDataSource *dataSource; +@property (nonatomic, assign) UITableViewStyle tableViewStyle; // 用来创建 tableView + +- (instancetype)initWithStyle:(UITableViewStyle)style; + +@end +``` + +为了确保子类创建了数据源,我们把这个方法定义到协议里,并且定义为 `required`。 + +# 成果与目标 + +现在我们梳理一下经过改造的 `TableView` 该怎么用: + +1. 首先你需要创建一个继承自 `KtTableViewController` 的视图控制器,并且调用它的 `initWithStyle` 方法。 + + ```objc + KTMainViewController *mainVC = [[KTMainViewController alloc] initWithStyle:UITableViewStylePlain]; + ``` +2. 在子类 VC 中实现 `createDataSource` 方法,实现数据源的绑定。 + + ```objc + - (void)createDataSource { + self.dataSource = [[KtMainTableViewDataSource alloc] init]; // 这 一步创建了数据源 + } + ``` + +3. 在数据源中,需要指定 cell 的类型。 + + ```objc + - (Class)tableView:(UITableView *)tableView cellClassForObject:(KtTableViewBaseItem *)object { + return [KtMainTableViewCell class]; + } + ``` + +4. 在 Cell 中,需要通过解析数据,来更新 UI 并返回自己的高度。 + + ```objc + + (CGFloat)tableView:(UITableView *)tableView rowHeightForObject:(KtTableViewBaseItem *)object { + return 60; + } + // Demo 中沿用了父类的 setObject 方法。 + ``` + +### 下一步做什么? + +关于 `TableView` 的讨论远远没有结束,我列出了以下需要解决的问题 + +1. 在这种设计下,数据的回传不够方便,比如 cell 的给 C 发消息。 +2. 下拉刷新与上拉加载如何集成 +3. 网络请求的发起,与解析数据如何集成 + +关于第一个问题,其实是普通的 MVC 模式中 V 和 C 的交互问题,可以在 Cell(或者其他类) 中添加 weak 属性达到直接持有的目的,也可以定义协议。 + +问题二和三是另一大块话题,网络请求大家都会实现,但如何优雅的集成进框架,保证代码的简单和可拓展,就是一个值得深入思考,研究的问题了。我会在下次有空的时候和大家分享这个问题。 \ No newline at end of file diff --git a/NodeRequireTest/.vscode/launch.json b/NodeRequireTest/.vscode/launch.json new file mode 100644 index 0000000..95828bc --- /dev/null +++ b/NodeRequireTest/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/b.js" + } + ] +} \ No newline at end of file diff --git a/NodeRequireTest/README.md b/NodeRequireTest/README.md new file mode 100644 index 0000000..c52ea19 --- /dev/null +++ b/NodeRequireTest/README.md @@ -0,0 +1,107 @@ +这是一篇水文,讲讲踩坑的经历。 + +# 背景 + +起因是在写 Node 时,受够了 `require ('../../../../helper.js')` 这种相对路径。不够直观不谈,如果将来在别的地方用,都不能直接 copy 过来,还得重新计算相对路径,因此希望用绝对路径(换句话说就是永远相对根路径)来表示。 + +一种比较简单的方案是封装 `require` 函数: + +```js +global.rootRequire = function(name) { + return require(__dirname + '/' + name); +} +``` + +在我们的 `rootRequire` 函数中,所有的路径都会被加上 `__dirname` 的前缀,也就实现了绝对路径。 + +这么做功能上没有问题,然而似乎 VSCode 对这种写法支持得不够好(有了解的大佬还望指教),表现为以下两个问题: + +1. 虽然我们把 `rootRequire` 定义为全局的,但在别的文件中输入这个单词时,并没有自动补全 +2. 通过这种方式引入的模块,不能跳转到模块的实现,也看不到模块的内部结构,如果用 `require` 引入则没有问题。 + +经过更进一步的测试,甚至于这种写法也是不行的: + +```js +let r = require +let a = r('../test/a') +``` + +在 VSCode 中会发现 `a` 的类型为 `any` 并且丢失了很多信息。 + +# 解决方案 + +换句话说,封装 `require` 的路是行不通了,只能用原生的 `require` 函数,那么只能看看有什么办法可以影响到模块查找的流程了。 + +内置的那套流程和顺序肯定是改不了,看起来只能从 `NODE_PATH` 这个全局变量下手了。我们知道 `require` 函数会去 `NODE_PATH` 的目录里查找模块,所以只要把它设置为工程的根路径,就可以实现绝对路径加载了。试验一下,项目目录如下所示: + +``` +project + |-----main + |------index.js + |-----util + |------utils.js +``` + +很简单的定义一下 `utils.js`,就导出一个对象: + +```js +// utils.js +module.exports = { + key:' value' +} +``` + +在 `index.js` 中这么写: + +```js +let utils = require('utils/utils') +console.log(utils.key) +``` + +然后执行 `node main/index.js`,肯定会编译失败。 + +但如果指定了 `NODE_PATH` 就不一样了,此时可以正常运行: + +```shell +export NODE_PATH=$PWD && node main/index.js +``` + +# 优化 + +直接在命令行中指定 `NODE_PATH` 有两个问题: + +1. 改变了项目的启动方式,别的开发者也会受到影响,不过这一点问题不大,因为一般都是通过命令来启动的。 +2. 如果在不同的路径下启动 node,那么 `$PWD` 是会变的,这种方式不够安全。 + +所以比较好的做法是,在入口文件中指定 `NODE_PATH`,因为这个文件的路径一般不会改变。所以 `index.js` 可以改造成这样: + +```js +let path = require('path') +process.env.NODE_PATH = path.resolve(__dirname, '../') ; +require('module').Module._initPaths(); + +let utils = require('utils/utils') + +console.log(utils.key) +``` + +这种写法的好处在于,无论我们在哪里执行 `node path/to/index.js` 都会得到正确的结果。 + +最后还需要修正一下写 `require` 函数时,路径补全的问题,只要在根目录里面加上一个 `jsconfig.json` 文件并添加如下内容即可: + +```json +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "baseUrl": "./", + }, + "exclude": [ + "node_modules" + ] +} +``` + +核心在于 `"baseUrl": "./"` 这一行。这样当我们写 `utils` 这个单词的时候,就可以享受到自动补全了。 + +至此,无论是 Node 的执行,还是路径补全,抑或是定义跳转功能,都正常工作了。 \ No newline at end of file diff --git a/NodeRequireTest/jsconfig.json b/NodeRequireTest/jsconfig.json new file mode 100644 index 0000000..182a516 --- /dev/null +++ b/NodeRequireTest/jsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + // "target": "es6", + // "module": "commonjs", + "baseUrl": "./", + // "paths": { + // "*": [ + // "*" + // ] + // } + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/NodeRequireTest/main/index.js b/NodeRequireTest/main/index.js new file mode 100644 index 0000000..495b7f5 --- /dev/null +++ b/NodeRequireTest/main/index.js @@ -0,0 +1,7 @@ +let path = require('path') +process.env.NODE_PATH = path.resolve(__dirname, '../') ; +require('module').Module._initPaths(); + +let utils = require('ut') + +console.log(utils.key) \ No newline at end of file diff --git a/NodeRequireTest/package.json b/NodeRequireTest/package.json new file mode 100644 index 0000000..29efd98 --- /dev/null +++ b/NodeRequireTest/package.json @@ -0,0 +1,14 @@ +{ + "name": "require", + "version": "1.0.0", + "description": "", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/NodeRequireTest/utils/utils.js b/NodeRequireTest/utils/utils.js new file mode 100644 index 0000000..287927d --- /dev/null +++ b/NodeRequireTest/utils/utils.js @@ -0,0 +1,4 @@ + +module.exports = { + key:' value' +} \ No newline at end of file diff --git a/RunloopAndThread/RunloopAndThread.xcodeproj/project.pbxproj b/RunloopAndThread/RunloopAndThread.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b81fcd1 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread.xcodeproj/project.pbxproj @@ -0,0 +1,317 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9BAA82A81D451A0E00E5B98A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAA82A71D451A0E00E5B98A /* main.m */; }; + 9BAA82AB1D451A0E00E5B98A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAA82AA1D451A0E00E5B98A /* AppDelegate.m */; }; + 9BAA82AE1D451A0E00E5B98A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAA82AD1D451A0E00E5B98A /* ViewController.m */; }; + 9BAA82B11D451A0E00E5B98A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9BAA82AF1D451A0E00E5B98A /* Main.storyboard */; }; + 9BAA82B31D451A0E00E5B98A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9BAA82B21D451A0E00E5B98A /* Assets.xcassets */; }; + 9BAA82B61D451A0E00E5B98A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9BAA82B41D451A0E00E5B98A /* LaunchScreen.storyboard */; }; + E59118CB1D9B84FE00F25FF6 /* NSObject+DeallocBlock.m in Sources */ = {isa = PBXBuildFile; fileRef = E59118CA1D9B84FE00F25FF6 /* NSObject+DeallocBlock.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 9BAA82A31D451A0E00E5B98A /* RunloopAndThread.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RunloopAndThread.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 9BAA82A71D451A0E00E5B98A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 9BAA82A91D451A0E00E5B98A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 9BAA82AA1D451A0E00E5B98A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9BAA82AC1D451A0E00E5B98A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 9BAA82AD1D451A0E00E5B98A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 9BAA82B01D451A0E00E5B98A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 9BAA82B21D451A0E00E5B98A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 9BAA82B51D451A0E00E5B98A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 9BAA82B71D451A0E00E5B98A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + E59118C91D9B84FE00F25FF6 /* NSObject+DeallocBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+DeallocBlock.h"; sourceTree = ""; }; + E59118CA1D9B84FE00F25FF6 /* NSObject+DeallocBlock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+DeallocBlock.m"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9BAA82A01D451A0E00E5B98A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9BAA829A1D451A0E00E5B98A = { + isa = PBXGroup; + children = ( + 9BAA82A51D451A0E00E5B98A /* RunloopAndThread */, + 9BAA82A41D451A0E00E5B98A /* Products */, + ); + sourceTree = ""; + }; + 9BAA82A41D451A0E00E5B98A /* Products */ = { + isa = PBXGroup; + children = ( + 9BAA82A31D451A0E00E5B98A /* RunloopAndThread.app */, + ); + name = Products; + sourceTree = ""; + }; + 9BAA82A51D451A0E00E5B98A /* RunloopAndThread */ = { + isa = PBXGroup; + children = ( + E59118C91D9B84FE00F25FF6 /* NSObject+DeallocBlock.h */, + E59118CA1D9B84FE00F25FF6 /* NSObject+DeallocBlock.m */, + 9BAA82A91D451A0E00E5B98A /* AppDelegate.h */, + 9BAA82AA1D451A0E00E5B98A /* AppDelegate.m */, + 9BAA82AC1D451A0E00E5B98A /* ViewController.h */, + 9BAA82AD1D451A0E00E5B98A /* ViewController.m */, + 9BAA82AF1D451A0E00E5B98A /* Main.storyboard */, + 9BAA82B21D451A0E00E5B98A /* Assets.xcassets */, + 9BAA82B41D451A0E00E5B98A /* LaunchScreen.storyboard */, + 9BAA82B71D451A0E00E5B98A /* Info.plist */, + 9BAA82A61D451A0E00E5B98A /* Supporting Files */, + ); + path = RunloopAndThread; + sourceTree = ""; + }; + 9BAA82A61D451A0E00E5B98A /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 9BAA82A71D451A0E00E5B98A /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9BAA82A21D451A0E00E5B98A /* RunloopAndThread */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9BAA82BA1D451A0E00E5B98A /* Build configuration list for PBXNativeTarget "RunloopAndThread" */; + buildPhases = ( + 9BAA829F1D451A0E00E5B98A /* Sources */, + 9BAA82A01D451A0E00E5B98A /* Frameworks */, + 9BAA82A11D451A0E00E5B98A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RunloopAndThread; + productName = RunloopAndThread; + productReference = 9BAA82A31D451A0E00E5B98A /* RunloopAndThread.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9BAA829B1D451A0E00E5B98A /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0730; + ORGANIZATIONNAME = bestswifter; + TargetAttributes = { + 9BAA82A21D451A0E00E5B98A = { + CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = RN42P92PY7; + }; + }; + }; + buildConfigurationList = 9BAA829E1D451A0E00E5B98A /* Build configuration list for PBXProject "RunloopAndThread" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9BAA829A1D451A0E00E5B98A; + productRefGroup = 9BAA82A41D451A0E00E5B98A /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9BAA82A21D451A0E00E5B98A /* RunloopAndThread */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9BAA82A11D451A0E00E5B98A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9BAA82B61D451A0E00E5B98A /* LaunchScreen.storyboard in Resources */, + 9BAA82B31D451A0E00E5B98A /* Assets.xcassets in Resources */, + 9BAA82B11D451A0E00E5B98A /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9BAA829F1D451A0E00E5B98A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E59118CB1D9B84FE00F25FF6 /* NSObject+DeallocBlock.m in Sources */, + 9BAA82AE1D451A0E00E5B98A /* ViewController.m in Sources */, + 9BAA82AB1D451A0E00E5B98A /* AppDelegate.m in Sources */, + 9BAA82A81D451A0E00E5B98A /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 9BAA82AF1D451A0E00E5B98A /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9BAA82B01D451A0E00E5B98A /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 9BAA82B41D451A0E00E5B98A /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9BAA82B51D451A0E00E5B98A /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 9BAA82B81D451A0E00E5B98A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 9BAA82B91D451A0E00E5B98A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9BAA82BB1D451A0E00E5B98A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = RN42P92PY7; + INFOPLIST_FILE = RunloopAndThread/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = bestswifter.RunloopAndThread; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 9BAA82BC1D451A0E00E5B98A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = RN42P92PY7; + INFOPLIST_FILE = RunloopAndThread/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = bestswifter.RunloopAndThread; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9BAA829E1D451A0E00E5B98A /* Build configuration list for PBXProject "RunloopAndThread" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9BAA82B81D451A0E00E5B98A /* Debug */, + 9BAA82B91D451A0E00E5B98A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9BAA82BA1D451A0E00E5B98A /* Build configuration list for PBXNativeTarget "RunloopAndThread" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9BAA82BB1D451A0E00E5B98A /* Debug */, + 9BAA82BC1D451A0E00E5B98A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9BAA829B1D451A0E00E5B98A /* Project object */; +} diff --git a/RunloopAndThread/RunloopAndThread/AppDelegate.h b/RunloopAndThread/RunloopAndThread/AppDelegate.h new file mode 100644 index 0000000..fe7f9b2 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// RunloopAndThread +// +// Created by 张星宇 on 16/7/24. +// Copyright © 2016年 bestswifter. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/RunloopAndThread/RunloopAndThread/AppDelegate.m b/RunloopAndThread/RunloopAndThread/AppDelegate.m new file mode 100644 index 0000000..abb96e3 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/AppDelegate.m @@ -0,0 +1,45 @@ +// +// AppDelegate.m +// RunloopAndThread +// +// Created by 张星宇 on 16/7/24. +// Copyright © 2016年 bestswifter. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. +} + +@end diff --git a/RunloopAndThread/RunloopAndThread/Assets.xcassets/AppIcon.appiconset/Contents.json b/RunloopAndThread/RunloopAndThread/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/RunloopAndThread/RunloopAndThread/Base.lproj/LaunchScreen.storyboard b/RunloopAndThread/RunloopAndThread/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..2e721e1 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RunloopAndThread/RunloopAndThread/Base.lproj/Main.storyboard b/RunloopAndThread/RunloopAndThread/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f56d2f3 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/Base.lproj/Main.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/RunloopAndThread/RunloopAndThread/Info.plist b/RunloopAndThread/RunloopAndThread/Info.plist new file mode 100644 index 0000000..6905cc6 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/Info.plist @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/RunloopAndThread/RunloopAndThread/NSObject+DeallocBlock.h b/RunloopAndThread/RunloopAndThread/NSObject+DeallocBlock.h new file mode 100644 index 0000000..6ac38b3 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/NSObject+DeallocBlock.h @@ -0,0 +1,14 @@ +// +// NSObject+DeallocBlock.h +// pengpeng +// +// Created by jianwei.chen on 15/9/6. +// Copyright (c) 2015年 AsiaInnovations. All rights reserved. +// + +#import + +@interface NSObject (DeallocBlock) + +-(void)runAtDealloc:(dispatch_block_t)block; +@end diff --git a/RunloopAndThread/RunloopAndThread/NSObject+DeallocBlock.m b/RunloopAndThread/RunloopAndThread/NSObject+DeallocBlock.m new file mode 100644 index 0000000..c9d83e7 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/NSObject+DeallocBlock.m @@ -0,0 +1,45 @@ +// +// NSObject+DeallocBlock.m +// pengpeng +// +// Created by jianwei.chen on 15/9/6. +// Copyright (c) 2015年 AsiaInnovations. All rights reserved. +// + +#import "NSObject+DeallocBlock.h" +#import + +@interface NBDeallocBlockExecutor : NSObject{ + dispatch_block_t _block; +} +- (id)initWithBlock:(dispatch_block_t)block; +@end + +@implementation NBDeallocBlockExecutor +- (id)initWithBlock:(dispatch_block_t)aBlock +{ + self = [super init]; + if (self) { + _block = [aBlock copy]; + } + return self; +} +- (void)dealloc +{ + _block ? _block() : nil; +} +@end + + +static char *dealloc_key; +@implementation NSObject (DeallocBlock) + +-(void)runAtDealloc:(dispatch_block_t)block +{ + if(block){ + NBDeallocBlockExecutor *executor = [[NBDeallocBlockExecutor alloc] initWithBlock:block]; + objc_setAssociatedObject(self, &dealloc_key, executor, OBJC_ASSOCIATION_RETAIN);//不要强应用 + } +} + +@end diff --git a/RunloopAndThread/RunloopAndThread/ViewController.h b/RunloopAndThread/RunloopAndThread/ViewController.h new file mode 100644 index 0000000..52f0228 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// RunloopAndThread +// +// Created by 张星宇 on 16/7/24. +// Copyright © 2016年 bestswifter. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/RunloopAndThread/RunloopAndThread/ViewController.m b/RunloopAndThread/RunloopAndThread/ViewController.m new file mode 100644 index 0000000..e5b97d1 --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/ViewController.m @@ -0,0 +1,119 @@ +// +// ViewController.m +// RunloopAndThread +// +// Created by 张星宇 on 16/7/24. +// Copyright © 2016年 bestswifter. All rights reserved. +// + +#import "ViewController.h" +#import "NSObject+DeallocBlock.h" + +@interface ViewController () + +@property (strong, nonatomic) NSPort *emptyPort; +@property (strong, nonatomic) NSThread *thread; +@property (assign, nonatomic) BOOL shouldKeepRunning; + +@end + +@implementation ViewController + + +- (void)viewDidLoad { + [super viewDidLoad]; + [self memoryTest]; + NSLog(@"test"); +// [self runloopTest]; +} + +#pragma --mark 内存占用测试 +- (void)memoryTest { + for (int i = 0; i < 100000; ++i) { + //总结:test At: xcode8,ios 9.3.4 + //1,当用CFRunLoopRun(),然后调用CFRunLoopStop,此方法是后果会输出current thread,thread dealloc,current thread,thread dealloc ...所以不会用内存问题 + //2,当用 [runLoop run];,然后调用CFRunLoopStop,此方法会current thread,current thread,... 最后输出[NSThread start]: Thread creation failed with error 35.然后app卡住,然后app crash. 内存不会暴增。但是线程无法销毁 + //3,当用 [runLoop runMode:NSRunLoopCommonModes beforeDate:[NSDate distantFuture]];,然后调用CFRunLoopStop,此方法会。[ViewController performSelector:onThread:withObject:waitUntilDone:modes:]: target thread exited while waiting for the perform' crash。是因为 [runLoop runMode:NSRunLoopCommonModes beforeDate:[NSDate distantFuture]]; 无法阻塞线程,所以线程很快执行完run 方法。然后线程exit,导致奔溃(在一个退出的线程,当然这个时候线程没有释放,执行方法奔溃) + + NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil]; + [thread runAtDealloc:^{ + NSLog(@"thread dealloc"); + }]; + [thread start]; + [self performSelector:@selector(stopThread) onThread:thread withObject:nil waitUntilDone:YES]; + } + NSLog(@"test over"); +} + +- (void)stopThread { + CFRunLoopStop(CFRunLoopGetCurrent()); +// [[NSRunLoop currentRunLoop] removePort:self.emptyPort forMode:NSDefaultRunLoopMode]; + NSThread *thread = [NSThread currentThread]; + [thread cancel]; +} + +- (void)run { + @autoreleasepool { + NSLog(@"current thread = %@", [NSThread currentThread]); + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + if (!self.emptyPort) { + self.emptyPort = [NSMachPort port]; + } + [runLoop addPort:self.emptyPort forMode:NSDefaultRunLoopMode]; + // 下面这两种写法都不可取 +// [runLoop run]; + [runLoop runMode:NSRunLoopCommonModes beforeDate:[NSDate distantFuture]]; +// CFRunLoopRun(); + NSLog(@"run over"); + } +} + +# pragma --mark runloop 启动与退出测试 +- (void)runloopTest { + // 绘制按钮,点击按钮后关闭 runloop + UIButton *stopButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; + [stopButton setTitle:@"Stop Timer" forState:UIControlStateNormal]; + [stopButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [self.view addSubview:stopButton]; + [stopButton addTarget:self action:@selector(stopButtonDidClicked:) forControlEvents:UIControlEventTouchUpInside]; + +// self.shouldKeepRunning = YES; + + self.thread = [[NSThread alloc] initWithTarget:self selector:@selector(singleThread) object:nil]; + [self.thread start]; + [self performSelector:@selector(printSomething) onThread:self.thread withObject:nil waitUntilDone:YES]; +} + +- (void)singleThread { + @autoreleasepool { + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + if (!self.emptyPort) { + self.emptyPort = [NSMachPort port]; + } + [runLoop addPort:self.emptyPort forMode:NSDefaultRunLoopMode]; + CFRunLoopRun(); +// while (_shouldKeepRunning && [runLoop runMode:NSRunLoopCommonModes beforeDate:[NSDate distantFuture]]); + } +} + +- (void)printSomething { + NSLog(@"current thread = %@", [NSThread currentThread]); + [self performSelector:@selector(printSomething) withObject:nil afterDelay:1]; +} + +#pragma --mark 点击按钮退出 +- (void)stopButtonDidClicked:(id)sender { + [self performSelector:@selector(stopRunloop) onThread:self.thread withObject:nil waitUntilDone:YES]; +} + +- (void)stopRunloop { + // self.shouldKeepRunning = NO; + CFRunLoopStop(CFRunLoopGetCurrent()); +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/RunloopAndThread/RunloopAndThread/main.m b/RunloopAndThread/RunloopAndThread/main.m new file mode 100644 index 0000000..69bcf1c --- /dev/null +++ b/RunloopAndThread/RunloopAndThread/main.m @@ -0,0 +1,16 @@ +// +// main.m +// RunloopAndThread +// +// Created by 张星宇 on 16/7/24. +// Copyright © 2016年 bestswifter. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}