├── .DS_Store ├── README.md ├── RealTimeFilter.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── altitudelabs.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── altitudelabs.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── RealTimeFilter.xcscheme │ └── xcschememanagement.plist ├── RealTimeFilter ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── RealTimeFilter.xcdatamodeld │ ├── .xccurrentversion │ └── RealTimeFilter.xcdatamodel │ │ └── contents ├── ViewController.h ├── ViewController.m └── main.m ├── RealTimeFilterTests ├── Info.plist └── RealTimeFilterTests.m └── RealTimeFilterUITests ├── Info.plist └── RealTimeFilterUITests.m /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/altitudelabs/iOSRealTimeFilterTutorial/906eaead6862ec41848297aa4a0a5802b2337882/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOSRealTimeFilterTutorial 2 | This is the final source code of "Create a Real Time Photo Filter App" tutorial. 3 | -------------------------------------------------------------------------------- /RealTimeFilter.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D67CFB571C30E6FA005AE284 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D67CFB561C30E6FA005AE284 /* main.m */; }; 11 | D67CFB5A1C30E6FA005AE284 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D67CFB591C30E6FA005AE284 /* AppDelegate.m */; }; 12 | D67CFB5D1C30E6FA005AE284 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D67CFB5C1C30E6FA005AE284 /* ViewController.m */; }; 13 | D67CFB601C30E6FA005AE284 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D67CFB5E1C30E6FA005AE284 /* Main.storyboard */; }; 14 | D67CFB631C30E6FA005AE284 /* RealTimeFilter.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = D67CFB611C30E6FA005AE284 /* RealTimeFilter.xcdatamodeld */; }; 15 | D67CFB651C30E6FA005AE284 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D67CFB641C30E6FA005AE284 /* Assets.xcassets */; }; 16 | D67CFB681C30E6FA005AE284 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D67CFB661C30E6FA005AE284 /* LaunchScreen.storyboard */; }; 17 | D67CFB731C30E6FA005AE284 /* RealTimeFilterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D67CFB721C30E6FA005AE284 /* RealTimeFilterTests.m */; }; 18 | D67CFB7E1C30E6FA005AE284 /* RealTimeFilterUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = D67CFB7D1C30E6FA005AE284 /* RealTimeFilterUITests.m */; }; 19 | D67CFB8C1C30E84C005AE284 /* CoreImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D67CFB8B1C30E84C005AE284 /* CoreImage.framework */; }; 20 | D67CFB8E1C30E853005AE284 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D67CFB8D1C30E853005AE284 /* AVFoundation.framework */; }; 21 | D67CFB901C30EB6D005AE284 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D67CFB8F1C30EB6D005AE284 /* OpenGLES.framework */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | D67CFB6F1C30E6FA005AE284 /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = D67CFB4A1C30E6FA005AE284 /* Project object */; 28 | proxyType = 1; 29 | remoteGlobalIDString = D67CFB511C30E6FA005AE284; 30 | remoteInfo = RealTimeFilter; 31 | }; 32 | D67CFB7A1C30E6FA005AE284 /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = D67CFB4A1C30E6FA005AE284 /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = D67CFB511C30E6FA005AE284; 37 | remoteInfo = RealTimeFilter; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | D67CFB521C30E6FA005AE284 /* RealTimeFilter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RealTimeFilter.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | D67CFB561C30E6FA005AE284 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 44 | D67CFB581C30E6FA005AE284 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 45 | D67CFB591C30E6FA005AE284 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 46 | D67CFB5B1C30E6FA005AE284 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 47 | D67CFB5C1C30E6FA005AE284 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 48 | D67CFB5F1C30E6FA005AE284 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 49 | D67CFB621C30E6FA005AE284 /* RealTimeFilter.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = RealTimeFilter.xcdatamodel; sourceTree = ""; }; 50 | D67CFB641C30E6FA005AE284 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 51 | D67CFB671C30E6FA005AE284 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 52 | D67CFB691C30E6FA005AE284 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | D67CFB6E1C30E6FA005AE284 /* RealTimeFilterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RealTimeFilterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | D67CFB721C30E6FA005AE284 /* RealTimeFilterTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RealTimeFilterTests.m; sourceTree = ""; }; 55 | D67CFB741C30E6FA005AE284 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | D67CFB791C30E6FA005AE284 /* RealTimeFilterUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RealTimeFilterUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | D67CFB7D1C30E6FA005AE284 /* RealTimeFilterUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RealTimeFilterUITests.m; sourceTree = ""; }; 58 | D67CFB7F1C30E6FA005AE284 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | D67CFB8B1C30E84C005AE284 /* CoreImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreImage.framework; path = System/Library/Frameworks/CoreImage.framework; sourceTree = SDKROOT; }; 60 | D67CFB8D1C30E853005AE284 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 61 | D67CFB8F1C30EB6D005AE284 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 62 | /* End PBXFileReference section */ 63 | 64 | /* Begin PBXFrameworksBuildPhase section */ 65 | D67CFB4F1C30E6FA005AE284 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | D67CFB901C30EB6D005AE284 /* OpenGLES.framework in Frameworks */, 70 | D67CFB8E1C30E853005AE284 /* AVFoundation.framework in Frameworks */, 71 | D67CFB8C1C30E84C005AE284 /* CoreImage.framework in Frameworks */, 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | D67CFB6B1C30E6FA005AE284 /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | D67CFB761C30E6FA005AE284 /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | /* End PBXFrameworksBuildPhase section */ 90 | 91 | /* Begin PBXGroup section */ 92 | D67CFB491C30E6FA005AE284 = { 93 | isa = PBXGroup; 94 | children = ( 95 | D67CFB8F1C30EB6D005AE284 /* OpenGLES.framework */, 96 | D67CFB8D1C30E853005AE284 /* AVFoundation.framework */, 97 | D67CFB8B1C30E84C005AE284 /* CoreImage.framework */, 98 | D67CFB541C30E6FA005AE284 /* RealTimeFilter */, 99 | D67CFB711C30E6FA005AE284 /* RealTimeFilterTests */, 100 | D67CFB7C1C30E6FA005AE284 /* RealTimeFilterUITests */, 101 | D67CFB531C30E6FA005AE284 /* Products */, 102 | ); 103 | sourceTree = ""; 104 | }; 105 | D67CFB531C30E6FA005AE284 /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | D67CFB521C30E6FA005AE284 /* RealTimeFilter.app */, 109 | D67CFB6E1C30E6FA005AE284 /* RealTimeFilterTests.xctest */, 110 | D67CFB791C30E6FA005AE284 /* RealTimeFilterUITests.xctest */, 111 | ); 112 | name = Products; 113 | sourceTree = ""; 114 | }; 115 | D67CFB541C30E6FA005AE284 /* RealTimeFilter */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | D67CFB581C30E6FA005AE284 /* AppDelegate.h */, 119 | D67CFB591C30E6FA005AE284 /* AppDelegate.m */, 120 | D67CFB5B1C30E6FA005AE284 /* ViewController.h */, 121 | D67CFB5C1C30E6FA005AE284 /* ViewController.m */, 122 | D67CFB5E1C30E6FA005AE284 /* Main.storyboard */, 123 | D67CFB641C30E6FA005AE284 /* Assets.xcassets */, 124 | D67CFB661C30E6FA005AE284 /* LaunchScreen.storyboard */, 125 | D67CFB691C30E6FA005AE284 /* Info.plist */, 126 | D67CFB611C30E6FA005AE284 /* RealTimeFilter.xcdatamodeld */, 127 | D67CFB551C30E6FA005AE284 /* Supporting Files */, 128 | ); 129 | path = RealTimeFilter; 130 | sourceTree = ""; 131 | }; 132 | D67CFB551C30E6FA005AE284 /* Supporting Files */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | D67CFB561C30E6FA005AE284 /* main.m */, 136 | ); 137 | name = "Supporting Files"; 138 | sourceTree = ""; 139 | }; 140 | D67CFB711C30E6FA005AE284 /* RealTimeFilterTests */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | D67CFB721C30E6FA005AE284 /* RealTimeFilterTests.m */, 144 | D67CFB741C30E6FA005AE284 /* Info.plist */, 145 | ); 146 | path = RealTimeFilterTests; 147 | sourceTree = ""; 148 | }; 149 | D67CFB7C1C30E6FA005AE284 /* RealTimeFilterUITests */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | D67CFB7D1C30E6FA005AE284 /* RealTimeFilterUITests.m */, 153 | D67CFB7F1C30E6FA005AE284 /* Info.plist */, 154 | ); 155 | path = RealTimeFilterUITests; 156 | sourceTree = ""; 157 | }; 158 | /* End PBXGroup section */ 159 | 160 | /* Begin PBXNativeTarget section */ 161 | D67CFB511C30E6FA005AE284 /* RealTimeFilter */ = { 162 | isa = PBXNativeTarget; 163 | buildConfigurationList = D67CFB821C30E6FA005AE284 /* Build configuration list for PBXNativeTarget "RealTimeFilter" */; 164 | buildPhases = ( 165 | D67CFB4E1C30E6FA005AE284 /* Sources */, 166 | D67CFB4F1C30E6FA005AE284 /* Frameworks */, 167 | D67CFB501C30E6FA005AE284 /* Resources */, 168 | ); 169 | buildRules = ( 170 | ); 171 | dependencies = ( 172 | ); 173 | name = RealTimeFilter; 174 | productName = RealTimeFilter; 175 | productReference = D67CFB521C30E6FA005AE284 /* RealTimeFilter.app */; 176 | productType = "com.apple.product-type.application"; 177 | }; 178 | D67CFB6D1C30E6FA005AE284 /* RealTimeFilterTests */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = D67CFB851C30E6FA005AE284 /* Build configuration list for PBXNativeTarget "RealTimeFilterTests" */; 181 | buildPhases = ( 182 | D67CFB6A1C30E6FA005AE284 /* Sources */, 183 | D67CFB6B1C30E6FA005AE284 /* Frameworks */, 184 | D67CFB6C1C30E6FA005AE284 /* Resources */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | D67CFB701C30E6FA005AE284 /* PBXTargetDependency */, 190 | ); 191 | name = RealTimeFilterTests; 192 | productName = RealTimeFilterTests; 193 | productReference = D67CFB6E1C30E6FA005AE284 /* RealTimeFilterTests.xctest */; 194 | productType = "com.apple.product-type.bundle.unit-test"; 195 | }; 196 | D67CFB781C30E6FA005AE284 /* RealTimeFilterUITests */ = { 197 | isa = PBXNativeTarget; 198 | buildConfigurationList = D67CFB881C30E6FA005AE284 /* Build configuration list for PBXNativeTarget "RealTimeFilterUITests" */; 199 | buildPhases = ( 200 | D67CFB751C30E6FA005AE284 /* Sources */, 201 | D67CFB761C30E6FA005AE284 /* Frameworks */, 202 | D67CFB771C30E6FA005AE284 /* Resources */, 203 | ); 204 | buildRules = ( 205 | ); 206 | dependencies = ( 207 | D67CFB7B1C30E6FA005AE284 /* PBXTargetDependency */, 208 | ); 209 | name = RealTimeFilterUITests; 210 | productName = RealTimeFilterUITests; 211 | productReference = D67CFB791C30E6FA005AE284 /* RealTimeFilterUITests.xctest */; 212 | productType = "com.apple.product-type.bundle.ui-testing"; 213 | }; 214 | /* End PBXNativeTarget section */ 215 | 216 | /* Begin PBXProject section */ 217 | D67CFB4A1C30E6FA005AE284 /* Project object */ = { 218 | isa = PBXProject; 219 | attributes = { 220 | LastUpgradeCheck = 0710; 221 | ORGANIZATIONNAME = Victor; 222 | TargetAttributes = { 223 | D67CFB511C30E6FA005AE284 = { 224 | CreatedOnToolsVersion = 7.1; 225 | DevelopmentTeam = 9UQ4BP42V9; 226 | }; 227 | D67CFB6D1C30E6FA005AE284 = { 228 | CreatedOnToolsVersion = 7.1; 229 | DevelopmentTeam = 9UQ4BP42V9; 230 | TestTargetID = D67CFB511C30E6FA005AE284; 231 | }; 232 | D67CFB781C30E6FA005AE284 = { 233 | CreatedOnToolsVersion = 7.1; 234 | DevelopmentTeam = 9UQ4BP42V9; 235 | TestTargetID = D67CFB511C30E6FA005AE284; 236 | }; 237 | }; 238 | }; 239 | buildConfigurationList = D67CFB4D1C30E6FA005AE284 /* Build configuration list for PBXProject "RealTimeFilter" */; 240 | compatibilityVersion = "Xcode 3.2"; 241 | developmentRegion = English; 242 | hasScannedForEncodings = 0; 243 | knownRegions = ( 244 | en, 245 | Base, 246 | ); 247 | mainGroup = D67CFB491C30E6FA005AE284; 248 | productRefGroup = D67CFB531C30E6FA005AE284 /* Products */; 249 | projectDirPath = ""; 250 | projectRoot = ""; 251 | targets = ( 252 | D67CFB511C30E6FA005AE284 /* RealTimeFilter */, 253 | D67CFB6D1C30E6FA005AE284 /* RealTimeFilterTests */, 254 | D67CFB781C30E6FA005AE284 /* RealTimeFilterUITests */, 255 | ); 256 | }; 257 | /* End PBXProject section */ 258 | 259 | /* Begin PBXResourcesBuildPhase section */ 260 | D67CFB501C30E6FA005AE284 /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | D67CFB681C30E6FA005AE284 /* LaunchScreen.storyboard in Resources */, 265 | D67CFB651C30E6FA005AE284 /* Assets.xcassets in Resources */, 266 | D67CFB601C30E6FA005AE284 /* Main.storyboard in Resources */, 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | }; 270 | D67CFB6C1C30E6FA005AE284 /* Resources */ = { 271 | isa = PBXResourcesBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | }; 277 | D67CFB771C30E6FA005AE284 /* Resources */ = { 278 | isa = PBXResourcesBuildPhase; 279 | buildActionMask = 2147483647; 280 | files = ( 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | }; 284 | /* End PBXResourcesBuildPhase section */ 285 | 286 | /* Begin PBXSourcesBuildPhase section */ 287 | D67CFB4E1C30E6FA005AE284 /* Sources */ = { 288 | isa = PBXSourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | D67CFB631C30E6FA005AE284 /* RealTimeFilter.xcdatamodeld in Sources */, 292 | D67CFB5D1C30E6FA005AE284 /* ViewController.m in Sources */, 293 | D67CFB5A1C30E6FA005AE284 /* AppDelegate.m in Sources */, 294 | D67CFB571C30E6FA005AE284 /* main.m in Sources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | D67CFB6A1C30E6FA005AE284 /* Sources */ = { 299 | isa = PBXSourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | D67CFB731C30E6FA005AE284 /* RealTimeFilterTests.m in Sources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | D67CFB751C30E6FA005AE284 /* Sources */ = { 307 | isa = PBXSourcesBuildPhase; 308 | buildActionMask = 2147483647; 309 | files = ( 310 | D67CFB7E1C30E6FA005AE284 /* RealTimeFilterUITests.m in Sources */, 311 | ); 312 | runOnlyForDeploymentPostprocessing = 0; 313 | }; 314 | /* End PBXSourcesBuildPhase section */ 315 | 316 | /* Begin PBXTargetDependency section */ 317 | D67CFB701C30E6FA005AE284 /* PBXTargetDependency */ = { 318 | isa = PBXTargetDependency; 319 | target = D67CFB511C30E6FA005AE284 /* RealTimeFilter */; 320 | targetProxy = D67CFB6F1C30E6FA005AE284 /* PBXContainerItemProxy */; 321 | }; 322 | D67CFB7B1C30E6FA005AE284 /* PBXTargetDependency */ = { 323 | isa = PBXTargetDependency; 324 | target = D67CFB511C30E6FA005AE284 /* RealTimeFilter */; 325 | targetProxy = D67CFB7A1C30E6FA005AE284 /* PBXContainerItemProxy */; 326 | }; 327 | /* End PBXTargetDependency section */ 328 | 329 | /* Begin PBXVariantGroup section */ 330 | D67CFB5E1C30E6FA005AE284 /* Main.storyboard */ = { 331 | isa = PBXVariantGroup; 332 | children = ( 333 | D67CFB5F1C30E6FA005AE284 /* Base */, 334 | ); 335 | name = Main.storyboard; 336 | sourceTree = ""; 337 | }; 338 | D67CFB661C30E6FA005AE284 /* LaunchScreen.storyboard */ = { 339 | isa = PBXVariantGroup; 340 | children = ( 341 | D67CFB671C30E6FA005AE284 /* Base */, 342 | ); 343 | name = LaunchScreen.storyboard; 344 | sourceTree = ""; 345 | }; 346 | /* End PBXVariantGroup section */ 347 | 348 | /* Begin XCBuildConfiguration section */ 349 | D67CFB801C30E6FA005AE284 /* Debug */ = { 350 | isa = XCBuildConfiguration; 351 | buildSettings = { 352 | ALWAYS_SEARCH_USER_PATHS = NO; 353 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 354 | CLANG_CXX_LIBRARY = "libc++"; 355 | CLANG_ENABLE_MODULES = YES; 356 | CLANG_ENABLE_OBJC_ARC = YES; 357 | CLANG_WARN_BOOL_CONVERSION = YES; 358 | CLANG_WARN_CONSTANT_CONVERSION = YES; 359 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 360 | CLANG_WARN_EMPTY_BODY = YES; 361 | CLANG_WARN_ENUM_CONVERSION = YES; 362 | CLANG_WARN_INT_CONVERSION = YES; 363 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 364 | CLANG_WARN_UNREACHABLE_CODE = YES; 365 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 366 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 367 | COPY_PHASE_STRIP = NO; 368 | DEBUG_INFORMATION_FORMAT = dwarf; 369 | ENABLE_STRICT_OBJC_MSGSEND = YES; 370 | ENABLE_TESTABILITY = YES; 371 | GCC_C_LANGUAGE_STANDARD = gnu99; 372 | GCC_DYNAMIC_NO_PIC = NO; 373 | GCC_NO_COMMON_BLOCKS = YES; 374 | GCC_OPTIMIZATION_LEVEL = 0; 375 | GCC_PREPROCESSOR_DEFINITIONS = ( 376 | "DEBUG=1", 377 | "$(inherited)", 378 | ); 379 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 380 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 381 | GCC_WARN_UNDECLARED_SELECTOR = YES; 382 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 383 | GCC_WARN_UNUSED_FUNCTION = YES; 384 | GCC_WARN_UNUSED_VARIABLE = YES; 385 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 386 | MTL_ENABLE_DEBUG_INFO = YES; 387 | ONLY_ACTIVE_ARCH = YES; 388 | SDKROOT = iphoneos; 389 | }; 390 | name = Debug; 391 | }; 392 | D67CFB811C30E6FA005AE284 /* Release */ = { 393 | isa = XCBuildConfiguration; 394 | buildSettings = { 395 | ALWAYS_SEARCH_USER_PATHS = NO; 396 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 397 | CLANG_CXX_LIBRARY = "libc++"; 398 | CLANG_ENABLE_MODULES = YES; 399 | CLANG_ENABLE_OBJC_ARC = YES; 400 | CLANG_WARN_BOOL_CONVERSION = YES; 401 | CLANG_WARN_CONSTANT_CONVERSION = YES; 402 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 403 | CLANG_WARN_EMPTY_BODY = YES; 404 | CLANG_WARN_ENUM_CONVERSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 407 | CLANG_WARN_UNREACHABLE_CODE = YES; 408 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 409 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 410 | COPY_PHASE_STRIP = NO; 411 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 412 | ENABLE_NS_ASSERTIONS = NO; 413 | ENABLE_STRICT_OBJC_MSGSEND = YES; 414 | GCC_C_LANGUAGE_STANDARD = gnu99; 415 | GCC_NO_COMMON_BLOCKS = YES; 416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 418 | GCC_WARN_UNDECLARED_SELECTOR = YES; 419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 420 | GCC_WARN_UNUSED_FUNCTION = YES; 421 | GCC_WARN_UNUSED_VARIABLE = YES; 422 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 423 | MTL_ENABLE_DEBUG_INFO = NO; 424 | SDKROOT = iphoneos; 425 | VALIDATE_PRODUCT = YES; 426 | }; 427 | name = Release; 428 | }; 429 | D67CFB831C30E6FA005AE284 /* Debug */ = { 430 | isa = XCBuildConfiguration; 431 | buildSettings = { 432 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 433 | INFOPLIST_FILE = RealTimeFilter/Info.plist; 434 | IPHONEOS_DEPLOYMENT_TARGET = 8.2; 435 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 436 | PRODUCT_BUNDLE_IDENTIFIER = Victor.RealTimeFilter; 437 | PRODUCT_NAME = "$(TARGET_NAME)"; 438 | }; 439 | name = Debug; 440 | }; 441 | D67CFB841C30E6FA005AE284 /* Release */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 445 | INFOPLIST_FILE = RealTimeFilter/Info.plist; 446 | IPHONEOS_DEPLOYMENT_TARGET = 8.2; 447 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 448 | PRODUCT_BUNDLE_IDENTIFIER = Victor.RealTimeFilter; 449 | PRODUCT_NAME = "$(TARGET_NAME)"; 450 | }; 451 | name = Release; 452 | }; 453 | D67CFB861C30E6FA005AE284 /* Debug */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | BUNDLE_LOADER = "$(TEST_HOST)"; 457 | INFOPLIST_FILE = RealTimeFilterTests/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 459 | PRODUCT_BUNDLE_IDENTIFIER = Victor.RealTimeFilterTests; 460 | PRODUCT_NAME = "$(TARGET_NAME)"; 461 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RealTimeFilter.app/RealTimeFilter"; 462 | }; 463 | name = Debug; 464 | }; 465 | D67CFB871C30E6FA005AE284 /* Release */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | BUNDLE_LOADER = "$(TEST_HOST)"; 469 | INFOPLIST_FILE = RealTimeFilterTests/Info.plist; 470 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 471 | PRODUCT_BUNDLE_IDENTIFIER = Victor.RealTimeFilterTests; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RealTimeFilter.app/RealTimeFilter"; 474 | }; 475 | name = Release; 476 | }; 477 | D67CFB891C30E6FA005AE284 /* Debug */ = { 478 | isa = XCBuildConfiguration; 479 | buildSettings = { 480 | INFOPLIST_FILE = RealTimeFilterUITests/Info.plist; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 482 | PRODUCT_BUNDLE_IDENTIFIER = Victor.RealTimeFilterUITests; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | TEST_TARGET_NAME = RealTimeFilter; 485 | USES_XCTRUNNER = YES; 486 | }; 487 | name = Debug; 488 | }; 489 | D67CFB8A1C30E6FA005AE284 /* Release */ = { 490 | isa = XCBuildConfiguration; 491 | buildSettings = { 492 | INFOPLIST_FILE = RealTimeFilterUITests/Info.plist; 493 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 494 | PRODUCT_BUNDLE_IDENTIFIER = Victor.RealTimeFilterUITests; 495 | PRODUCT_NAME = "$(TARGET_NAME)"; 496 | TEST_TARGET_NAME = RealTimeFilter; 497 | USES_XCTRUNNER = YES; 498 | }; 499 | name = Release; 500 | }; 501 | /* End XCBuildConfiguration section */ 502 | 503 | /* Begin XCConfigurationList section */ 504 | D67CFB4D1C30E6FA005AE284 /* Build configuration list for PBXProject "RealTimeFilter" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | D67CFB801C30E6FA005AE284 /* Debug */, 508 | D67CFB811C30E6FA005AE284 /* Release */, 509 | ); 510 | defaultConfigurationIsVisible = 0; 511 | defaultConfigurationName = Release; 512 | }; 513 | D67CFB821C30E6FA005AE284 /* Build configuration list for PBXNativeTarget "RealTimeFilter" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | D67CFB831C30E6FA005AE284 /* Debug */, 517 | D67CFB841C30E6FA005AE284 /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | }; 521 | D67CFB851C30E6FA005AE284 /* Build configuration list for PBXNativeTarget "RealTimeFilterTests" */ = { 522 | isa = XCConfigurationList; 523 | buildConfigurations = ( 524 | D67CFB861C30E6FA005AE284 /* Debug */, 525 | D67CFB871C30E6FA005AE284 /* Release */, 526 | ); 527 | defaultConfigurationIsVisible = 0; 528 | }; 529 | D67CFB881C30E6FA005AE284 /* Build configuration list for PBXNativeTarget "RealTimeFilterUITests" */ = { 530 | isa = XCConfigurationList; 531 | buildConfigurations = ( 532 | D67CFB891C30E6FA005AE284 /* Debug */, 533 | D67CFB8A1C30E6FA005AE284 /* Release */, 534 | ); 535 | defaultConfigurationIsVisible = 0; 536 | }; 537 | /* End XCConfigurationList section */ 538 | 539 | /* Begin XCVersionGroup section */ 540 | D67CFB611C30E6FA005AE284 /* RealTimeFilter.xcdatamodeld */ = { 541 | isa = XCVersionGroup; 542 | children = ( 543 | D67CFB621C30E6FA005AE284 /* RealTimeFilter.xcdatamodel */, 544 | ); 545 | currentVersion = D67CFB621C30E6FA005AE284 /* RealTimeFilter.xcdatamodel */; 546 | path = RealTimeFilter.xcdatamodeld; 547 | sourceTree = ""; 548 | versionGroupType = wrapper.xcdatamodel; 549 | }; 550 | /* End XCVersionGroup section */ 551 | }; 552 | rootObject = D67CFB4A1C30E6FA005AE284 /* Project object */; 553 | } 554 | -------------------------------------------------------------------------------- /RealTimeFilter.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RealTimeFilter.xcodeproj/project.xcworkspace/xcuserdata/altitudelabs.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/altitudelabs/iOSRealTimeFilterTutorial/906eaead6862ec41848297aa4a0a5802b2337882/RealTimeFilter.xcodeproj/project.xcworkspace/xcuserdata/altitudelabs.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /RealTimeFilter.xcodeproj/xcuserdata/altitudelabs.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /RealTimeFilter.xcodeproj/xcuserdata/altitudelabs.xcuserdatad/xcschemes/RealTimeFilter.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /RealTimeFilter.xcodeproj/xcuserdata/altitudelabs.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RealTimeFilter.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D67CFB511C30E6FA005AE284 16 | 17 | primary 18 | 19 | 20 | D67CFB6D1C30E6FA005AE284 21 | 22 | primary 23 | 24 | 25 | D67CFB781C30E6FA005AE284 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /RealTimeFilter/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // RealTimeFilter 4 | // 5 | // Created by Altitude Labs on 28/12/15. 6 | // Copyright © 2015 Victor. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (strong, nonatomic) UIWindow *window; 15 | 16 | @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; 17 | @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; 18 | @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; 19 | 20 | - (void)saveContext; 21 | - (NSURL *)applicationDocumentsDirectory; 22 | 23 | 24 | @end 25 | 26 | -------------------------------------------------------------------------------- /RealTimeFilter/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // RealTimeFilter 4 | // 5 | // Created by Altitude Labs on 28/12/15. 6 | // Copyright © 2015 Victor. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | // Saves changes in the application's managed object context before the application terminates. 44 | [self saveContext]; 45 | } 46 | 47 | #pragma mark - Core Data stack 48 | 49 | @synthesize managedObjectContext = _managedObjectContext; 50 | @synthesize managedObjectModel = _managedObjectModel; 51 | @synthesize persistentStoreCoordinator = _persistentStoreCoordinator; 52 | 53 | - (NSURL *)applicationDocumentsDirectory { 54 | // The directory the application uses to store the Core Data store file. This code uses a directory named "Victor.RealTimeFilter" in the application's documents directory. 55 | return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; 56 | } 57 | 58 | - (NSManagedObjectModel *)managedObjectModel { 59 | // The managed object model for the application. It is a fatal error for the application not to be able to find and load its model. 60 | if (_managedObjectModel != nil) { 61 | return _managedObjectModel; 62 | } 63 | NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"RealTimeFilter" withExtension:@"momd"]; 64 | _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; 65 | return _managedObjectModel; 66 | } 67 | 68 | - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { 69 | // The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. 70 | if (_persistentStoreCoordinator != nil) { 71 | return _persistentStoreCoordinator; 72 | } 73 | 74 | // Create the coordinator and store 75 | 76 | _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; 77 | NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"RealTimeFilter.sqlite"]; 78 | NSError *error = nil; 79 | NSString *failureReason = @"There was an error creating or loading the application's saved data."; 80 | if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { 81 | // Report any error we got. 82 | NSMutableDictionary *dict = [NSMutableDictionary dictionary]; 83 | dict[NSLocalizedDescriptionKey] = @"Failed to initialize the application's saved data"; 84 | dict[NSLocalizedFailureReasonErrorKey] = failureReason; 85 | dict[NSUnderlyingErrorKey] = error; 86 | error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict]; 87 | // Replace this with code to handle the error appropriately. 88 | // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 89 | NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 90 | abort(); 91 | } 92 | 93 | return _persistentStoreCoordinator; 94 | } 95 | 96 | 97 | - (NSManagedObjectContext *)managedObjectContext { 98 | // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) 99 | if (_managedObjectContext != nil) { 100 | return _managedObjectContext; 101 | } 102 | 103 | NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; 104 | if (!coordinator) { 105 | return nil; 106 | } 107 | _managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; 108 | [_managedObjectContext setPersistentStoreCoordinator:coordinator]; 109 | return _managedObjectContext; 110 | } 111 | 112 | #pragma mark - Core Data Saving support 113 | 114 | - (void)saveContext { 115 | NSManagedObjectContext *managedObjectContext = self.managedObjectContext; 116 | if (managedObjectContext != nil) { 117 | NSError *error = nil; 118 | if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { 119 | // Replace this implementation with code to handle the error appropriately. 120 | // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. 121 | NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 122 | abort(); 123 | } 124 | } 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /RealTimeFilter/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 | } -------------------------------------------------------------------------------- /RealTimeFilter/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 | -------------------------------------------------------------------------------- /RealTimeFilter/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 | -------------------------------------------------------------------------------- /RealTimeFilter/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /RealTimeFilter/RealTimeFilter.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | _XCCurrentVersionName 6 | RealTimeFilter.xcdatamodel 7 | 8 | 9 | -------------------------------------------------------------------------------- /RealTimeFilter/RealTimeFilter.xcdatamodeld/RealTimeFilter.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RealTimeFilter/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // RealtimeVideoFilter 4 | // 5 | // Created by Altitude Labs on 23/12/15. 6 | // Copyright © 2015 Victor. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /RealTimeFilter/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // RealtimeVideoFilter 4 | // 5 | // Created by Altitude Labs on 23/12/15. 6 | // Copyright © 2015 Victor. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | #import 12 | #import 13 | #import "AppDelegate.h" 14 | 15 | @interface ViewController () 16 | 17 | @property GLKView *videoPreviewView; 18 | @property CIContext *ciContext; 19 | @property EAGLContext *eaglContext; 20 | @property CGRect videoPreviewViewBounds; 21 | 22 | @property AVCaptureDevice *videoDevice; 23 | @property AVCaptureSession *captureSession; 24 | @property dispatch_queue_t captureSessionQueue; 25 | 26 | @end 27 | 28 | @implementation ViewController 29 | 30 | - (void)viewDidLoad { 31 | [super viewDidLoad]; 32 | 33 | // remove the view's background color; this allows us not to use the opaque property (self.view.opaque = NO) since we remove the background color drawing altogether 34 | self.view.backgroundColor = [UIColor clearColor]; 35 | 36 | // setup the GLKView for video/image preview 37 | UIView *window = ((AppDelegate *)[UIApplication sharedApplication].delegate).window; 38 | _eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; 39 | _videoPreviewView = [[GLKView alloc] initWithFrame:window.bounds context:_eaglContext]; 40 | _videoPreviewView.enableSetNeedsDisplay = NO; 41 | 42 | // because the native video image from the back camera is in UIDeviceOrientationLandscapeLeft (i.e. the home button is on the right), we need to apply a clockwise 90 degree transform so that we can draw the video preview as if we were in a landscape-oriented view; if you're using the front camera and you want to have a mirrored preview (so that the user is seeing themselves in the mirror), you need to apply an additional horizontal flip (by concatenating CGAffineTransformMakeScale(-1.0, 1.0) to the rotation transform) 43 | _videoPreviewView.transform = CGAffineTransformMakeRotation(M_PI_2); 44 | _videoPreviewView.frame = window.bounds; 45 | 46 | // we make our video preview view a subview of the window, and send it to the back; this makes FHViewController's view (and its UI elements) on top of the video preview, and also makes video preview unaffected by device rotation 47 | [window addSubview:_videoPreviewView]; 48 | [window sendSubviewToBack:_videoPreviewView]; 49 | 50 | // bind the frame buffer to get the frame buffer width and height; 51 | // the bounds used by CIContext when drawing to a GLKView are in pixels (not points), 52 | // hence the need to read from the frame buffer's width and height; 53 | // in addition, since we will be accessing the bounds in another queue (_captureSessionQueue), 54 | // we want to obtain this piece of information so that we won't be 55 | // accessing _videoPreviewView's properties from another thread/queue 56 | [_videoPreviewView bindDrawable]; 57 | _videoPreviewViewBounds = CGRectZero; 58 | _videoPreviewViewBounds.size.width = _videoPreviewView.drawableWidth; 59 | _videoPreviewViewBounds.size.height = _videoPreviewView.drawableHeight; 60 | 61 | 62 | // create the CIContext instance, note that this must be done after _videoPreviewView is properly set up 63 | _ciContext = [CIContext contextWithEAGLContext:_eaglContext options:@{kCIContextWorkingColorSpace : [NSNull null]} ]; 64 | 65 | if ([[AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo] count] > 0) 66 | { 67 | 68 | [self _start]; 69 | } 70 | else 71 | { 72 | NSLog(@"No device with AVMediaTypeVideo"); 73 | } 74 | } 75 | 76 | - (void)_start 77 | { 78 | // get the input device and also validate the settings 79 | NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; 80 | 81 | AVCaptureDevicePosition position = AVCaptureDevicePositionBack; 82 | 83 | for (AVCaptureDevice *device in videoDevices) 84 | { 85 | if (device.position == position) { 86 | _videoDevice = device; 87 | break; 88 | } 89 | } 90 | 91 | // obtain device input 92 | NSError *error = nil; 93 | AVCaptureDeviceInput *videoDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:_videoDevice error:&error]; 94 | if (!videoDeviceInput) 95 | { 96 | NSLog(@"%@", [NSString stringWithFormat:@"Unable to obtain video device input, error: %@", error]); 97 | return; 98 | } 99 | 100 | // obtain the preset and validate the preset 101 | NSString *preset = AVCaptureSessionPresetHigh; 102 | if (![_videoDevice supportsAVCaptureSessionPreset:preset]) 103 | { 104 | NSLog(@"%@", [NSString stringWithFormat:@"Capture session preset not supported by video device: %@", preset]); 105 | return; 106 | } 107 | 108 | // create the capture session 109 | _captureSession = [[AVCaptureSession alloc] init]; 110 | _captureSession.sessionPreset = preset; 111 | 112 | // CoreImage wants BGRA pixel format 113 | NSDictionary *outputSettings = @{ (id)kCVPixelBufferPixelFormatTypeKey : [NSNumber numberWithInteger:kCVPixelFormatType_32BGRA]}; 114 | // create and configure video data output 115 | AVCaptureVideoDataOutput *videoDataOutput = [[AVCaptureVideoDataOutput alloc] init]; 116 | videoDataOutput.videoSettings = outputSettings; 117 | 118 | // create the dispatch queue for handling capture session delegate method calls 119 | _captureSessionQueue = dispatch_queue_create("capture_session_queue", NULL); 120 | [videoDataOutput setSampleBufferDelegate:self queue:_captureSessionQueue]; 121 | 122 | videoDataOutput.alwaysDiscardsLateVideoFrames = YES; 123 | 124 | // begin configure capture session 125 | [_captureSession beginConfiguration]; 126 | 127 | if (![_captureSession canAddOutput:videoDataOutput]) 128 | { 129 | NSLog(@"Cannot add video data output"); 130 | _captureSession = nil; 131 | return; 132 | } 133 | 134 | // connect the video device input and video data and still image outputs 135 | [_captureSession addInput:videoDeviceInput]; 136 | [_captureSession addOutput:videoDataOutput]; 137 | 138 | [_captureSession commitConfiguration]; 139 | 140 | // then start everything 141 | [_captureSession startRunning]; 142 | } 143 | 144 | 145 | - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection 146 | { 147 | CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); 148 | CIImage *sourceImage = [CIImage imageWithCVPixelBuffer:(CVPixelBufferRef)imageBuffer options:nil]; 149 | CGRect sourceExtent = sourceImage.extent; 150 | 151 | // Image processing 152 | CIFilter * vignetteFilter = [CIFilter filterWithName:@"CIVignetteEffect"]; 153 | [vignetteFilter setValue:sourceImage forKey:kCIInputImageKey]; 154 | [vignetteFilter setValue:[CIVector vectorWithX:sourceExtent.size.width/2 Y:sourceExtent.size.height/2] forKey:kCIInputCenterKey]; 155 | [vignetteFilter setValue:@(sourceExtent.size.width/2) forKey:kCIInputRadiusKey]; 156 | CIImage *filteredImage = [vignetteFilter outputImage]; 157 | 158 | CIFilter *effectFilter = [CIFilter filterWithName:@"CIPhotoEffectInstant"]; 159 | [effectFilter setValue:filteredImage forKey:kCIInputImageKey]; 160 | filteredImage = [effectFilter outputImage]; 161 | 162 | 163 | CGFloat sourceAspect = sourceExtent.size.width / sourceExtent.size.height; 164 | CGFloat previewAspect = _videoPreviewViewBounds.size.width / _videoPreviewViewBounds.size.height; 165 | 166 | // we want to maintain the aspect radio of the screen size, so we clip the video image 167 | CGRect drawRect = sourceExtent; 168 | if (sourceAspect > previewAspect) 169 | { 170 | // use full height of the video image, and center crop the width 171 | drawRect.origin.x += (drawRect.size.width - drawRect.size.height * previewAspect) / 2.0; 172 | drawRect.size.width = drawRect.size.height * previewAspect; 173 | } 174 | else 175 | { 176 | // use full width of the video image, and center crop the height 177 | drawRect.origin.y += (drawRect.size.height - drawRect.size.width / previewAspect) / 2.0; 178 | drawRect.size.height = drawRect.size.width / previewAspect; 179 | } 180 | 181 | [_videoPreviewView bindDrawable]; 182 | 183 | if (_eaglContext != [EAGLContext currentContext]) 184 | [EAGLContext setCurrentContext:_eaglContext]; 185 | 186 | // clear eagl view to grey 187 | glClearColor(0.5, 0.5, 0.5, 1.0); 188 | glClear(GL_COLOR_BUFFER_BIT); 189 | 190 | // set the blend mode to "source over" so that CI will use that 191 | glEnable(GL_BLEND); 192 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); 193 | 194 | if (filteredImage) 195 | [_ciContext drawImage:filteredImage inRect:_videoPreviewViewBounds fromRect:drawRect]; 196 | 197 | [_videoPreviewView display]; 198 | } 199 | 200 | @end 201 | -------------------------------------------------------------------------------- /RealTimeFilter/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RealTimeFilter 4 | // 5 | // Created by Altitude Labs on 28/12/15. 6 | // Copyright © 2015 Victor. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /RealTimeFilterTests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /RealTimeFilterTests/RealTimeFilterTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RealTimeFilterTests.m 3 | // RealTimeFilterTests 4 | // 5 | // Created by Altitude Labs on 28/12/15. 6 | // Copyright © 2015 Victor. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RealTimeFilterTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation RealTimeFilterTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /RealTimeFilterUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /RealTimeFilterUITests/RealTimeFilterUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // RealTimeFilterUITests.m 3 | // RealTimeFilterUITests 4 | // 5 | // Created by Altitude Labs on 28/12/15. 6 | // Copyright © 2015 Victor. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface RealTimeFilterUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation RealTimeFilterUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------