├── .gitignore ├── .travis.yml ├── LICENSE ├── NotifyDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── NotifyDemo.xcscheme ├── NotifyDemo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── NotifyDemoTests ├── Info.plist └── NotifyDemoTests.swift ├── README.md ├── ZRNotify.podspec ├── ZRNotify └── ZRNotify.swift └── ZRNotifyDemo ├── Podfile ├── Podfile.lock ├── ZRNotifyDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── ZRNotifyDemo.xcworkspace └── contents.xcworkspacedata └── ZRNotifyDemo ├── AppDelegate.swift ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist └── ViewController.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | branches: 4 | only: 5 | - master 6 | 7 | xcode_project: NotifyDemo.xcodeproj 8 | xcode_scheme: NotifyDemoTests 9 | osx_image: xcode9 10 | xcode_sdk: iphonesimulator10.0 11 | 12 | script: 13 | - xcodebuild test -project NotifyDemo.xcodeproj -scheme "NotifyDemo" -destination "platform=iOS Simulator,name=iPhone 6s" 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Zero.Lee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NotifyDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C03B64F21FD667D800D93CAA /* ZRNotify.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03B64F11FD667D800D93CAA /* ZRNotify.swift */; }; 11 | C0F600ED1FD642B2006C242A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F600EC1FD642B2006C242A /* AppDelegate.swift */; }; 12 | C0F600EF1FD642B2006C242A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F600EE1FD642B2006C242A /* ViewController.swift */; }; 13 | C0F600F21FD642B2006C242A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0F600F01FD642B2006C242A /* Main.storyboard */; }; 14 | C0F600F41FD642B2006C242A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C0F600F31FD642B2006C242A /* Assets.xcassets */; }; 15 | C0F600F71FD642B2006C242A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0F600F51FD642B2006C242A /* LaunchScreen.storyboard */; }; 16 | C0F601021FD642B3006C242A /* NotifyDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0F601011FD642B3006C242A /* NotifyDemoTests.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | C0F600FE1FD642B3006C242A /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = C0F600E11FD642B2006C242A /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = C0F600E81FD642B2006C242A; 25 | remoteInfo = NotifyDemo; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | C03B64F11FD667D800D93CAA /* ZRNotify.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZRNotify.swift; sourceTree = ""; }; 31 | C0F600E91FD642B2006C242A /* NotifyDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NotifyDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | C0F600EC1FD642B2006C242A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33 | C0F600EE1FD642B2006C242A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 34 | C0F600F11FD642B2006C242A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 35 | C0F600F31FD642B2006C242A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 36 | C0F600F61FD642B2006C242A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 37 | C0F600F81FD642B2006C242A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 38 | C0F600FD1FD642B3006C242A /* NotifyDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NotifyDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | C0F601011FD642B3006C242A /* NotifyDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotifyDemoTests.swift; sourceTree = ""; }; 40 | C0F601031FD642B3006C242A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | C0F600E61FD642B2006C242A /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | C0F600FA1FD642B3006C242A /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | C03B64F01FD667D800D93CAA /* ZRNotify */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | C03B64F11FD667D800D93CAA /* ZRNotify.swift */, 65 | ); 66 | path = ZRNotify; 67 | sourceTree = SOURCE_ROOT; 68 | }; 69 | C0F600E01FD642B2006C242A = { 70 | isa = PBXGroup; 71 | children = ( 72 | C0F600EB1FD642B2006C242A /* NotifyDemo */, 73 | C0F601001FD642B3006C242A /* NotifyDemoTests */, 74 | C0F600EA1FD642B2006C242A /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | C0F600EA1FD642B2006C242A /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | C0F600E91FD642B2006C242A /* NotifyDemo.app */, 82 | C0F600FD1FD642B3006C242A /* NotifyDemoTests.xctest */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | C0F600EB1FD642B2006C242A /* NotifyDemo */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | C03B64F01FD667D800D93CAA /* ZRNotify */, 91 | C0F600EC1FD642B2006C242A /* AppDelegate.swift */, 92 | C0F600EE1FD642B2006C242A /* ViewController.swift */, 93 | C0F600F01FD642B2006C242A /* Main.storyboard */, 94 | C0F600F31FD642B2006C242A /* Assets.xcassets */, 95 | C0F600F51FD642B2006C242A /* LaunchScreen.storyboard */, 96 | C0F600F81FD642B2006C242A /* Info.plist */, 97 | ); 98 | path = NotifyDemo; 99 | sourceTree = ""; 100 | }; 101 | C0F601001FD642B3006C242A /* NotifyDemoTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | C0F601011FD642B3006C242A /* NotifyDemoTests.swift */, 105 | C0F601031FD642B3006C242A /* Info.plist */, 106 | ); 107 | path = NotifyDemoTests; 108 | sourceTree = ""; 109 | }; 110 | /* End PBXGroup section */ 111 | 112 | /* Begin PBXNativeTarget section */ 113 | C0F600E81FD642B2006C242A /* NotifyDemo */ = { 114 | isa = PBXNativeTarget; 115 | buildConfigurationList = C0F601061FD642B3006C242A /* Build configuration list for PBXNativeTarget "NotifyDemo" */; 116 | buildPhases = ( 117 | C0F600E51FD642B2006C242A /* Sources */, 118 | C0F600E61FD642B2006C242A /* Frameworks */, 119 | C0F600E71FD642B2006C242A /* Resources */, 120 | ); 121 | buildRules = ( 122 | ); 123 | dependencies = ( 124 | ); 125 | name = NotifyDemo; 126 | productName = NotifyDemo; 127 | productReference = C0F600E91FD642B2006C242A /* NotifyDemo.app */; 128 | productType = "com.apple.product-type.application"; 129 | }; 130 | C0F600FC1FD642B3006C242A /* NotifyDemoTests */ = { 131 | isa = PBXNativeTarget; 132 | buildConfigurationList = C0F601091FD642B3006C242A /* Build configuration list for PBXNativeTarget "NotifyDemoTests" */; 133 | buildPhases = ( 134 | C0F600F91FD642B3006C242A /* Sources */, 135 | C0F600FA1FD642B3006C242A /* Frameworks */, 136 | C0F600FB1FD642B3006C242A /* Resources */, 137 | ); 138 | buildRules = ( 139 | ); 140 | dependencies = ( 141 | C0F600FF1FD642B3006C242A /* PBXTargetDependency */, 142 | ); 143 | name = NotifyDemoTests; 144 | productName = NotifyDemoTests; 145 | productReference = C0F600FD1FD642B3006C242A /* NotifyDemoTests.xctest */; 146 | productType = "com.apple.product-type.bundle.unit-test"; 147 | }; 148 | /* End PBXNativeTarget section */ 149 | 150 | /* Begin PBXProject section */ 151 | C0F600E11FD642B2006C242A /* Project object */ = { 152 | isa = PBXProject; 153 | attributes = { 154 | LastSwiftUpdateCheck = 0910; 155 | LastUpgradeCheck = 0910; 156 | ORGANIZATIONNAME = Zero; 157 | TargetAttributes = { 158 | C0F600E81FD642B2006C242A = { 159 | CreatedOnToolsVersion = 9.1; 160 | ProvisioningStyle = Automatic; 161 | }; 162 | C0F600FC1FD642B3006C242A = { 163 | CreatedOnToolsVersion = 9.1; 164 | ProvisioningStyle = Automatic; 165 | TestTargetID = C0F600E81FD642B2006C242A; 166 | }; 167 | }; 168 | }; 169 | buildConfigurationList = C0F600E41FD642B2006C242A /* Build configuration list for PBXProject "NotifyDemo" */; 170 | compatibilityVersion = "Xcode 8.0"; 171 | developmentRegion = en; 172 | hasScannedForEncodings = 0; 173 | knownRegions = ( 174 | en, 175 | Base, 176 | ); 177 | mainGroup = C0F600E01FD642B2006C242A; 178 | productRefGroup = C0F600EA1FD642B2006C242A /* Products */; 179 | projectDirPath = ""; 180 | projectRoot = ""; 181 | targets = ( 182 | C0F600E81FD642B2006C242A /* NotifyDemo */, 183 | C0F600FC1FD642B3006C242A /* NotifyDemoTests */, 184 | ); 185 | }; 186 | /* End PBXProject section */ 187 | 188 | /* Begin PBXResourcesBuildPhase section */ 189 | C0F600E71FD642B2006C242A /* Resources */ = { 190 | isa = PBXResourcesBuildPhase; 191 | buildActionMask = 2147483647; 192 | files = ( 193 | C0F600F71FD642B2006C242A /* LaunchScreen.storyboard in Resources */, 194 | C0F600F41FD642B2006C242A /* Assets.xcassets in Resources */, 195 | C0F600F21FD642B2006C242A /* Main.storyboard in Resources */, 196 | ); 197 | runOnlyForDeploymentPostprocessing = 0; 198 | }; 199 | C0F600FB1FD642B3006C242A /* Resources */ = { 200 | isa = PBXResourcesBuildPhase; 201 | buildActionMask = 2147483647; 202 | files = ( 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | /* End PBXResourcesBuildPhase section */ 207 | 208 | /* Begin PBXSourcesBuildPhase section */ 209 | C0F600E51FD642B2006C242A /* Sources */ = { 210 | isa = PBXSourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | C0F600EF1FD642B2006C242A /* ViewController.swift in Sources */, 214 | C03B64F21FD667D800D93CAA /* ZRNotify.swift in Sources */, 215 | C0F600ED1FD642B2006C242A /* AppDelegate.swift in Sources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | C0F600F91FD642B3006C242A /* Sources */ = { 220 | isa = PBXSourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | C0F601021FD642B3006C242A /* NotifyDemoTests.swift in Sources */, 224 | ); 225 | runOnlyForDeploymentPostprocessing = 0; 226 | }; 227 | /* End PBXSourcesBuildPhase section */ 228 | 229 | /* Begin PBXTargetDependency section */ 230 | C0F600FF1FD642B3006C242A /* PBXTargetDependency */ = { 231 | isa = PBXTargetDependency; 232 | target = C0F600E81FD642B2006C242A /* NotifyDemo */; 233 | targetProxy = C0F600FE1FD642B3006C242A /* PBXContainerItemProxy */; 234 | }; 235 | /* End PBXTargetDependency section */ 236 | 237 | /* Begin PBXVariantGroup section */ 238 | C0F600F01FD642B2006C242A /* Main.storyboard */ = { 239 | isa = PBXVariantGroup; 240 | children = ( 241 | C0F600F11FD642B2006C242A /* Base */, 242 | ); 243 | name = Main.storyboard; 244 | sourceTree = ""; 245 | }; 246 | C0F600F51FD642B2006C242A /* LaunchScreen.storyboard */ = { 247 | isa = PBXVariantGroup; 248 | children = ( 249 | C0F600F61FD642B2006C242A /* Base */, 250 | ); 251 | name = LaunchScreen.storyboard; 252 | sourceTree = ""; 253 | }; 254 | /* End PBXVariantGroup section */ 255 | 256 | /* Begin XCBuildConfiguration section */ 257 | C0F601041FD642B3006C242A /* Debug */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_ANALYZER_NONNULL = YES; 262 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 264 | CLANG_CXX_LIBRARY = "libc++"; 265 | CLANG_ENABLE_MODULES = YES; 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 268 | CLANG_WARN_BOOL_CONVERSION = YES; 269 | CLANG_WARN_COMMA = YES; 270 | CLANG_WARN_CONSTANT_CONVERSION = YES; 271 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 272 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 273 | CLANG_WARN_EMPTY_BODY = YES; 274 | CLANG_WARN_ENUM_CONVERSION = YES; 275 | CLANG_WARN_INFINITE_RECURSION = YES; 276 | CLANG_WARN_INT_CONVERSION = YES; 277 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 278 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 279 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 280 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 281 | CLANG_WARN_STRICT_PROTOTYPES = YES; 282 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 283 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 284 | CLANG_WARN_UNREACHABLE_CODE = YES; 285 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 286 | CODE_SIGN_IDENTITY = "iPhone Developer"; 287 | COPY_PHASE_STRIP = NO; 288 | DEBUG_INFORMATION_FORMAT = dwarf; 289 | ENABLE_STRICT_OBJC_MSGSEND = YES; 290 | ENABLE_TESTABILITY = YES; 291 | GCC_C_LANGUAGE_STANDARD = gnu11; 292 | GCC_DYNAMIC_NO_PIC = NO; 293 | GCC_NO_COMMON_BLOCKS = YES; 294 | GCC_OPTIMIZATION_LEVEL = 0; 295 | GCC_PREPROCESSOR_DEFINITIONS = ( 296 | "DEBUG=1", 297 | "$(inherited)", 298 | ); 299 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 300 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 301 | GCC_WARN_UNDECLARED_SELECTOR = YES; 302 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 303 | GCC_WARN_UNUSED_FUNCTION = YES; 304 | GCC_WARN_UNUSED_VARIABLE = YES; 305 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 306 | MTL_ENABLE_DEBUG_INFO = YES; 307 | ONLY_ACTIVE_ARCH = YES; 308 | SDKROOT = iphoneos; 309 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 310 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 311 | }; 312 | name = Debug; 313 | }; 314 | C0F601051FD642B3006C242A /* Release */ = { 315 | isa = XCBuildConfiguration; 316 | buildSettings = { 317 | ALWAYS_SEARCH_USER_PATHS = NO; 318 | CLANG_ANALYZER_NONNULL = YES; 319 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 320 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 321 | CLANG_CXX_LIBRARY = "libc++"; 322 | CLANG_ENABLE_MODULES = YES; 323 | CLANG_ENABLE_OBJC_ARC = YES; 324 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 325 | CLANG_WARN_BOOL_CONVERSION = YES; 326 | CLANG_WARN_COMMA = YES; 327 | CLANG_WARN_CONSTANT_CONVERSION = YES; 328 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 329 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 330 | CLANG_WARN_EMPTY_BODY = YES; 331 | CLANG_WARN_ENUM_CONVERSION = YES; 332 | CLANG_WARN_INFINITE_RECURSION = YES; 333 | CLANG_WARN_INT_CONVERSION = YES; 334 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 335 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 336 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 337 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 338 | CLANG_WARN_STRICT_PROTOTYPES = YES; 339 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 340 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 341 | CLANG_WARN_UNREACHABLE_CODE = YES; 342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 343 | CODE_SIGN_IDENTITY = "iPhone Developer"; 344 | COPY_PHASE_STRIP = NO; 345 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 346 | ENABLE_NS_ASSERTIONS = NO; 347 | ENABLE_STRICT_OBJC_MSGSEND = YES; 348 | GCC_C_LANGUAGE_STANDARD = gnu11; 349 | GCC_NO_COMMON_BLOCKS = YES; 350 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 351 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 352 | GCC_WARN_UNDECLARED_SELECTOR = YES; 353 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 354 | GCC_WARN_UNUSED_FUNCTION = YES; 355 | GCC_WARN_UNUSED_VARIABLE = YES; 356 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 357 | MTL_ENABLE_DEBUG_INFO = NO; 358 | SDKROOT = iphoneos; 359 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 360 | VALIDATE_PRODUCT = YES; 361 | }; 362 | name = Release; 363 | }; 364 | C0F601071FD642B3006C242A /* Debug */ = { 365 | isa = XCBuildConfiguration; 366 | buildSettings = { 367 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 368 | CODE_SIGN_STYLE = Automatic; 369 | INFOPLIST_FILE = NotifyDemo/Info.plist; 370 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 371 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 372 | PRODUCT_BUNDLE_IDENTIFIER = com.zero.NotifyDemo; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | SWIFT_VERSION = 4.0; 375 | TARGETED_DEVICE_FAMILY = "1,2"; 376 | }; 377 | name = Debug; 378 | }; 379 | C0F601081FD642B3006C242A /* Release */ = { 380 | isa = XCBuildConfiguration; 381 | buildSettings = { 382 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 383 | CODE_SIGN_STYLE = Automatic; 384 | INFOPLIST_FILE = NotifyDemo/Info.plist; 385 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 386 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 387 | PRODUCT_BUNDLE_IDENTIFIER = com.zero.NotifyDemo; 388 | PRODUCT_NAME = "$(TARGET_NAME)"; 389 | SWIFT_VERSION = 4.0; 390 | TARGETED_DEVICE_FAMILY = "1,2"; 391 | }; 392 | name = Release; 393 | }; 394 | C0F6010A1FD642B3006C242A /* Debug */ = { 395 | isa = XCBuildConfiguration; 396 | buildSettings = { 397 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 398 | BUNDLE_LOADER = "$(TEST_HOST)"; 399 | CODE_SIGN_STYLE = Automatic; 400 | INFOPLIST_FILE = NotifyDemoTests/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 402 | PRODUCT_BUNDLE_IDENTIFIER = com.zero.NotifyDemoTests; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | SWIFT_VERSION = 4.0; 405 | TARGETED_DEVICE_FAMILY = "1,2"; 406 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NotifyDemo.app/NotifyDemo"; 407 | }; 408 | name = Debug; 409 | }; 410 | C0F6010B1FD642B3006C242A /* Release */ = { 411 | isa = XCBuildConfiguration; 412 | buildSettings = { 413 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 414 | BUNDLE_LOADER = "$(TEST_HOST)"; 415 | CODE_SIGN_STYLE = Automatic; 416 | INFOPLIST_FILE = NotifyDemoTests/Info.plist; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 418 | PRODUCT_BUNDLE_IDENTIFIER = com.zero.NotifyDemoTests; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | SWIFT_VERSION = 4.0; 421 | TARGETED_DEVICE_FAMILY = "1,2"; 422 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NotifyDemo.app/NotifyDemo"; 423 | }; 424 | name = Release; 425 | }; 426 | /* End XCBuildConfiguration section */ 427 | 428 | /* Begin XCConfigurationList section */ 429 | C0F600E41FD642B2006C242A /* Build configuration list for PBXProject "NotifyDemo" */ = { 430 | isa = XCConfigurationList; 431 | buildConfigurations = ( 432 | C0F601041FD642B3006C242A /* Debug */, 433 | C0F601051FD642B3006C242A /* Release */, 434 | ); 435 | defaultConfigurationIsVisible = 0; 436 | defaultConfigurationName = Release; 437 | }; 438 | C0F601061FD642B3006C242A /* Build configuration list for PBXNativeTarget "NotifyDemo" */ = { 439 | isa = XCConfigurationList; 440 | buildConfigurations = ( 441 | C0F601071FD642B3006C242A /* Debug */, 442 | C0F601081FD642B3006C242A /* Release */, 443 | ); 444 | defaultConfigurationIsVisible = 0; 445 | defaultConfigurationName = Release; 446 | }; 447 | C0F601091FD642B3006C242A /* Build configuration list for PBXNativeTarget "NotifyDemoTests" */ = { 448 | isa = XCConfigurationList; 449 | buildConfigurations = ( 450 | C0F6010A1FD642B3006C242A /* Debug */, 451 | C0F6010B1FD642B3006C242A /* Release */, 452 | ); 453 | defaultConfigurationIsVisible = 0; 454 | defaultConfigurationName = Release; 455 | }; 456 | /* End XCConfigurationList section */ 457 | }; 458 | rootObject = C0F600E11FD642B2006C242A /* Project object */; 459 | } 460 | -------------------------------------------------------------------------------- /NotifyDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 9 | 10 | 11 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NotifyDemo.xcodeproj/xcshareddata/xcschemes/NotifyDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 48 | 54 | 55 | 56 | 57 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 80 | 82 | 88 | 89 | 90 | 91 | 92 | 93 | 99 | 101 | 107 | 108 | 109 | 110 | 112 | 113 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /NotifyDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // NotifyDemo 4 | // 5 | // Created by 李锋 on 2017/12/5. 6 | // Copyright © 2017年 Zero. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /NotifyDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /NotifyDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /NotifyDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /NotifyDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /NotifyDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // NotifyDemo 4 | // 5 | // Created by 李锋 on 2017/12/5. 6 | // Copyright © 2017年 Zero. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | 23 | 24 | } 25 | 26 | -------------------------------------------------------------------------------- /NotifyDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /NotifyDemoTests/NotifyDemoTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NotifyDemoTests.swift 3 | // NotifyDemoTests 4 | // 5 | // Created by 李锋 on 2017/12/5. 6 | // Copyright © 2017年 Zero. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import NotifyDemo 11 | 12 | class NotifyDemoTests: XCTestCase { 13 | 14 | var notifyer: ZRNotify! 15 | override func setUp() { 16 | super.setUp() 17 | 18 | notifyer = ZRNotify() 19 | } 20 | 21 | override func tearDown() { 22 | super.tearDown() 23 | } 24 | 25 | func testNormal() { 26 | 27 | notifyer.on("NotifyerName") { notifyer in 28 | XCTAssertNotNil(notifyer.object, "notifyer.object is nill") 29 | } 30 | 31 | notifyer.on("NotifyerName", notify: { notify in 32 | XCTAssertEqual("notify.value", notify.object as! String, "normal not equal") 33 | }) 34 | 35 | NotificationCenter.default.post(name: Notification.Name(rawValue: "NotifyerName"), object: "notify.value") 36 | } 37 | 38 | func testChain() { 39 | 40 | notifyer.on("Chain.ScheduleA") { notify in 41 | XCTAssertNotNil(notify.object, "Chain.ScheduleA.object is nill") 42 | XCTAssertEqual("Chain.ScheduleA.value", notify.object as! String, "Chain.ScheduleA not equal") 43 | }.on("Chain.ScheduleB") { notify in 44 | XCTAssertNotNil(notify.object, "Chain.ScheduleB.object is nill") 45 | XCTAssertEqual("Chain.ScheduleB.value", notify.object as! String, "Chain.ScheduleB not equal") 46 | } 47 | 48 | NotificationCenter.default.post(name: Notification.Name(rawValue: "Chain.ScheduleA"), object: "Chain.ScheduleA.value") 49 | NotificationCenter.default.post(name: Notification.Name(rawValue: "Chain.ScheduleB"), object: "Chain.ScheduleB.value") 50 | } 51 | 52 | func testUnify() { 53 | 54 | notifyer.ons(["Unify.Schedule1", "Unify.Schedule2"]) { notify in 55 | XCTAssertNotNil(notify.object, "Unify notification is nill") 56 | XCTAssert( notify.object as! String == "Unify.Schedule1.value" || notify.object as! String == "Unify.Schedule2.value", "Unify's object is not equal") 57 | } 58 | 59 | NotificationCenter.default.post(name: Notification.Name(rawValue: "Unify.Schedule1"), object: "Unify.Schedule1.value") 60 | NotificationCenter.default.post(name: Notification.Name(rawValue: "Unify.Schedule2"), object: "Unify.Schedule2.value") 61 | } 62 | } 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZRNotify 2 | ![build](https://travis-ci.org/ZeroFengLee/ZRNotify.svg?branch=master) 3 | ![Swift](https://img.shields.io/badge/Swift-4.0-orange.svg) 4 | ![CocoaPods](http://img.shields.io/cocoapods/v/ZRNotify.svg) 5 | ![License](https://img.shields.io/cocoapods/l/ZRNotify.svg) 6 | ![Platform](https://img.shields.io/cocoapods/p/ZRNotify.svg) 7 | 8 | ✨ZRNotify is a new way of dealing with Notification,more simpler and more convenient 9 | 10 | 11 | ## Bad Way 12 | 13 | observer notification 14 | 15 | ```swfit 16 | NotificationCenter.default.addObserver(self, selector: #selector(acceptNotify), name: NSNotification.Name(rawValue: "NotifyName"), object: nil) 17 | 18 | func acceptNotify(notify: Notification) { 19 | print(notify) 20 | } 21 | ``` 22 | 23 | post notification 24 | ```swfit 25 | NotificationCenter.default.post(name: Notification.Name(rawValue: "NotifyName"), object: "hello") 26 | ``` 27 | 28 | ## ZRNotify Way 29 | 30 | ```swfit 31 | ZRNotify().on("NotifyName", notify: { notify in 32 | print(notify.object) 33 | }) 34 | ``` 35 | 36 | post notification 37 | ```swfit 38 | NotificationCenter.default.post(name: Notification.Name(rawValue: "NotifyName"), object: "hello") 39 | ``` 40 | ## Advanced Usage 41 | 42 | Initialize ZRNotify 43 | 44 | ```swift 45 | let notify = ZRNotify() 46 | ``` 47 | 48 | start observer 49 | > there are two ways to observer,you can use one of them according to the actual situation 50 | 51 | way 01: Separate Observer 52 | 53 | ```swift 54 | notify.on("ScheduleA", notify: { notify in 55 | 56 | print(notify.object) 57 | }).on("ScheduleB", notify: { notify in 58 | 59 | print(notify.object) 60 | }) 61 | ``` 62 | 63 | way 02: Unified Observer 64 | 65 | ```swift 66 | notify.ons(["ScheduleA", "ScheduleB"], notify: { notify in 67 | 68 | print(notify.object) 69 | }) 70 | ``` 71 | 72 | post notification 73 | 74 | ```swfit 75 | NotificationCenter.default.post(name: Notification.Name(rawValue: "ScheduleA"), object: "hello A") 76 | NotificationCenter.default.post(name: Notification.Name(rawValue: "ScheduleB"), object: "hello B") 77 | ``` 78 | 79 | ## Installation 80 | 81 | `pod 'ZRNotify', '~> 0.0.5'` 82 | 83 | ## License 84 | 85 | **ZRNotify** is under MIT license. See the [LICENSE](LICENSE) file for more info. 86 | -------------------------------------------------------------------------------- /ZRNotify.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint ZObjcStore.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "ZRNotify" 19 | s.version = "0.0.5" 20 | s.summary = "Storaging data of model." 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = <<-DESC 28 | deal with notification in chain. 29 | DESC 30 | 31 | s.homepage = "http://www.jianshu.com/users/79b1ed19c06f/latest_articles" 32 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 33 | 34 | 35 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 36 | # 37 | # Licensing your code is important. See http://choosealicense.com for more info. 38 | # CocoaPods will detect a license file if there is a named LICENSE* 39 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 40 | # 41 | 42 | s.license = "MIT" 43 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 44 | 45 | 46 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 47 | # 48 | # Specify the authors of the library, with email addresses. Email addresses 49 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 50 | # accepts just a name if you'd rather not provide an email address. 51 | # 52 | # Specify a social_media_url where others can refer to, for example a twitter 53 | # profile URL. 54 | # 55 | 56 | s.author = { "Zero" => "caivenlf@126.com" } 57 | # Or just: s.author = "Zero" 58 | # s.authors = { "Zero" => "caivenlf@126.com" } 59 | # s.social_media_url = "http://twitter.com/Zero" 60 | 61 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 62 | # 63 | # If this Pod runs only on iOS or OS X, then specify the platform and 64 | # the deployment target. You can optionally include the target after the platform. 65 | # 66 | 67 | # s.platform = :ios 68 | s.platform = :ios, "8" 69 | 70 | # When using multiple platforms 71 | # s.ios.deployment_target = "5.0" 72 | # s.osx.deployment_target = "10.7" 73 | # s.watchos.deployment_target = "2.0" 74 | # s.tvos.deployment_target = "9.0" 75 | 76 | 77 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 78 | # 79 | # Specify the location from where the source should be retrieved. 80 | # Supports git, hg, bzr, svn and HTTP. 81 | # 82 | 83 | s.source = { :git => "https://github.com/ZeroFengLee/ZRNotify.git", :tag => s.version } 84 | 85 | 86 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 87 | # 88 | # CocoaPods is smart about how it includes source code. For source files 89 | # giving a folder will include any swift, h, m, mm, c & cpp files. 90 | # For header files it will include any header in the folder. 91 | # Not including the public_header_files will make all headers public. 92 | # 93 | 94 | s.source_files = "ZRNotify/**/*" 95 | #s.exclude_files = "Classes/Exclude" 96 | 97 | # s.public_header_files = "Classes/**/*.h" 98 | 99 | 100 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 101 | # 102 | # A list of resources included with the Pod. These are copied into the 103 | # target bundle with a build phase script. Anything else will be cleaned. 104 | # You can preserve files from being cleaned, please don't preserve 105 | # non-essential files like tests, examples and documentation. 106 | # 107 | 108 | # s.resource = "icon.png" 109 | # s.resources = "Resources/*.png" 110 | 111 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 112 | 113 | 114 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 115 | # 116 | # Link your library with frameworks, or libraries. Libraries do not include 117 | # the lib prefix of their name. 118 | # 119 | 120 | # s.framework = "SomeFramework" 121 | # s.frameworks = "SomeFramework", "AnotherFramework" 122 | 123 | # s.library = "iconv" 124 | # s.libraries = "iconv", "xml2" 125 | 126 | 127 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 128 | # 129 | # If your library depends on compiler flags you can set them in the xcconfig hash 130 | # where they will only apply to your library. If you depend on other Podspecs 131 | # you can include multiple dependencies to ensure it works. 132 | 133 | s.requires_arc = true 134 | 135 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 136 | # s.dependency "JSONKit", "~> 1.4" 137 | 138 | end 139 | -------------------------------------------------------------------------------- /ZRNotify/ZRNotify.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZRNotify.swift 3 | // Planetoid 4 | // 5 | // Created by Zero on 2017/3/21. 6 | // Copyright © 2017年 Zero. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public class ZRNotify { 12 | 13 | public init() {} 14 | typealias notifierIdentifier = String 15 | public typealias notifyType = ((Notification) -> Void) 16 | 17 | fileprivate var notifyPool: [(String, notifyType?)] = [] 18 | fileprivate var notifyStatus: [String: Bool] = [:] 19 | 20 | fileprivate lazy var lock: NSLock = { 21 | var lock = NSLock() 22 | return lock 23 | }() 24 | 25 | /* 26 | one <-> one 27 | */ 28 | @discardableResult public func on(_ notifyIdentifier: String, notify: notifyType?) -> Self { 29 | NotificationCenter.default.addObserver(self, selector: #selector(receiveNotify(_:)), name: NSNotification.Name(rawValue: notifyIdentifier), object: nil) 30 | lock.lock() 31 | self.notifyPool.append((notifyIdentifier, notify)) 32 | lock.unlock() 33 | self.notifyStatus[notifyIdentifier] = true 34 | return self 35 | } 36 | 37 | /* 38 | one <-> many 39 | */ 40 | @discardableResult public func ons(_ notifyIdentifiers: [String], notify: notifyType?) -> Self { 41 | lock.lock() 42 | notifyIdentifiers.forEach { 43 | NotificationCenter.default.addObserver(self, selector: #selector(receiveNotify(_:)), name: NSNotification.Name(rawValue: $0), object: nil) 44 | self.notifyPool.append(($0, notify)) 45 | self.notifyStatus[$0] = true 46 | } 47 | lock.unlock() 48 | return self 49 | } 50 | 51 | /* 52 | remove notification 53 | */ 54 | @discardableResult public func remove(_ notifyIdentifier: String) -> Self { 55 | NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: notifyIdentifier), object: nil) 56 | notifyPool = notifyPool.filter { $0.0 == notifyIdentifier } 57 | return self 58 | } 59 | 60 | /* 61 | remove all notifications 62 | */ 63 | @discardableResult public func removeAll() -> Self { 64 | NotificationCenter.default.removeObserver(self) 65 | notifyPool.removeAll() 66 | return self 67 | } 68 | 69 | /* 70 | switch notification's status 71 | */ 72 | @discardableResult public func opStatus(_ notifyIdentifier: String, _ open: Bool) -> Self { 73 | self.notifyStatus[notifyIdentifier] = open 74 | return self 75 | } 76 | 77 | /* 78 | switch all notifacations' status 79 | */ 80 | @discardableResult public func opStatusForAll(_ open: Bool) -> Self { 81 | self.notifyStatus.keys.forEach { self.notifyStatus[$0] = open } 82 | return self 83 | } 84 | 85 | /** ! 86 | `default`: ZRNotify remove all notification in deinit 87 | */ 88 | deinit { 89 | removeAll() 90 | } 91 | } 92 | 93 | extension ZRNotify { 94 | @objc fileprivate func receiveNotify(_ notification: Notification) { 95 | for notify in notifyPool { 96 | guard let status = self.notifyStatus[notify.0], status == true, notify.0 == notification.name.rawValue else { 97 | continue 98 | } 99 | notify.1?(notification) 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /ZRNotifyDemo/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | 3 | platform :ios, '8.0' 4 | use_frameworks! 5 | 6 | def pro_pods 7 | pod 'ZRNotify', '~> 0.0.5' 8 | end 9 | 10 | target 'ZRNotifyDemo' do 11 | pro_pods 12 | end 13 | -------------------------------------------------------------------------------- /ZRNotifyDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ZRNotify (0.0.5) 3 | 4 | DEPENDENCIES: 5 | - ZRNotify (~> 0.0.5) 6 | 7 | SPEC CHECKSUMS: 8 | ZRNotify: 7973c963946c1170e7e5910789957c09821d24e5 9 | 10 | PODFILE CHECKSUM: 28010026ebb6afc18dd94f2ffc0fe5687edd950d 11 | 12 | COCOAPODS: 1.2.0 13 | -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C0DBCDD91EC3083700A53C7A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DBCDD81EC3083700A53C7A /* AppDelegate.swift */; }; 11 | C0DBCDDB1EC3083700A53C7A /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0DBCDDA1EC3083700A53C7A /* ViewController.swift */; }; 12 | C0DBCDDE1EC3083700A53C7A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0DBCDDC1EC3083700A53C7A /* Main.storyboard */; }; 13 | C0DBCDE01EC3083700A53C7A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C0DBCDDF1EC3083700A53C7A /* Assets.xcassets */; }; 14 | C0DBCDE31EC3083700A53C7A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0DBCDE11EC3083700A53C7A /* LaunchScreen.storyboard */; }; 15 | C1F76938A40810211DD90150 /* Pods_ZRNotifyDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4A633426BA988EAA77EFD2A /* Pods_ZRNotifyDemo.framework */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | 86427CD937CDCB61F14D222D /* Pods-ZRNotifyDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZRNotifyDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-ZRNotifyDemo/Pods-ZRNotifyDemo.release.xcconfig"; sourceTree = ""; }; 20 | ADF36F81F70A1D400D3F06E9 /* Pods-ZRNotifyDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ZRNotifyDemo.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ZRNotifyDemo/Pods-ZRNotifyDemo.debug.xcconfig"; sourceTree = ""; }; 21 | C0DBCDD51EC3083700A53C7A /* ZRNotifyDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZRNotifyDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | C0DBCDD81EC3083700A53C7A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 23 | C0DBCDDA1EC3083700A53C7A /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 24 | C0DBCDDD1EC3083700A53C7A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 25 | C0DBCDDF1EC3083700A53C7A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 26 | C0DBCDE21EC3083700A53C7A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | C0DBCDE41EC3083700A53C7A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | D4A633426BA988EAA77EFD2A /* Pods_ZRNotifyDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ZRNotifyDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | C0DBCDD21EC3083700A53C7A /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | C1F76938A40810211DD90150 /* Pods_ZRNotifyDemo.framework in Frameworks */, 37 | ); 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXFrameworksBuildPhase section */ 41 | 42 | /* Begin PBXGroup section */ 43 | 3D303DD680733DCFF485ADA6 /* Frameworks */ = { 44 | isa = PBXGroup; 45 | children = ( 46 | D4A633426BA988EAA77EFD2A /* Pods_ZRNotifyDemo.framework */, 47 | ); 48 | name = Frameworks; 49 | sourceTree = ""; 50 | }; 51 | 47A0E89EDD509B39BD4BFFEA /* Pods */ = { 52 | isa = PBXGroup; 53 | children = ( 54 | ADF36F81F70A1D400D3F06E9 /* Pods-ZRNotifyDemo.debug.xcconfig */, 55 | 86427CD937CDCB61F14D222D /* Pods-ZRNotifyDemo.release.xcconfig */, 56 | ); 57 | name = Pods; 58 | sourceTree = ""; 59 | }; 60 | C0DBCDCC1EC3083700A53C7A = { 61 | isa = PBXGroup; 62 | children = ( 63 | C0DBCDD71EC3083700A53C7A /* ZRNotifyDemo */, 64 | C0DBCDD61EC3083700A53C7A /* Products */, 65 | 47A0E89EDD509B39BD4BFFEA /* Pods */, 66 | 3D303DD680733DCFF485ADA6 /* Frameworks */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | C0DBCDD61EC3083700A53C7A /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | C0DBCDD51EC3083700A53C7A /* ZRNotifyDemo.app */, 74 | ); 75 | name = Products; 76 | sourceTree = ""; 77 | }; 78 | C0DBCDD71EC3083700A53C7A /* ZRNotifyDemo */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | C0DBCDD81EC3083700A53C7A /* AppDelegate.swift */, 82 | C0DBCDDA1EC3083700A53C7A /* ViewController.swift */, 83 | C0DBCDDC1EC3083700A53C7A /* Main.storyboard */, 84 | C0DBCDDF1EC3083700A53C7A /* Assets.xcassets */, 85 | C0DBCDE11EC3083700A53C7A /* LaunchScreen.storyboard */, 86 | C0DBCDE41EC3083700A53C7A /* Info.plist */, 87 | ); 88 | path = ZRNotifyDemo; 89 | sourceTree = ""; 90 | }; 91 | /* End PBXGroup section */ 92 | 93 | /* Begin PBXNativeTarget section */ 94 | C0DBCDD41EC3083700A53C7A /* ZRNotifyDemo */ = { 95 | isa = PBXNativeTarget; 96 | buildConfigurationList = C0DBCDE71EC3083700A53C7A /* Build configuration list for PBXNativeTarget "ZRNotifyDemo" */; 97 | buildPhases = ( 98 | 6400095603B69240EEE40757 /* [CP] Check Pods Manifest.lock */, 99 | C0DBCDD11EC3083700A53C7A /* Sources */, 100 | C0DBCDD21EC3083700A53C7A /* Frameworks */, 101 | C0DBCDD31EC3083700A53C7A /* Resources */, 102 | 8BA32482BD7B2FCA4D0BF147 /* [CP] Embed Pods Frameworks */, 103 | 8022C66438BA18FD6DD3A3F1 /* [CP] Copy Pods Resources */, 104 | ); 105 | buildRules = ( 106 | ); 107 | dependencies = ( 108 | ); 109 | name = ZRNotifyDemo; 110 | productName = ZRNotifyDemo; 111 | productReference = C0DBCDD51EC3083700A53C7A /* ZRNotifyDemo.app */; 112 | productType = "com.apple.product-type.application"; 113 | }; 114 | /* End PBXNativeTarget section */ 115 | 116 | /* Begin PBXProject section */ 117 | C0DBCDCD1EC3083700A53C7A /* Project object */ = { 118 | isa = PBXProject; 119 | attributes = { 120 | LastSwiftUpdateCheck = 0820; 121 | LastUpgradeCheck = 0820; 122 | ORGANIZATIONNAME = Zero; 123 | TargetAttributes = { 124 | C0DBCDD41EC3083700A53C7A = { 125 | CreatedOnToolsVersion = 8.2.1; 126 | DevelopmentTeam = 4K4Q9JA95Y; 127 | ProvisioningStyle = Manual; 128 | }; 129 | }; 130 | }; 131 | buildConfigurationList = C0DBCDD01EC3083700A53C7A /* Build configuration list for PBXProject "ZRNotifyDemo" */; 132 | compatibilityVersion = "Xcode 3.2"; 133 | developmentRegion = English; 134 | hasScannedForEncodings = 0; 135 | knownRegions = ( 136 | en, 137 | Base, 138 | ); 139 | mainGroup = C0DBCDCC1EC3083700A53C7A; 140 | productRefGroup = C0DBCDD61EC3083700A53C7A /* Products */; 141 | projectDirPath = ""; 142 | projectRoot = ""; 143 | targets = ( 144 | C0DBCDD41EC3083700A53C7A /* ZRNotifyDemo */, 145 | ); 146 | }; 147 | /* End PBXProject section */ 148 | 149 | /* Begin PBXResourcesBuildPhase section */ 150 | C0DBCDD31EC3083700A53C7A /* Resources */ = { 151 | isa = PBXResourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | C0DBCDE31EC3083700A53C7A /* LaunchScreen.storyboard in Resources */, 155 | C0DBCDE01EC3083700A53C7A /* Assets.xcassets in Resources */, 156 | C0DBCDDE1EC3083700A53C7A /* Main.storyboard in Resources */, 157 | ); 158 | runOnlyForDeploymentPostprocessing = 0; 159 | }; 160 | /* End PBXResourcesBuildPhase section */ 161 | 162 | /* Begin PBXShellScriptBuildPhase section */ 163 | 6400095603B69240EEE40757 /* [CP] Check Pods Manifest.lock */ = { 164 | isa = PBXShellScriptBuildPhase; 165 | buildActionMask = 2147483647; 166 | files = ( 167 | ); 168 | inputPaths = ( 169 | ); 170 | name = "[CP] Check Pods Manifest.lock"; 171 | outputPaths = ( 172 | ); 173 | runOnlyForDeploymentPostprocessing = 0; 174 | shellPath = /bin/sh; 175 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 176 | showEnvVarsInLog = 0; 177 | }; 178 | 8022C66438BA18FD6DD3A3F1 /* [CP] Copy Pods Resources */ = { 179 | isa = PBXShellScriptBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | ); 183 | inputPaths = ( 184 | ); 185 | name = "[CP] Copy Pods Resources"; 186 | outputPaths = ( 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | shellPath = /bin/sh; 190 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ZRNotifyDemo/Pods-ZRNotifyDemo-resources.sh\"\n"; 191 | showEnvVarsInLog = 0; 192 | }; 193 | 8BA32482BD7B2FCA4D0BF147 /* [CP] Embed Pods Frameworks */ = { 194 | isa = PBXShellScriptBuildPhase; 195 | buildActionMask = 2147483647; 196 | files = ( 197 | ); 198 | inputPaths = ( 199 | ); 200 | name = "[CP] Embed Pods Frameworks"; 201 | outputPaths = ( 202 | ); 203 | runOnlyForDeploymentPostprocessing = 0; 204 | shellPath = /bin/sh; 205 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ZRNotifyDemo/Pods-ZRNotifyDemo-frameworks.sh\"\n"; 206 | showEnvVarsInLog = 0; 207 | }; 208 | /* End PBXShellScriptBuildPhase section */ 209 | 210 | /* Begin PBXSourcesBuildPhase section */ 211 | C0DBCDD11EC3083700A53C7A /* Sources */ = { 212 | isa = PBXSourcesBuildPhase; 213 | buildActionMask = 2147483647; 214 | files = ( 215 | C0DBCDDB1EC3083700A53C7A /* ViewController.swift in Sources */, 216 | C0DBCDD91EC3083700A53C7A /* AppDelegate.swift in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXSourcesBuildPhase section */ 221 | 222 | /* Begin PBXVariantGroup section */ 223 | C0DBCDDC1EC3083700A53C7A /* Main.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | C0DBCDDD1EC3083700A53C7A /* Base */, 227 | ); 228 | name = Main.storyboard; 229 | sourceTree = ""; 230 | }; 231 | C0DBCDE11EC3083700A53C7A /* LaunchScreen.storyboard */ = { 232 | isa = PBXVariantGroup; 233 | children = ( 234 | C0DBCDE21EC3083700A53C7A /* Base */, 235 | ); 236 | name = LaunchScreen.storyboard; 237 | sourceTree = ""; 238 | }; 239 | /* End PBXVariantGroup section */ 240 | 241 | /* Begin XCBuildConfiguration section */ 242 | C0DBCDE51EC3083700A53C7A /* Debug */ = { 243 | isa = XCBuildConfiguration; 244 | buildSettings = { 245 | ALWAYS_SEARCH_USER_PATHS = NO; 246 | CLANG_ANALYZER_NONNULL = YES; 247 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 248 | CLANG_CXX_LIBRARY = "libc++"; 249 | CLANG_ENABLE_MODULES = YES; 250 | CLANG_ENABLE_OBJC_ARC = YES; 251 | CLANG_WARN_BOOL_CONVERSION = YES; 252 | CLANG_WARN_CONSTANT_CONVERSION = YES; 253 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 254 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 255 | CLANG_WARN_EMPTY_BODY = YES; 256 | CLANG_WARN_ENUM_CONVERSION = YES; 257 | CLANG_WARN_INFINITE_RECURSION = YES; 258 | CLANG_WARN_INT_CONVERSION = YES; 259 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 260 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 261 | CLANG_WARN_UNREACHABLE_CODE = YES; 262 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 263 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 264 | COPY_PHASE_STRIP = NO; 265 | DEBUG_INFORMATION_FORMAT = dwarf; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | ENABLE_TESTABILITY = YES; 268 | GCC_C_LANGUAGE_STANDARD = gnu99; 269 | GCC_DYNAMIC_NO_PIC = NO; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_OPTIMIZATION_LEVEL = 0; 272 | GCC_PREPROCESSOR_DEFINITIONS = ( 273 | "DEBUG=1", 274 | "$(inherited)", 275 | ); 276 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 277 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 278 | GCC_WARN_UNDECLARED_SELECTOR = YES; 279 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 280 | GCC_WARN_UNUSED_FUNCTION = YES; 281 | GCC_WARN_UNUSED_VARIABLE = YES; 282 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 283 | MTL_ENABLE_DEBUG_INFO = YES; 284 | ONLY_ACTIVE_ARCH = YES; 285 | SDKROOT = iphoneos; 286 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 287 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 288 | }; 289 | name = Debug; 290 | }; 291 | C0DBCDE61EC3083700A53C7A /* Release */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ALWAYS_SEARCH_USER_PATHS = NO; 295 | CLANG_ANALYZER_NONNULL = YES; 296 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 297 | CLANG_CXX_LIBRARY = "libc++"; 298 | CLANG_ENABLE_MODULES = YES; 299 | CLANG_ENABLE_OBJC_ARC = YES; 300 | CLANG_WARN_BOOL_CONVERSION = YES; 301 | CLANG_WARN_CONSTANT_CONVERSION = YES; 302 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 303 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 304 | CLANG_WARN_EMPTY_BODY = YES; 305 | CLANG_WARN_ENUM_CONVERSION = YES; 306 | CLANG_WARN_INFINITE_RECURSION = YES; 307 | CLANG_WARN_INT_CONVERSION = YES; 308 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 309 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 310 | CLANG_WARN_UNREACHABLE_CODE = YES; 311 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 312 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 313 | COPY_PHASE_STRIP = NO; 314 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 315 | ENABLE_NS_ASSERTIONS = NO; 316 | ENABLE_STRICT_OBJC_MSGSEND = YES; 317 | GCC_C_LANGUAGE_STANDARD = gnu99; 318 | GCC_NO_COMMON_BLOCKS = YES; 319 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 320 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 321 | GCC_WARN_UNDECLARED_SELECTOR = YES; 322 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 323 | GCC_WARN_UNUSED_FUNCTION = YES; 324 | GCC_WARN_UNUSED_VARIABLE = YES; 325 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 326 | MTL_ENABLE_DEBUG_INFO = NO; 327 | SDKROOT = iphoneos; 328 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 329 | VALIDATE_PRODUCT = YES; 330 | }; 331 | name = Release; 332 | }; 333 | C0DBCDE81EC3083700A53C7A /* Debug */ = { 334 | isa = XCBuildConfiguration; 335 | baseConfigurationReference = ADF36F81F70A1D400D3F06E9 /* Pods-ZRNotifyDemo.debug.xcconfig */; 336 | buildSettings = { 337 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 338 | DEVELOPMENT_TEAM = 4K4Q9JA95Y; 339 | INFOPLIST_FILE = ZRNotifyDemo/Info.plist; 340 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 341 | PRODUCT_BUNDLE_IDENTIFIER = com.zero.ZRNotifyDemo; 342 | PRODUCT_NAME = "$(TARGET_NAME)"; 343 | PROVISIONING_PROFILE = "c7c58d42-98fe-4aa5-a417-eed7ac8a1dda"; 344 | PROVISIONING_PROFILE_SPECIFIER = "oudmon band wild develop"; 345 | SWIFT_VERSION = 3.0; 346 | }; 347 | name = Debug; 348 | }; 349 | C0DBCDE91EC3083700A53C7A /* Release */ = { 350 | isa = XCBuildConfiguration; 351 | baseConfigurationReference = 86427CD937CDCB61F14D222D /* Pods-ZRNotifyDemo.release.xcconfig */; 352 | buildSettings = { 353 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 354 | DEVELOPMENT_TEAM = ""; 355 | INFOPLIST_FILE = ZRNotifyDemo/Info.plist; 356 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 357 | PRODUCT_BUNDLE_IDENTIFIER = com.zero.ZRNotifyDemo; 358 | PRODUCT_NAME = "$(TARGET_NAME)"; 359 | SWIFT_VERSION = 3.0; 360 | }; 361 | name = Release; 362 | }; 363 | /* End XCBuildConfiguration section */ 364 | 365 | /* Begin XCConfigurationList section */ 366 | C0DBCDD01EC3083700A53C7A /* Build configuration list for PBXProject "ZRNotifyDemo" */ = { 367 | isa = XCConfigurationList; 368 | buildConfigurations = ( 369 | C0DBCDE51EC3083700A53C7A /* Debug */, 370 | C0DBCDE61EC3083700A53C7A /* Release */, 371 | ); 372 | defaultConfigurationIsVisible = 0; 373 | defaultConfigurationName = Release; 374 | }; 375 | C0DBCDE71EC3083700A53C7A /* Build configuration list for PBXNativeTarget "ZRNotifyDemo" */ = { 376 | isa = XCConfigurationList; 377 | buildConfigurations = ( 378 | C0DBCDE81EC3083700A53C7A /* Debug */, 379 | C0DBCDE91EC3083700A53C7A /* Release */, 380 | ); 381 | defaultConfigurationIsVisible = 0; 382 | defaultConfigurationName = Release; 383 | }; 384 | /* End XCConfigurationList section */ 385 | }; 386 | rootObject = C0DBCDCD1EC3083700A53C7A /* Project object */; 387 | } 388 | -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ZRNotifyDemo 4 | // 5 | // Created by 李锋 on 2017/5/10. 6 | // Copyright © 2017年 Zero. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ZRNotifyDemo/ZRNotifyDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ZRNotifyDemo 4 | // 5 | // Created by Zero on 2017/5/10. 6 | // Copyright © 2017年 Zero. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ZRNotify 11 | 12 | class ViewController: UIViewController { 13 | 14 | /* 15 | 1. 16 | */ 17 | lazy var zrNotify: ZRNotify = { 18 | var zrnotify = ZRNotify() 19 | zrnotify.on("ScheduleA", notify: { notify in 20 | 21 | print(notify.object ?? "nil object") 22 | }).on("ScheduleB", notify: { notify in 23 | 24 | print(notify.object ?? "nil object") 25 | }).on("ScheduleC", notify: { notify in 26 | 27 | print(notify.object ?? "nil object") 28 | }) 29 | 30 | return zrnotify 31 | }() 32 | 33 | /* 34 | 2. 35 | */ 36 | lazy var zrNotifys: ZRNotify = { 37 | var zrnotify = ZRNotify() 38 | zrnotify.ons(["Schedule1", "Schedule2", "Schedule3"], notify: { notify in 39 | 40 | print(notify.object ?? "nil object") 41 | }) 42 | 43 | return zrnotify 44 | }() 45 | 46 | override func viewDidLoad() { 47 | super.viewDidLoad() 48 | 49 | zrNotify.opStatusForAll(true) 50 | zrNotifys.opStatusForAll(true) 51 | 52 | NotificationCenter.default.post(name: Notification.Name(rawValue: "ScheduleA"), object: "hello ScheduleA") 53 | NotificationCenter.default.post(name: Notification.Name(rawValue: "ScheduleB"), object: nil) 54 | NotificationCenter.default.post(name: Notification.Name(rawValue: "ScheduleC"), object: "hello ScheduleC") 55 | 56 | 57 | NotificationCenter.default.post(name: Notification.Name(rawValue: "Schedule1"), object: "hello Schedule1") 58 | NotificationCenter.default.post(name: Notification.Name(rawValue: "Schedule2"), object: nil) 59 | NotificationCenter.default.post(name: Notification.Name(rawValue: "Schedule3"), object: "hello Schedule3") 60 | } 61 | 62 | override func didReceiveMemoryWarning() { 63 | super.didReceiveMemoryWarning() 64 | } 65 | 66 | 67 | } 68 | 69 | --------------------------------------------------------------------------------