From e2f4fb67841a72ffe333a09053c79f8dc673d99a Mon Sep 17 00:00:00 2001 From: Luis Medrano Date: Mon, 24 Apr 2017 11:52:28 -0700 Subject: [PATCH 1/3] Adding Reachability project --- Scenarios/Reachability/README.md | 0 Scenarios/Reachability/iOSReachability | 1 + 2 files changed, 1 insertion(+) create mode 100644 Scenarios/Reachability/README.md create mode 160000 Scenarios/Reachability/iOSReachability diff --git a/Scenarios/Reachability/README.md b/Scenarios/Reachability/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Scenarios/Reachability/iOSReachability b/Scenarios/Reachability/iOSReachability new file mode 160000 index 0000000..e93096e --- /dev/null +++ b/Scenarios/Reachability/iOSReachability @@ -0,0 +1 @@ +Subproject commit e93096e88b100f5a06be46c47c5f39dd9d1cfa9b From 6f1c4ddf6dab466a53b8380406658aff00b03bf5 Mon Sep 17 00:00:00 2001 From: Luis Medrano Date: Mon, 24 Apr 2017 12:06:29 -0700 Subject: [PATCH 2/3] Resenting branch --- Scenarios/Reachability/README.md | 0 Scenarios/Reachability/iOSReachability | 1 - 2 files changed, 1 deletion(-) delete mode 100644 Scenarios/Reachability/README.md delete mode 160000 Scenarios/Reachability/iOSReachability diff --git a/Scenarios/Reachability/README.md b/Scenarios/Reachability/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/Scenarios/Reachability/iOSReachability b/Scenarios/Reachability/iOSReachability deleted file mode 160000 index e93096e..0000000 --- a/Scenarios/Reachability/iOSReachability +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e93096e88b100f5a06be46c47c5f39dd9d1cfa9b From bd5236da0fdf9a242b82ce05922afddc1db65ab8 Mon Sep 17 00:00:00 2001 From: Luis Medrano Date: Mon, 24 Apr 2017 12:15:04 -0700 Subject: [PATCH 3/3] Adding Reachability project --- Scenarios/Reachability/README.md | 0 .../iOSReachability.xcodeproj/project.pbxproj | 358 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../iOSReachability/AppDelegate.h | 17 + .../iOSReachability/AppDelegate.m | 79 ++++ .../AppIcon.appiconset/Contents.json | 38 ++ .../Base.lproj/LaunchScreen.storyboard | 27 ++ .../Base.lproj/Main.storyboard | 26 ++ .../iOSReachability/BaseTableView.h | 24 ++ .../iOSReachability/BaseTableView.m | 283 ++++++++++++++ .../Reachability/iOSReachability/Info.plist | 36 ++ .../iOSReachability/MainViewController.h | 13 + .../iOSReachability/MainViewController.m | 161 ++++++++ .../iOSReachability/Reachability.h | 64 ++++ .../iOSReachability/Reachability.m | 242 ++++++++++++ .../ReachabilityViewController.h | 14 + .../ReachabilityViewController.m | 131 +++++++ Scenarios/Reachability/iOSReachability/main.m | 16 + 18 files changed, 1536 insertions(+) create mode 100644 Scenarios/Reachability/README.md create mode 100644 Scenarios/Reachability/iOSReachability.xcodeproj/project.pbxproj create mode 100644 Scenarios/Reachability/iOSReachability.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Scenarios/Reachability/iOSReachability/AppDelegate.h create mode 100644 Scenarios/Reachability/iOSReachability/AppDelegate.m create mode 100644 Scenarios/Reachability/iOSReachability/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Scenarios/Reachability/iOSReachability/Base.lproj/LaunchScreen.storyboard create mode 100644 Scenarios/Reachability/iOSReachability/Base.lproj/Main.storyboard create mode 100644 Scenarios/Reachability/iOSReachability/BaseTableView.h create mode 100644 Scenarios/Reachability/iOSReachability/BaseTableView.m create mode 100644 Scenarios/Reachability/iOSReachability/Info.plist create mode 100644 Scenarios/Reachability/iOSReachability/MainViewController.h create mode 100644 Scenarios/Reachability/iOSReachability/MainViewController.m create mode 100644 Scenarios/Reachability/iOSReachability/Reachability.h create mode 100644 Scenarios/Reachability/iOSReachability/Reachability.m create mode 100644 Scenarios/Reachability/iOSReachability/ReachabilityViewController.h create mode 100644 Scenarios/Reachability/iOSReachability/ReachabilityViewController.m create mode 100644 Scenarios/Reachability/iOSReachability/main.m diff --git a/Scenarios/Reachability/README.md b/Scenarios/Reachability/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Scenarios/Reachability/iOSReachability.xcodeproj/project.pbxproj b/Scenarios/Reachability/iOSReachability.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b8b0f70 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability.xcodeproj/project.pbxproj @@ -0,0 +1,358 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 375717A71EA8246A00326E27 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 375717A61EA8246A00326E27 /* main.m */; }; + 375717AA1EA8246A00326E27 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 375717A91EA8246A00326E27 /* AppDelegate.m */; }; + 375717B01EA8246A00326E27 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 375717AE1EA8246A00326E27 /* Main.storyboard */; }; + 375717B21EA8246A00326E27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 375717B11EA8246A00326E27 /* Assets.xcassets */; }; + 375717B51EA8246A00326E27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 375717B31EA8246A00326E27 /* LaunchScreen.storyboard */; }; + 375717BE1EA8258100326E27 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 375717BD1EA8258100326E27 /* CoreLocation.framework */; }; + 375717C01EA825CA00326E27 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 375717BF1EA825CA00326E27 /* UIKit.framework */; }; + 375717C21EA825F100326E27 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 375717C11EA825F100326E27 /* Foundation.framework */; }; + 375717C51EA8271700326E27 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 375717C41EA8271700326E27 /* Reachability.m */; }; + 375718201EAE5C5700326E27 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3757181F1EAE5C5700326E27 /* MainViewController.m */; }; + 375718231EAE5E1E00326E27 /* ReachabilityViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 375718221EAE5E1E00326E27 /* ReachabilityViewController.m */; }; + 375718261EAE5E5600326E27 /* BaseTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 375718251EAE5E5600326E27 /* BaseTableView.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 375717A21EA8246A00326E27 /* iOSReachability.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = iOSReachability.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 375717A61EA8246A00326E27 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 375717A81EA8246A00326E27 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 375717A91EA8246A00326E27 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 375717AF1EA8246A00326E27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 375717B11EA8246A00326E27 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 375717B41EA8246A00326E27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 375717B61EA8246A00326E27 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 375717BD1EA8258100326E27 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + 375717BF1EA825CA00326E27 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 375717C11EA825F100326E27 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 375717C31EA8271700326E27 /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = ""; }; + 375717C41EA8271700326E27 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = ""; }; + 3757181E1EAE5C5700326E27 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; + 3757181F1EAE5C5700326E27 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; + 375718211EAE5E1E00326E27 /* ReachabilityViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReachabilityViewController.h; sourceTree = ""; }; + 375718221EAE5E1E00326E27 /* ReachabilityViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReachabilityViewController.m; sourceTree = ""; }; + 375718241EAE5E5600326E27 /* BaseTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseTableView.h; sourceTree = ""; }; + 375718251EAE5E5600326E27 /* BaseTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseTableView.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3757179F1EA8246A00326E27 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 375717C21EA825F100326E27 /* Foundation.framework in Frameworks */, + 375717C01EA825CA00326E27 /* UIKit.framework in Frameworks */, + 375717BE1EA8258100326E27 /* CoreLocation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 375717991EA8246A00326E27 = { + isa = PBXGroup; + children = ( + 375717A41EA8246A00326E27 /* iOSReachability */, + 375717A31EA8246A00326E27 /* Products */, + 375717BC1EA8258100326E27 /* Frameworks */, + ); + indentWidth = 4; + sourceTree = ""; + }; + 375717A31EA8246A00326E27 /* Products */ = { + isa = PBXGroup; + children = ( + 375717A21EA8246A00326E27 /* iOSReachability.app */, + ); + name = Products; + sourceTree = ""; + }; + 375717A41EA8246A00326E27 /* iOSReachability */ = { + isa = PBXGroup; + children = ( + 375718241EAE5E5600326E27 /* BaseTableView.h */, + 375718251EAE5E5600326E27 /* BaseTableView.m */, + 3757181E1EAE5C5700326E27 /* MainViewController.h */, + 3757181F1EAE5C5700326E27 /* MainViewController.m */, + 375718211EAE5E1E00326E27 /* ReachabilityViewController.h */, + 375718221EAE5E1E00326E27 /* ReachabilityViewController.m */, + 375717C31EA8271700326E27 /* Reachability.h */, + 375717C41EA8271700326E27 /* Reachability.m */, + 375717A81EA8246A00326E27 /* AppDelegate.h */, + 375717A91EA8246A00326E27 /* AppDelegate.m */, + 375717AE1EA8246A00326E27 /* Main.storyboard */, + 375717B11EA8246A00326E27 /* Assets.xcassets */, + 375717B31EA8246A00326E27 /* LaunchScreen.storyboard */, + 375717B61EA8246A00326E27 /* Info.plist */, + 375717A51EA8246A00326E27 /* Supporting Files */, + ); + path = iOSReachability; + sourceTree = ""; + }; + 375717A51EA8246A00326E27 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 375717A61EA8246A00326E27 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 375717BC1EA8258100326E27 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 375717C11EA825F100326E27 /* Foundation.framework */, + 375717BF1EA825CA00326E27 /* UIKit.framework */, + 375717BD1EA8258100326E27 /* CoreLocation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 375717A11EA8246A00326E27 /* iOSReachability */ = { + isa = PBXNativeTarget; + buildConfigurationList = 375717B91EA8246A00326E27 /* Build configuration list for PBXNativeTarget "iOSReachability" */; + buildPhases = ( + 3757179E1EA8246A00326E27 /* Sources */, + 3757179F1EA8246A00326E27 /* Frameworks */, + 375717A01EA8246A00326E27 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = iOSReachability; + productName = iOSReachability; + productReference = 375717A21EA8246A00326E27 /* iOSReachability.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3757179A1EA8246A00326E27 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = "Luis Meddrano-Zaldivar"; + TargetAttributes = { + 375717A11EA8246A00326E27 = { + CreatedOnToolsVersion = 8.3.2; + DevelopmentTeam = 44RZ7GPU2W; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 3757179D1EA8246A00326E27 /* Build configuration list for PBXProject "iOSReachability" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 375717991EA8246A00326E27; + productRefGroup = 375717A31EA8246A00326E27 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 375717A11EA8246A00326E27 /* iOSReachability */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 375717A01EA8246A00326E27 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 375717B51EA8246A00326E27 /* LaunchScreen.storyboard in Resources */, + 375717B21EA8246A00326E27 /* Assets.xcassets in Resources */, + 375717B01EA8246A00326E27 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3757179E1EA8246A00326E27 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 375718261EAE5E5600326E27 /* BaseTableView.m in Sources */, + 375717AA1EA8246A00326E27 /* AppDelegate.m in Sources */, + 375717C51EA8271700326E27 /* Reachability.m in Sources */, + 375717A71EA8246A00326E27 /* main.m in Sources */, + 375718231EAE5E1E00326E27 /* ReachabilityViewController.m in Sources */, + 375718201EAE5C5700326E27 /* MainViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 375717AE1EA8246A00326E27 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 375717AF1EA8246A00326E27 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 375717B31EA8246A00326E27 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 375717B41EA8246A00326E27 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 375717B71EA8246A00326E27 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + 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.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 375717B81EA8246A00326E27 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + 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.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 375717BA1EA8246A00326E27 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 44RZ7GPU2W; + INFOPLIST_FILE = iOSReachability/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.lemz.test.iOSReachability; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 375717BB1EA8246A00326E27 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 44RZ7GPU2W; + INFOPLIST_FILE = iOSReachability/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.lemz.test.iOSReachability; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3757179D1EA8246A00326E27 /* Build configuration list for PBXProject "iOSReachability" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 375717B71EA8246A00326E27 /* Debug */, + 375717B81EA8246A00326E27 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 375717B91EA8246A00326E27 /* Build configuration list for PBXNativeTarget "iOSReachability" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 375717BA1EA8246A00326E27 /* Debug */, + 375717BB1EA8246A00326E27 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 3757179A1EA8246A00326E27 /* Project object */; +} diff --git a/Scenarios/Reachability/iOSReachability.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Scenarios/Reachability/iOSReachability.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..185a57a --- /dev/null +++ b/Scenarios/Reachability/iOSReachability.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Scenarios/Reachability/iOSReachability/AppDelegate.h b/Scenarios/Reachability/iOSReachability/AppDelegate.h new file mode 100644 index 0000000..3293dcc --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/AppDelegate.h @@ -0,0 +1,17 @@ +// +// AppDelegate.h +// iOSReachability +// +// Created by Luis Meddrano-Zaldivar on 4/19/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + + +@end + diff --git a/Scenarios/Reachability/iOSReachability/AppDelegate.m b/Scenarios/Reachability/iOSReachability/AppDelegate.m new file mode 100644 index 0000000..1c3c37d --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/AppDelegate.m @@ -0,0 +1,79 @@ +// +// AppDelegate.m +// iOSReachability +// +// Created by Luis Meddrano-Zaldivar on 4/19/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import "AppDelegate.h" +#import "MainViewController.h" + +#ifdef WINOBJC +#import "UWP/WindowsUIViewManagement.h" +#import "UWP/WindowsFoundationMetadata.h" +#endif +#ifdef WINOBJC + +// Tell the WinObjC runtime how large to render the application +@implementation UIApplication (UIApplicationInitialStartupMode) ++ (void)setStartupDisplayMode:(WOCDisplayMode*)mode { + mode.autoMagnification = TRUE; + mode.sizeUIWindowToFit = TRUE; + mode.clampScaleToClosestExpected = FALSE; + mode.fixedWidth = 0; + mode.fixedHeight = 0; + mode.magnification = 1.0; +} +@end +#endif + + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + //Generating Navegation controller: + self.window = [[UIWindow alloc] + initWithFrame:[[UIScreen mainScreen] + bounds]]; + self.window.rootViewController = [[UINavigationController alloc] + initWithRootViewController:[[MainViewController alloc] + init]]; + [self.window makeKeyAndVisible]; + 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/Scenarios/Reachability/iOSReachability/Assets.xcassets/AppIcon.appiconset/Contents.json b/Scenarios/Reachability/iOSReachability/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/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/Scenarios/Reachability/iOSReachability/Base.lproj/LaunchScreen.storyboard b/Scenarios/Reachability/iOSReachability/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Scenarios/Reachability/iOSReachability/Base.lproj/Main.storyboard b/Scenarios/Reachability/iOSReachability/Base.lproj/Main.storyboard new file mode 100644 index 0000000..4529698 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Scenarios/Reachability/iOSReachability/BaseTableView.h b/Scenarios/Reachability/iOSReachability/BaseTableView.h new file mode 100644 index 0000000..23e3e78 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/BaseTableView.h @@ -0,0 +1,24 @@ +// +// BaseTableView.h +// ObjCTableViewNoNib +// +// Created by Luis Meddrano-Zaldivar on 4/21/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import + +@interface BaseTableView : UIViewController + +@property NSArray *content; +@property UITableView *tableView; +@property NSMutableAttributedString* bufferedOutText; +@property UITextView *delegateOutputTextView; + +-(void)appendToPrintBuffer:(id)format, ...; +-(void)clearLogFromTextView; +-(void)printColoredDebugInfo:(NSString*) string using:(UIColor*)color ; +-(void)printAndscrollDelegateTextViewToBottom; +-(void)configurePropertiesAndViews; + +@end diff --git a/Scenarios/Reachability/iOSReachability/BaseTableView.m b/Scenarios/Reachability/iOSReachability/BaseTableView.m new file mode 100644 index 0000000..ce2fa99 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/BaseTableView.m @@ -0,0 +1,283 @@ +// +// BaseTableView.m +// ObjCTableViewNoNib +// +// Created by Luis Meddrano-Zaldivar on 4/21/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import "BaseTableView.h" + +@interface BaseTableView () + +@property (nonatomic,strong) UIView *topContainer; +@property (nonatomic,strong) UIView *bottomContainer; +@property (nonatomic,strong) UIButton *deleteLogButton; + +@end + +@implementation BaseTableView + + +-(void)configurePropertiesAndViews +{ + [self settingProperties]; + [self loadingViews]; + [self settingUIConstrains]; + +} + +#pragma tableView/UITextView delegate methods: + +- (BOOL)textViewShouldBeginEditing:(UITextView *)textView { + return NO; +} + +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.content.count; +} + +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + NSAttributedString *str = [[NSAttributedString alloc] initWithString:self.content[indexPath.row]]; + CGRect rect = [str boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingUsesDeviceMetrics context:nil]; + return rect.size.height + 40; +} + +-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ + NSString* cellID = @"buttonCell"; + UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellID]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; + } + cell.backgroundColor = [UIColor clearColor]; + cell.textLabel.numberOfLines = 0; + cell.textLabel.text = self.content[indexPath.row]; + cell.textLabel.textAlignment = NSTextAlignmentCenter; + return cell; +} + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + [tableView deselectRowAtIndexPath:indexPath animated:true]; +} + +- (void)clearLogFromTextView { + void (^block)() = ^{ + @synchronized(self) { + self.bufferedOutText = [[NSMutableAttributedString alloc] initWithString:@"\n"]; + self.delegateOutputTextView.text = @""; + } + }; + dispatch_async(dispatch_get_main_queue(), block); +} + +- (void)appendToPrintBuffer:(id)format, ... { + va_list ap; + va_start(ap, format); + + NSString* newString = [[NSString alloc] initWithFormat:[format description] arguments:ap]; + void (^block)() = ^{ + @synchronized(self.bufferedOutText) { + if ([format isKindOfClass:[NSAttributedString class]]) { + [self.bufferedOutText appendAttributedString:format]; + [self.bufferedOutText appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]]; + }else { + [self.bufferedOutText appendAttributedString:[[NSAttributedString alloc] initWithString:newString]]; + [self.bufferedOutText appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]]; + } + } + }; + dispatch_async(dispatch_get_main_queue(), block); + va_end(ap); +} + +-(void)printColoredDebugInfo:(NSString*) string using:(UIColor*)color { + __weak typeof(self) weakSelf = self; + NSMutableAttributedString *printString = [[NSMutableAttributedString alloc] init]; + [printString appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@", string]]]; + [printString addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, [printString length])]; + dispatch_async(dispatch_get_main_queue(), ^{ + [weakSelf appendToPrintBuffer:printString]; + }); +} + +-(void)printAndscrollDelegateTextViewToBottom { + dispatch_async(dispatch_get_main_queue(), ^{ + NSMutableAttributedString* textViewString = [self.delegateOutputTextView.attributedText mutableCopy]; + [textViewString appendAttributedString:self.bufferedOutText]; + self.delegateOutputTextView.attributedText = textViewString; + if(_bufferedOutText.length > 0 ) { + NSRange bottom = NSMakeRange(self.delegateOutputTextView.text.length -1, 1); + [self.delegateOutputTextView scrollRangeToVisible:bottom]; + self.bufferedOutText = [[NSMutableAttributedString alloc] initWithString:@"\n"]; + } + }); +} + +-(void)settingUIConstrains +{ + NSLayoutConstraint *topContainerTopLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.view + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self.topContainer + attribute:NSLayoutAttributeTop + multiplier:1.f constant:0.f]; + NSLayoutConstraint *topContainerBottomLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.topContainer + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.bottomContainer + attribute:NSLayoutAttributeTop + multiplier:1.f constant:0.f]; + NSLayoutConstraint *topContainerLeftLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.view + attribute:NSLayoutAttributeLeft + relatedBy:NSLayoutRelationEqual + toItem:self.topContainer + attribute:NSLayoutAttributeLeft + multiplier:1.f constant:0.f]; + NSLayoutConstraint *topContainerRightLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.view + attribute:NSLayoutAttributeRight + relatedBy:NSLayoutRelationEqual + toItem:self.topContainer + attribute:NSLayoutAttributeRight + multiplier:1.f constant:0.f]; + + NSLayoutConstraint *bottomContainerHeightLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.bottomContainer + attribute:NSLayoutAttributeHeight + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1.f constant:350.f]; + NSLayoutConstraint *bottomContainerleftLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.view + attribute:NSLayoutAttributeLeft + relatedBy:NSLayoutRelationEqual + toItem:self.bottomContainer + attribute:NSLayoutAttributeLeft + multiplier:1.f constant:0.f]; + NSLayoutConstraint *bottomContainerRightLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.view + attribute:NSLayoutAttributeRight + relatedBy:NSLayoutRelationEqual + toItem:self.bottomContainer + attribute:NSLayoutAttributeRight + multiplier:1.f constant:0.f]; + NSLayoutConstraint *bottomContainerBottomLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.bottomContainer + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.view + attribute:NSLayoutAttributeBottom + multiplier:1.f constant:0.f]; + + NSDictionary *topContainerviews = NSDictionaryOfVariableBindings(_tableView); + [self.topContainer addConstraints:[NSLayoutConstraint constraintsWithVisualFormat: + @"H:|[_tableView]|" options:0 metrics:nil views:topContainerviews]]; + [self.topContainer addConstraints:[NSLayoutConstraint constraintsWithVisualFormat: + @"V:|-40-[_tableView]-0-|" options:0 metrics:nil views:topContainerviews]]; + + NSDictionary *bottomContainerViews = NSDictionaryOfVariableBindings(_delegateOutputTextView); + [self.bottomContainer addConstraints:[NSLayoutConstraint constraintsWithVisualFormat: + @"H:|[_delegateOutputTextView]|" options:0 metrics:nil views:bottomContainerViews]]; + [self.bottomContainer addConstraints:[NSLayoutConstraint constraintsWithVisualFormat: + @"V:|[_delegateOutputTextView]|" options:0 metrics:nil views:bottomContainerViews]]; + + [self.view addConstraint:topContainerTopLayoutConstraints]; + [self.view addConstraint:topContainerBottomLayoutConstraints]; + [self.view addConstraint:topContainerLeftLayoutConstraints]; + [self.view addConstraint:topContainerRightLayoutConstraints]; + [self.view addConstraint:bottomContainerHeightLayoutConstraints]; + [self.view addConstraint:bottomContainerleftLayoutConstraints]; + [self.view addConstraint:bottomContainerRightLayoutConstraints]; + [self.view addConstraint:bottomContainerBottomLayoutConstraints]; + + NSLayoutConstraint *topDLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.bottomContainer + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self.deleteLogButton + attribute:NSLayoutAttributeTop + multiplier:1.f constant:0.f]; + NSLayoutConstraint *widthDLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.deleteLogButton + attribute:NSLayoutAttributeWidth + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1.f constant:60.f]; + NSLayoutConstraint *heightDLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.deleteLogButton + attribute:NSLayoutAttributeHeight + relatedBy:NSLayoutRelationEqual + toItem:nil + attribute:NSLayoutAttributeNotAnAttribute + multiplier:1.f constant:40.f]; + +#if WINOBJC + NSLayoutConstraint *rightDLayoutConstraints = [NSLayoutConstraint constraintWithItem:_deleteLogButton + attribute:NSLayoutAttributeRightMargin + relatedBy:NSLayoutRelationEqual + toItem:_bottomContainer + attribute:NSLayoutAttributeRightMargin + multiplier:1.f constant:-12.f]; + +#else + NSLayoutConstraint *rightDLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.deleteLogButton + attribute:NSLayoutAttributeRightMargin + relatedBy:NSLayoutRelationEqual + toItem:self.bottomContainer + attribute:NSLayoutAttributeRightMargin + multiplier:1.f constant:0.f]; + +#endif + + [self.bottomContainer addConstraint:widthDLayoutConstraints]; + [self.bottomContainer addConstraint:heightDLayoutConstraints]; + [self.bottomContainer addConstraint:topDLayoutConstraints]; + [self.bottomContainer addConstraint:rightDLayoutConstraints]; +} + +-(void)loadingViews +{ + [self.topContainer addSubview:self.tableView]; + [self.bottomContainer addSubview:self.delegateOutputTextView]; + [self.bottomContainer addSubview:self.deleteLogButton]; + [self.view addSubview:self.topContainer]; + [self.view addSubview:self.bottomContainer]; +} + +-(void)settingProperties +{ + // Initilization of properties: + self.bufferedOutText = [[NSMutableAttributedString alloc] init]; + self.topContainer = [[UIView alloc] init]; + self.tableView = [[UITableView alloc] init]; + self.bottomContainer = [[UIView alloc] init]; + self.deleteLogButton = [[UIButton alloc] init]; + self.delegateOutputTextView = [[UITextView alloc] init]; + + //Config tableView + self.tableView.delegate = self; + self.tableView.dataSource = self; + self.tableView.backgroundColor = [UIColor clearColor]; + self.tableView.translatesAutoresizingMaskIntoConstraints = false; + self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; + + //Config topContainer: + self.topContainer.translatesAutoresizingMaskIntoConstraints = false; + self.topContainer.tag = 111; + self.topContainer.backgroundColor = [UIColor colorWithWhite:0.5 alpha:1.0]; + + //Config bottomContainer: + self.bottomContainer.translatesAutoresizingMaskIntoConstraints = false; + self.bottomContainer.tag = 222; + + //Config delegateOutputTextView: + + self.delegateOutputTextView.translatesAutoresizingMaskIntoConstraints = false; + self.delegateOutputTextView.backgroundColor = [UIColor whiteColor]; + self.delegateOutputTextView.editable = NO; + self.delegateOutputTextView.delegate = self; + + //Config deleteLogButton + self.deleteLogButton.backgroundColor = [UIColor redColor]; + self.deleteLogButton.translatesAutoresizingMaskIntoConstraints = false; + [self.deleteLogButton setTitle:@"clear" forState:UIControlStateNormal]; + [self.deleteLogButton addTarget:self action:@selector(clearLogFromTextView) forControlEvents:UIControlEventTouchDown]; + +} + +@end diff --git a/Scenarios/Reachability/iOSReachability/Info.plist b/Scenarios/Reachability/iOSReachability/Info.plist new file mode 100644 index 0000000..b8901ee --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/Info.plist @@ -0,0 +1,36 @@ + + + + + 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 + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Scenarios/Reachability/iOSReachability/MainViewController.h b/Scenarios/Reachability/iOSReachability/MainViewController.h new file mode 100644 index 0000000..e1c4178 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/MainViewController.h @@ -0,0 +1,13 @@ +// +// MainViewController.h +// iOSReachability +// +// Created by Luis Meddrano-Zaldivar on 4/24/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import + +@interface MainViewController : UIViewController + +@end diff --git a/Scenarios/Reachability/iOSReachability/MainViewController.m b/Scenarios/Reachability/iOSReachability/MainViewController.m new file mode 100644 index 0000000..29fc416 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/MainViewController.m @@ -0,0 +1,161 @@ +// +// MainViewController.m +// iOSReachability +// +// Created by Luis Meddrano-Zaldivar on 4/24/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import "MainViewController.h" +#import "ReachabilityViewController.h" + + +@interface MainViewController () + +@property (nonatomic,strong) NSArray *content; +@property (nonatomic,strong) UITableView *tableView; +@property (nonatomic,strong) UILabel *mainLabel; + + +@end + +@implementation MainViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self generatingListOfContentForTableView]; + [self generatingTitleLabel]; + [self configTableView]; + [self configUILayout]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +-(void)generatingListOfContentForTableView +{ + self.content = @[@"Test Reachability"]; +} + +-(void)configTableView +{ + self.tableView = [[UITableView alloc] init]; + self.tableView.delegate = self; + self.tableView.dataSource = self; + self.tableView.translatesAutoresizingMaskIntoConstraints = false; + self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; + [self.view addSubview:self.tableView]; +} + +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return _content.count; +} + +-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ + NSString* cellID = @"buttonCell"; + UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:cellID]; + if (cell == nil) { + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; + } + cell.textLabel.text = _content[indexPath.row]; + cell.textLabel.textAlignment = NSTextAlignmentCenter; + cell.textLabel.numberOfLines = 0; + cell.backgroundColor = [UIColor clearColor]; + + return cell; +} + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + [tableView deselectRowAtIndexPath:indexPath animated:false]; + switch (indexPath.row) { + case 0: + [[self navigationController] pushViewController:[[ReachabilityViewController alloc] init] animated:true]; + break; + default: + break; + } +} + +-(void)configUILayout +{ + NSLayoutConstraint *topCLayoutConstraints = [NSLayoutConstraint constraintWithItem:[self topLayoutGuide] + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.mainLabel + attribute:NSLayoutAttributeTop + multiplier:1.f constant:0.f]; + NSLayoutConstraint *leftCLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.view + attribute:NSLayoutAttributeLeft + relatedBy:NSLayoutRelationEqual + toItem:self.mainLabel + attribute:NSLayoutAttributeLeft + multiplier:1.f constant:0.f]; + NSLayoutConstraint *rightCLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.view + attribute:NSLayoutAttributeRight + relatedBy:NSLayoutRelationEqual + toItem:self.mainLabel + attribute:NSLayoutAttributeRight + multiplier:1.f constant:0.f]; + NSLayoutConstraint *widthCLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.mainLabel + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:[self topLayoutGuide] + attribute:NSLayoutAttributeBottom + multiplier:1.f constant:40.f]; + + NSLayoutConstraint *topTLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.tableView + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self.mainLabel + attribute:NSLayoutAttributeBottom + multiplier:1.f constant:0.f]; + NSLayoutConstraint *leftTLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.tableView + attribute:NSLayoutAttributeLeft + relatedBy:NSLayoutRelationEqual + toItem:self.view + attribute:NSLayoutAttributeLeft + multiplier:1.f constant:0.f]; + NSLayoutConstraint *rightTLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.tableView + attribute:NSLayoutAttributeRight + relatedBy:NSLayoutRelationEqual + toItem:[self view] + attribute:NSLayoutAttributeRight + multiplier:1.f constant:0.f]; + NSLayoutConstraint *bottomTLayoutConstraints = [NSLayoutConstraint constraintWithItem:self.tableView + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.view + attribute:NSLayoutAttributeBottom + multiplier:1.f constant:0.f]; + [self.view addConstraint:topCLayoutConstraints]; + [self.view addConstraint:widthCLayoutConstraints]; + [self.view addConstraint:leftCLayoutConstraints]; + [self.view addConstraint:rightCLayoutConstraints]; + [self.view addConstraint:topCLayoutConstraints]; + [self.view addConstraint:leftTLayoutConstraints]; + [self.view addConstraint:leftTLayoutConstraints]; + [self.view addConstraint:rightCLayoutConstraints]; + [self.view addConstraint:bottomTLayoutConstraints]; + [self.view addConstraint:topTLayoutConstraints]; + [self.view addConstraint:rightTLayoutConstraints]; + + +} + +-(void)generatingTitleLabel +{ + self.mainLabel = [[UILabel alloc] init]; + [self.mainLabel setText:@"iOS Reachability"]; + [self.mainLabel setLineBreakMode:NSLineBreakByWordWrapping]; + [self.mainLabel setNumberOfLines:0]; + [self.mainLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; + [self.mainLabel setBackgroundColor:[UIColor lightGrayColor]]; + [self.mainLabel setTextColor:[UIColor whiteColor]]; + [self.mainLabel setTextAlignment:NSTextAlignmentCenter]; + [[self view] addSubview:self.mainLabel]; +} + + +@end diff --git a/Scenarios/Reachability/iOSReachability/Reachability.h b/Scenarios/Reachability/iOSReachability/Reachability.h new file mode 100644 index 0000000..50c048c --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/Reachability.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2016 Apple Inc. All Rights Reserved. + See LICENSE.txt for this sample’s licensing information + + Abstract: + Basic demonstration of how to use the SystemConfiguration Reachablity APIs. + */ + +#import +#import +#import + + +typedef enum : NSInteger { + NotReachable = 0, + ReachableViaWiFi, + ReachableViaWWAN +} NetworkStatus; + +#pragma mark IPv6 Support +//Reachability fully support IPv6. For full details, see ReadMe.md. + + +extern NSString *kReachabilityChangedNotification; + + +@interface Reachability : NSObject + +/*! + * Use to check the reachability of a given host name. + */ ++ (instancetype)reachabilityWithHostName:(NSString *)hostName; + +/*! + * Use to check the reachability of a given IP address. + */ ++ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress; + +/*! + * Checks whether the default route is available. Should be used by applications that do not connect to a particular host. + */ ++ (instancetype)reachabilityForInternetConnection; + + +#pragma mark reachabilityForLocalWiFi +//reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information. +//+ (instancetype)reachabilityForLocalWiFi; + +/*! + * Start listening for reachability notifications on the current run loop. + */ +- (BOOL)startNotifier; +- (void)stopNotifier; + +- (NetworkStatus)currentReachabilityStatus; + +/*! + * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand. + */ +- (BOOL)connectionRequired; + +@end + + diff --git a/Scenarios/Reachability/iOSReachability/Reachability.m b/Scenarios/Reachability/iOSReachability/Reachability.m new file mode 100644 index 0000000..f081a16 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/Reachability.m @@ -0,0 +1,242 @@ +/* + Copyright (C) 2016 Apple Inc. All Rights Reserved. + See LICENSE.txt for this sample’s licensing information + + Abstract: + Basic demonstration of how to use the SystemConfiguration Reachablity APIs. + */ + +#import +#import +#import +#import +#import + +#import + +#import "Reachability.h" + +#pragma mark IPv6 Support +//Reachability fully support IPv6. For full details, see ReadMe.md. + + +NSString *kReachabilityChangedNotification = @"kNetworkReachabilityChangedNotification"; + + +#pragma mark - Supporting functions + +#define kShouldPrintReachabilityFlags 1 + +static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment) +{ +#if kShouldPrintReachabilityFlags + + NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n", + (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', + (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', + + (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', + (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', + (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', + (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-', + comment + ); +#endif +} + + +static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) +{ +#pragma unused (target, flags) + NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback"); + NSCAssert([(__bridge NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback"); + + Reachability* noteObject = (__bridge Reachability *)info; + // Post a notification to notify the client that the network reachability changed. + [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject]; +} + + +#pragma mark - Reachability implementation + +@implementation Reachability +{ + SCNetworkReachabilityRef _reachabilityRef; +} + ++ (instancetype)reachabilityWithHostName:(NSString *)hostName +{ + Reachability* returnValue = NULL; + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]); + if (reachability != NULL) + { + returnValue= [[self alloc] init]; + if (returnValue != NULL) + { + returnValue->_reachabilityRef = reachability; + } + else { + CFRelease(reachability); + } + } + return returnValue; +} + + ++ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress +{ + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, hostAddress); + + Reachability* returnValue = NULL; + + if (reachability != NULL) + { + returnValue = [[self alloc] init]; + if (returnValue != NULL) + { + returnValue->_reachabilityRef = reachability; + } + else { + CFRelease(reachability); + } + } + return returnValue; +} + + ++ (instancetype)reachabilityForInternetConnection +{ + struct sockaddr_in zeroAddress; + bzero(&zeroAddress, sizeof(zeroAddress)); + zeroAddress.sin_len = sizeof(zeroAddress); + zeroAddress.sin_family = AF_INET; + + return [self reachabilityWithAddress: (const struct sockaddr *) &zeroAddress]; +} + +#pragma mark reachabilityForLocalWiFi +//reachabilityForLocalWiFi has been removed from the sample. See ReadMe.md for more information. +//+ (instancetype)reachabilityForLocalWiFi + + + +#pragma mark - Start and stop notifier + +- (BOOL)startNotifier +{ + BOOL returnValue = NO; + SCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL}; + + if (SCNetworkReachabilitySetCallback(_reachabilityRef, ReachabilityCallback, &context)) + { + if (SCNetworkReachabilityScheduleWithRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) + { + returnValue = YES; + } + } + + return returnValue; +} + + +- (void)stopNotifier +{ + if (_reachabilityRef != NULL) + { + SCNetworkReachabilityUnscheduleFromRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + } +} + + +- (void)dealloc +{ + [self stopNotifier]; + if (_reachabilityRef != NULL) + { + CFRelease(_reachabilityRef); + } +} + + +#pragma mark - Network Flag Handling + +- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags +{ + PrintReachabilityFlags(flags, "networkStatusForFlags"); + if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) + { + // The target host is not reachable. + return NotReachable; + } + + NetworkStatus returnValue = NotReachable; + + if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) + { + /* + If the target host is reachable and no connection is required then we'll assume (for now) that you're on Wi-Fi... + */ + returnValue = ReachableViaWiFi; + } + + if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || + (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)) + { + /* + ... and the connection is on-demand (or on-traffic) if the calling application is using the CFSocketStream or higher APIs... + */ + + if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) + { + /* + ... and no [user] intervention is needed... + */ + returnValue = ReachableViaWiFi; + } + } + + if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) + { + /* + ... but WWAN connections are OK if the calling application is using the CFNetwork APIs. + */ + returnValue = ReachableViaWWAN; + } + + return returnValue; +} + + +- (BOOL)connectionRequired +{ + NSAssert(_reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef"); + SCNetworkReachabilityFlags flags; + + if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) + { + return (flags & kSCNetworkReachabilityFlagsConnectionRequired); + } + + return NO; +} + + +- (NetworkStatus)currentReachabilityStatus +{ + NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef"); + NetworkStatus returnValue = NotReachable; + SCNetworkReachabilityFlags flags; + + if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) + { + returnValue = [self networkStatusForFlags:flags]; + } + + return returnValue; +} + + +@end diff --git a/Scenarios/Reachability/iOSReachability/ReachabilityViewController.h b/Scenarios/Reachability/iOSReachability/ReachabilityViewController.h new file mode 100644 index 0000000..9a70187 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/ReachabilityViewController.h @@ -0,0 +1,14 @@ +// +// ReachabilityViewController.h +// iOSReachability +// +// Created by Luis Meddrano-Zaldivar on 4/24/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import +#import "BaseTableView.h" + +@interface ReachabilityViewController : BaseTableView + +@end diff --git a/Scenarios/Reachability/iOSReachability/ReachabilityViewController.m b/Scenarios/Reachability/iOSReachability/ReachabilityViewController.m new file mode 100644 index 0000000..e85f29f --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/ReachabilityViewController.m @@ -0,0 +1,131 @@ +// +// ReachabilityViewController.m +// iOSReachability +// +// Created by Luis Meddrano-Zaldivar on 4/24/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import "ReachabilityViewController.h" +#import "Reachability.h" + + +@interface ReachabilityViewController () + +@property (nonatomic) Reachability *hostReachability; +@property (nonatomic) Reachability *internetReachability; + +@end + +@implementation ReachabilityViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.title = @"Testing Reachability"; + self.content = @[@"Reachability Output:"]; + [self configurePropertiesAndViews]; + [self configAndSettingReachability]; +} + +-(void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:animated]; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:kReachabilityChangedNotification + object:nil]; +} + +-(void)configAndSettingReachability +{ + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil]; + NSString *remoteHostName = @"luduscella.com"; + NSString *remoteHostLabelFormatString = NSLocalizedString(@"Remote Host: %@", @"Remote host label format string"); + [self logToBottonView:[NSString stringWithFormat:remoteHostLabelFormatString, remoteHostName]]; + self.hostReachability = [Reachability reachabilityWithHostName:remoteHostName]; + [self.hostReachability startNotifier]; + [self updateInterfaceWithReachability:self.hostReachability]; + + self.internetReachability = [Reachability reachabilityForInternetConnection]; + [self.internetReachability startNotifier]; + [self updateInterfaceWithReachability:self.internetReachability]; +} + +- (void)updateInterfaceWithReachability:(Reachability *)reachability +{ + if (reachability == self.hostReachability) + { + [self updateReachabilityStatus:reachability]; + BOOL connectionRequired = [reachability connectionRequired]; + + NSString *baseLabelText = @""; + + if (connectionRequired) + { + baseLabelText = NSLocalizedString(@"Cellular data network is available.\nInternet traffic will be routed through it after a connection is established.", @"Reachability text if a connection is required"); + } + else + { + baseLabelText = NSLocalizedString(@"Cellular data network is active.\nInternet traffic will be routed through it.", @"Reachability text if a connection is not required"); + } + [self logToBottonView:baseLabelText]; + } + + if (reachability == self.internetReachability) + { + [self updateReachabilityStatus:reachability]; + } +} + +-(void)updateReachabilityStatus:(Reachability *)reachability +{ + NetworkStatus netStatus = [reachability currentReachabilityStatus]; + BOOL connectionRequired = [reachability connectionRequired]; + NSString *statusString = @""; + + switch (netStatus) + { + case NotReachable: { + statusString = NSLocalizedString(@"Access Not Available", @"Text field text for access is not available"); + + connectionRequired = NO; + break; + } + case ReachableViaWWAN: { + statusString = NSLocalizedString(@"Reachable WWAN", @""); + + break; + } + case ReachableViaWiFi: { + statusString= NSLocalizedString(@"Reachable WiFi", @""); + break; + } + } + if (connectionRequired) + { + NSString *connectionRequiredFormatString = NSLocalizedString(@"%@, Connection Required", @"Concatenation of status string with connection requirement"); + statusString= [NSString stringWithFormat:connectionRequiredFormatString, statusString]; + } + + [self logToBottonView:statusString]; +} + +- (void) reachabilityChanged:(NSNotification *)note +{ + Reachability* curReach = [note object]; + NSParameterAssert([curReach isKindOfClass:[Reachability class]]); + [self updateInterfaceWithReachability:curReach]; +} + +-(void)logToBottonView:(NSString*)msg +{ + __weak typeof(self) weakSelf = self; + NSLog(@"%@",msg); + [weakSelf appendToPrintBuffer:msg]; + [weakSelf printAndscrollDelegateTextViewToBottom]; + +} + + + + +@end diff --git a/Scenarios/Reachability/iOSReachability/main.m b/Scenarios/Reachability/iOSReachability/main.m new file mode 100644 index 0000000..f850021 --- /dev/null +++ b/Scenarios/Reachability/iOSReachability/main.m @@ -0,0 +1,16 @@ +// +// main.m +// iOSReachability +// +// Created by Luis Meddrano-Zaldivar on 4/19/17. +// Copyright © 2017 Luis Meddrano-Zaldivar. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +}