diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..0d17589 Binary files /dev/null and b/.DS_Store differ diff --git a/InControl/.DS_Store b/InControl/.DS_Store new file mode 100644 index 0000000..3b599d4 Binary files /dev/null and b/InControl/.DS_Store differ diff --git a/InControl/InControl.xcodeproj/project.pbxproj b/InControl/InControl.xcodeproj/project.pbxproj new file mode 100644 index 0000000..23ed121 --- /dev/null +++ b/InControl/InControl.xcodeproj/project.pbxproj @@ -0,0 +1,1035 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0B17F5521BD83F9600EC7901 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B17F5511BD83F9600EC7901 /* CoreLocation.framework */; }; + 0B8208931BD43A5B00117BE1 /* MeetupTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8208921BD43A5B00117BE1 /* MeetupTableViewController.m */; settings = {ASSET_TAGS = (); }; }; + 0B8208961BD43CC500117BE1 /* MeetupTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8208951BD43CC500117BE1 /* MeetupTableViewCell.m */; settings = {ASSET_TAGS = (); }; }; + 0BAA7ABC1BD34A4D00CB7443 /* CustomTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BAA7ABB1BD34A4D00CB7443 /* CustomTableViewCell.m */; settings = {ASSET_TAGS = (); }; }; + 44FA49C8E2DCD94AB1DEA855 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CA12CD6286D3D05E336A1706 /* libPods.a */; }; + 8474039D1BD8A18700A460D8 /* InstaTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E6D4E51BD872D700ECAE47 /* InstaTableViewController.m */; }; + 8474039E1BD8A18F00A460D8 /* InstagramPost.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E6D4DC1BD86CFB00ECAE47 /* InstagramPost.m */; }; + 847403A31BD8BA6800A460D8 /* CandyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 847403A21BD8BA6800A460D8 /* CandyViewController.m */; settings = {ASSET_TAGS = (); }; }; + 84CF452B1BCAD0EA00EAA3BF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF452A1BCAD0EA00EAA3BF /* main.m */; }; + 84CF452E1BCAD0EA00EAA3BF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF452D1BCAD0EA00EAA3BF /* AppDelegate.m */; }; + 84CF45311BCAD0EA00EAA3BF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF45301BCAD0EA00EAA3BF /* ViewController.m */; }; + 84CF45341BCAD0EA00EAA3BF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45321BCAD0EA00EAA3BF /* Main.storyboard */; }; + 84CF45371BCAD0EB00EAA3BF /* InControl.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 84CF45351BCAD0EA00EAA3BF /* InControl.xcdatamodeld */; }; + 84CF45391BCAD0EB00EAA3BF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45381BCAD0EB00EAA3BF /* Assets.xcassets */; }; + 84CF453C1BCAD0EB00EAA3BF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 84CF453A1BCAD0EB00EAA3BF /* LaunchScreen.storyboard */; }; + 84CF45471BCAD0EB00EAA3BF /* InControlTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF45461BCAD0EB00EAA3BF /* InControlTests.m */; }; + 84CF45521BCAD0EB00EAA3BF /* InControlUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF45511BCAD0EB00EAA3BF /* InControlUITests.m */; }; + 84CF45601BCAD10700EAA3BF /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CF455F1BCAD10700EAA3BF /* Accelerate.framework */; }; + 84CF45621BCAD10D00EAA3BF /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CF45611BCAD10D00EAA3BF /* QuartzCore.framework */; }; + 84CF45641BCAD11300EAA3BF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CF45631BCAD11300EAA3BF /* Foundation.framework */; }; + 84CF45661BCAD11A00EAA3BF /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CF45651BCAD11A00EAA3BF /* CoreGraphics.framework */; }; + 84CF45681BCAD12100EAA3BF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84CF45671BCAD12100EAA3BF /* UIKit.framework */; }; + 84CF456B1BCAD14300EAA3BF /* RNFrostedSidebar.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF456A1BCAD14300EAA3BF /* RNFrostedSidebar.m */; settings = {ASSET_TAGS = (); }; }; + 84CF45711BCAD15A00EAA3BF /* burger.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF456C1BCAD15A00EAA3BF /* burger.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45721BCAD15A00EAA3BF /* burger@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF456D1BCAD15A00EAA3BF /* burger@2x.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45731BCAD15A00EAA3BF /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF456E1BCAD15A00EAA3BF /* Default-568h@2x.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45741BCAD15A00EAA3BF /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF456F1BCAD15A00EAA3BF /* Default.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45751BCAD15A00EAA3BF /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45701BCAD15A00EAA3BF /* Default@2x.png */; settings = {ASSET_TAGS = (); }; }; + 84CF457B1BCAD16400EAA3BF /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45761BCAD16400EAA3BF /* InfoPlist.strings */; settings = {ASSET_TAGS = (); }; }; + 84CF457C1BCAD16400EAA3BF /* gear.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45771BCAD16400EAA3BF /* gear.png */; settings = {ASSET_TAGS = (); }; }; + 84CF457D1BCAD16400EAA3BF /* gear@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45781BCAD16400EAA3BF /* gear@2x.png */; settings = {ASSET_TAGS = (); }; }; + 84CF457E1BCAD16400EAA3BF /* globe.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45791BCAD16400EAA3BF /* globe.png */; settings = {ASSET_TAGS = (); }; }; + 84CF457F1BCAD16400EAA3BF /* globe@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF457A1BCAD16400EAA3BF /* globe@2x.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45811BCAD2A600EAA3BF /* profile.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45801BCAD2A600EAA3BF /* profile.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45851BCAD2AE00EAA3BF /* profile@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45821BCAD2AE00EAA3BF /* profile@2x.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45861BCAD2AE00EAA3BF /* Profile_image.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45831BCAD2AE00EAA3BF /* Profile_image.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45871BCAD2AE00EAA3BF /* Profile_image@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45841BCAD2AE00EAA3BF /* Profile_image@2x.png */; settings = {ASSET_TAGS = (); }; }; + 84CF458A1BCAD2C900EAA3BF /* star.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45881BCAD2C900EAA3BF /* star.png */; settings = {ASSET_TAGS = (); }; }; + 84CF458B1BCAD2C900EAA3BF /* star@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45891BCAD2C900EAA3BF /* star@2x.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45951BCAED3D00EAA3BF /* search.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45941BCAED3D00EAA3BF /* search.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45991BCAF49900EAA3BF /* budget.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45981BCAF49900EAA3BF /* budget.png */; settings = {ASSET_TAGS = (); }; }; + 84CF459B1BCAF50100EAA3BF /* food.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF459A1BCAF50100EAA3BF /* food.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45A11BCAF64300EAA3BF /* hotel.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45A01BCAF64300EAA3BF /* hotel.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45A51BCAF71300EAA3BF /* video.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45A41BCAF71300EAA3BF /* video.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45A71BCAF7D300EAA3BF /* image.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45A61BCAF7D300EAA3BF /* image.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45AD1BCAFA5A00EAA3BF /* insta.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF45AC1BCAFA5A00EAA3BF /* insta.png */; settings = {ASSET_TAGS = (); }; }; + 84CF45B61BCB057600EAA3BF /* WelcomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF45B51BCB057600EAA3BF /* WelcomeViewController.m */; settings = {ASSET_TAGS = (); }; }; + 84CF45BC1BCB0E9D00EAA3BF /* ImageTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF45BB1BCB0E9D00EAA3BF /* ImageTableViewController.m */; settings = {ASSET_TAGS = (); }; }; + 84CF45CB1BCC51C200EAA3BF /* VideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF45CA1BCC51C200EAA3BF /* VideoViewController.m */; settings = {ASSET_TAGS = (); }; }; + 84CF45CE1BCD8F7200EAA3BF /* Youtube.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF45CD1BCD8F7200EAA3BF /* Youtube.m */; settings = {ASSET_TAGS = (); }; }; + 84CF46591BCDE80000EAA3BF /* meetup.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF46581BCDE80000EAA3BF /* meetup.png */; settings = {ASSET_TAGS = (); }; }; + 84CF46621BCE29DB00EAA3BF /* GamesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF46611BCE29DB00EAA3BF /* GamesViewController.m */; settings = {ASSET_TAGS = (); }; }; + 84CF46661BCE2B4600EAA3BF /* VisitedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF46651BCE2B4600EAA3BF /* VisitedViewController.m */; settings = {ASSET_TAGS = (); }; }; + 84CF46AE1BD0678700EAA3BF /* Tunnel.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF46AA1BD0678700EAA3BF /* Tunnel.png */; settings = {ASSET_TAGS = (); }; }; + 84CF46AF1BD0678700EAA3BF /* GameBack.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF46AB1BD0678700EAA3BF /* GameBack.png */; settings = {ASSET_TAGS = (); }; }; + 84CF46B01BD0678700EAA3BF /* BirdUp.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF46AC1BD0678700EAA3BF /* BirdUp.png */; settings = {ASSET_TAGS = (); }; }; + 84CF46B11BD0678700EAA3BF /* BirdDown.png in Resources */ = {isa = PBXBuildFile; fileRef = 84CF46AD1BD0678700EAA3BF /* BirdDown.png */; settings = {ASSET_TAGS = (); }; }; + 84CF46B51BD0681800EAA3BF /* FlappyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF46B41BD0681800EAA3BF /* FlappyViewController.m */; settings = {ASSET_TAGS = (); }; }; + 84CF46B81BD0683000EAA3BF /* FlappyGame.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CF46B71BD0683000EAA3BF /* FlappyGame.m */; settings = {ASSET_TAGS = (); }; }; + 84E6D4561BD08CCE00ECAE47 /* homeButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E6D4551BD08CCE00ECAE47 /* homeButton.png */; settings = {ASSET_TAGS = (); }; }; + 84E6D4D41BD6F93200ECAE47 /* VisitedTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E6D4D31BD6F93200ECAE47 /* VisitedTableViewCell.m */; settings = {ASSET_TAGS = (); }; }; + 84E6D4E11BD86D0800ECAE47 /* InstagramPostTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84E6D4E01BD86D0800ECAE47 /* InstagramPostTableViewCell.m */; settings = {ASSET_TAGS = (); }; }; + 84E6D4E31BD86D7400ECAE47 /* InstagramPostTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84E6D4E21BD86D7400ECAE47 /* InstagramPostTableViewCell.xib */; settings = {ASSET_TAGS = (); }; }; + D9389C3B1BD1E173009A8A15 /* DetailVisitedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D9389C3A1BD1E173009A8A15 /* DetailVisitedViewController.m */; settings = {ASSET_TAGS = (); }; }; + D9682D5D1BCD4E1600647FD8 /* APIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D9682D5C1BCD4E1600647FD8 /* APIManager.m */; settings = {ASSET_TAGS = (); }; }; + D9682D601BCD501700647FD8 /* Venue.m in Sources */ = {isa = PBXBuildFile; fileRef = D9682D5F1BCD501700647FD8 /* Venue.m */; settings = {ASSET_TAGS = (); }; }; + D9682D631BCD665200647FD8 /* HotelViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D9682D621BCD665200647FD8 /* HotelViewController.m */; settings = {ASSET_TAGS = (); }; }; + D9682D661BCD671000647FD8 /* FoodViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D9682D651BCD671000647FD8 /* FoodViewController.m */; settings = {ASSET_TAGS = (); }; }; + D9682E681BD1DD9C00647FD8 /* AddVisitedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D9682E671BD1DD9C00647FD8 /* AddVisitedViewController.m */; settings = {ASSET_TAGS = (); }; }; + D9CF57E01BD86CA6001B24F9 /* City+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = D9CF57D91BD86CA6001B24F9 /* City+CoreDataProperties.m */; settings = {ASSET_TAGS = (); }; }; + D9CF57E11BD86CA6001B24F9 /* City.m in Sources */ = {isa = PBXBuildFile; fileRef = D9CF57DB1BD86CA6001B24F9 /* City.m */; settings = {ASSET_TAGS = (); }; }; + D9CF57E31BD86CA6001B24F9 /* Photo.m in Sources */ = {isa = PBXBuildFile; fileRef = D9CF57DF1BD86CA6001B24F9 /* Photo.m */; settings = {ASSET_TAGS = (); }; }; + D9CF57E61BD877E3001B24F9 /* PhotoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D9CF57E51BD877E3001B24F9 /* PhotoCell.m */; settings = {ASSET_TAGS = (); }; }; + D9E6A86C1BD43BCC0092BFA7 /* FoursquareAPIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D9E6A86B1BD43BCC0092BFA7 /* FoursquareAPIManager.m */; settings = {ASSET_TAGS = (); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 84CF45431BCAD0EB00EAA3BF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 84CF451E1BCAD0EA00EAA3BF /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84CF45251BCAD0EA00EAA3BF; + remoteInfo = InControl; + }; + 84CF454E1BCAD0EB00EAA3BF /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 84CF451E1BCAD0EA00EAA3BF /* Project object */; + proxyType = 1; + remoteGlobalIDString = 84CF45251BCAD0EA00EAA3BF; + remoteInfo = InControl; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 0B17F5511BD83F9600EC7901 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; + 0B8208911BD43A5B00117BE1 /* MeetupTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeetupTableViewController.h; sourceTree = ""; }; + 0B8208921BD43A5B00117BE1 /* MeetupTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MeetupTableViewController.m; sourceTree = ""; }; + 0B8208941BD43CC500117BE1 /* MeetupTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MeetupTableViewCell.h; sourceTree = ""; }; + 0B8208951BD43CC500117BE1 /* MeetupTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MeetupTableViewCell.m; sourceTree = ""; }; + 0BAA7ABA1BD34A4D00CB7443 /* CustomTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomTableViewCell.h; sourceTree = ""; }; + 0BAA7ABB1BD34A4D00CB7443 /* CustomTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomTableViewCell.m; sourceTree = ""; }; + 4B5D5618892B20D168B80EB1 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + 847403A11BD8BA6800A460D8 /* CandyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CandyViewController.h; sourceTree = ""; }; + 847403A21BD8BA6800A460D8 /* CandyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CandyViewController.m; sourceTree = ""; }; + 84CF45261BCAD0EA00EAA3BF /* InControl.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InControl.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 84CF452A1BCAD0EA00EAA3BF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 84CF452C1BCAD0EA00EAA3BF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 84CF452D1BCAD0EA00EAA3BF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 84CF452F1BCAD0EA00EAA3BF /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 84CF45301BCAD0EA00EAA3BF /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 84CF45331BCAD0EA00EAA3BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 84CF45361BCAD0EB00EAA3BF /* InControl.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = InControl.xcdatamodel; sourceTree = ""; }; + 84CF45381BCAD0EB00EAA3BF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 84CF453B1BCAD0EB00EAA3BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 84CF453D1BCAD0EB00EAA3BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 84CF45421BCAD0EB00EAA3BF /* InControlTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InControlTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 84CF45461BCAD0EB00EAA3BF /* InControlTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InControlTests.m; sourceTree = ""; }; + 84CF45481BCAD0EB00EAA3BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 84CF454D1BCAD0EB00EAA3BF /* InControlUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InControlUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 84CF45511BCAD0EB00EAA3BF /* InControlUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InControlUITests.m; sourceTree = ""; }; + 84CF45531BCAD0EB00EAA3BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 84CF455F1BCAD10700EAA3BF /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; + 84CF45611BCAD10D00EAA3BF /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + 84CF45631BCAD11300EAA3BF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 84CF45651BCAD11A00EAA3BF /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 84CF45671BCAD12100EAA3BF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 84CF45691BCAD14300EAA3BF /* RNFrostedSidebar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNFrostedSidebar.h; sourceTree = ""; }; + 84CF456A1BCAD14300EAA3BF /* RNFrostedSidebar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNFrostedSidebar.m; sourceTree = ""; }; + 84CF456C1BCAD15A00EAA3BF /* burger.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = burger.png; sourceTree = ""; }; + 84CF456D1BCAD15A00EAA3BF /* burger@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "burger@2x.png"; sourceTree = ""; }; + 84CF456E1BCAD15A00EAA3BF /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; + 84CF456F1BCAD15A00EAA3BF /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + 84CF45701BCAD15A00EAA3BF /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; + 84CF45761BCAD16400EAA3BF /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = InfoPlist.strings; sourceTree = ""; }; + 84CF45771BCAD16400EAA3BF /* gear.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = gear.png; sourceTree = ""; }; + 84CF45781BCAD16400EAA3BF /* gear@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "gear@2x.png"; sourceTree = ""; }; + 84CF45791BCAD16400EAA3BF /* globe.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = globe.png; sourceTree = ""; }; + 84CF457A1BCAD16400EAA3BF /* globe@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "globe@2x.png"; sourceTree = ""; }; + 84CF45801BCAD2A600EAA3BF /* profile.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = profile.png; sourceTree = ""; }; + 84CF45821BCAD2AE00EAA3BF /* profile@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "profile@2x.png"; sourceTree = ""; }; + 84CF45831BCAD2AE00EAA3BF /* Profile_image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Profile_image.png; sourceTree = ""; }; + 84CF45841BCAD2AE00EAA3BF /* Profile_image@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Profile_image@2x.png"; sourceTree = ""; }; + 84CF45881BCAD2C900EAA3BF /* star.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = star.png; sourceTree = ""; }; + 84CF45891BCAD2C900EAA3BF /* star@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "star@2x.png"; sourceTree = ""; }; + 84CF45941BCAED3D00EAA3BF /* search.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = search.png; sourceTree = ""; }; + 84CF45981BCAF49900EAA3BF /* budget.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = budget.png; sourceTree = ""; }; + 84CF459A1BCAF50100EAA3BF /* food.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = food.png; sourceTree = ""; }; + 84CF45A01BCAF64300EAA3BF /* hotel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = hotel.png; sourceTree = ""; }; + 84CF45A41BCAF71300EAA3BF /* video.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = video.png; sourceTree = ""; }; + 84CF45A61BCAF7D300EAA3BF /* image.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image.png; sourceTree = ""; }; + 84CF45AC1BCAFA5A00EAA3BF /* insta.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = insta.png; sourceTree = ""; }; + 84CF45B41BCB057600EAA3BF /* WelcomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelcomeViewController.h; sourceTree = ""; }; + 84CF45B51BCB057600EAA3BF /* WelcomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WelcomeViewController.m; sourceTree = ""; }; + 84CF45BA1BCB0E9D00EAA3BF /* ImageTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageTableViewController.h; sourceTree = ""; }; + 84CF45BB1BCB0E9D00EAA3BF /* ImageTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageTableViewController.m; sourceTree = ""; }; + 84CF45C91BCC51C200EAA3BF /* VideoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoViewController.h; sourceTree = ""; }; + 84CF45CA1BCC51C200EAA3BF /* VideoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VideoViewController.m; sourceTree = ""; }; + 84CF45CC1BCD8F7200EAA3BF /* Youtube.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Youtube.h; sourceTree = ""; }; + 84CF45CD1BCD8F7200EAA3BF /* Youtube.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Youtube.m; sourceTree = ""; }; + 84CF46581BCDE80000EAA3BF /* meetup.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = meetup.png; sourceTree = ""; }; + 84CF46601BCE29DB00EAA3BF /* GamesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GamesViewController.h; sourceTree = ""; }; + 84CF46611BCE29DB00EAA3BF /* GamesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GamesViewController.m; sourceTree = ""; }; + 84CF46641BCE2B4600EAA3BF /* VisitedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedViewController.h; sourceTree = ""; }; + 84CF46651BCE2B4600EAA3BF /* VisitedViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VisitedViewController.m; sourceTree = ""; }; + 84CF46AA1BD0678700EAA3BF /* Tunnel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Tunnel.png; sourceTree = ""; }; + 84CF46AB1BD0678700EAA3BF /* GameBack.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = GameBack.png; sourceTree = ""; }; + 84CF46AC1BD0678700EAA3BF /* BirdUp.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = BirdUp.png; sourceTree = ""; }; + 84CF46AD1BD0678700EAA3BF /* BirdDown.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = BirdDown.png; sourceTree = ""; }; + 84CF46B31BD0681800EAA3BF /* FlappyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlappyViewController.h; sourceTree = ""; }; + 84CF46B41BD0681800EAA3BF /* FlappyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlappyViewController.m; sourceTree = ""; }; + 84CF46B61BD0683000EAA3BF /* FlappyGame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlappyGame.h; sourceTree = ""; }; + 84CF46B71BD0683000EAA3BF /* FlappyGame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlappyGame.m; sourceTree = ""; }; + 84E6D4551BD08CCE00ECAE47 /* homeButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = homeButton.png; sourceTree = ""; }; + 84E6D4D21BD6F93200ECAE47 /* VisitedTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedTableViewCell.h; sourceTree = ""; }; + 84E6D4D31BD6F93200ECAE47 /* VisitedTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VisitedTableViewCell.m; sourceTree = ""; }; + 84E6D4DB1BD86CFB00ECAE47 /* InstagramPost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstagramPost.h; sourceTree = ""; }; + 84E6D4DC1BD86CFB00ECAE47 /* InstagramPost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstagramPost.m; sourceTree = ""; }; + 84E6D4DF1BD86D0800ECAE47 /* InstagramPostTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstagramPostTableViewCell.h; sourceTree = ""; }; + 84E6D4E01BD86D0800ECAE47 /* InstagramPostTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstagramPostTableViewCell.m; sourceTree = ""; }; + 84E6D4E21BD86D7400ECAE47 /* InstagramPostTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InstagramPostTableViewCell.xib; sourceTree = ""; }; + 84E6D4E41BD872D700ECAE47 /* InstaTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstaTableViewController.h; sourceTree = ""; }; + 84E6D4E51BD872D700ECAE47 /* InstaTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstaTableViewController.m; sourceTree = ""; }; + CA12CD6286D3D05E336A1706 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + CA3CA915C16CD3F8F7FFC788 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + D9389C391BD1E173009A8A15 /* DetailVisitedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailVisitedViewController.h; sourceTree = ""; }; + D9389C3A1BD1E173009A8A15 /* DetailVisitedViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailVisitedViewController.m; sourceTree = ""; }; + D9682D5B1BCD4E1600647FD8 /* APIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIManager.h; sourceTree = ""; }; + D9682D5C1BCD4E1600647FD8 /* APIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIManager.m; sourceTree = ""; }; + D9682D5E1BCD501600647FD8 /* Venue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Venue.h; sourceTree = ""; }; + D9682D5F1BCD501700647FD8 /* Venue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Venue.m; sourceTree = ""; }; + D9682D611BCD665200647FD8 /* HotelViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HotelViewController.h; sourceTree = ""; }; + D9682D621BCD665200647FD8 /* HotelViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HotelViewController.m; sourceTree = ""; }; + D9682D641BCD671000647FD8 /* FoodViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoodViewController.h; sourceTree = ""; }; + D9682D651BCD671000647FD8 /* FoodViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FoodViewController.m; sourceTree = ""; }; + D9682E661BD1DD9C00647FD8 /* AddVisitedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddVisitedViewController.h; sourceTree = ""; }; + D9682E671BD1DD9C00647FD8 /* AddVisitedViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddVisitedViewController.m; sourceTree = ""; }; + D9CF57D81BD86CA6001B24F9 /* City+CoreDataProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "City+CoreDataProperties.h"; sourceTree = ""; }; + D9CF57D91BD86CA6001B24F9 /* City+CoreDataProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "City+CoreDataProperties.m"; sourceTree = ""; }; + D9CF57DA1BD86CA6001B24F9 /* City.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = City.h; sourceTree = ""; }; + D9CF57DB1BD86CA6001B24F9 /* City.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = City.m; sourceTree = ""; }; + D9CF57DC1BD86CA6001B24F9 /* Photo+CoreDataProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Photo+CoreDataProperties.h"; sourceTree = ""; }; + D9CF57DD1BD86CA6001B24F9 /* Photo+CoreDataProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Photo+CoreDataProperties.m"; sourceTree = ""; }; + D9CF57DE1BD86CA6001B24F9 /* Photo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Photo.h; sourceTree = ""; }; + D9CF57DF1BD86CA6001B24F9 /* Photo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Photo.m; sourceTree = ""; }; + D9CF57E41BD877E3001B24F9 /* PhotoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoCell.h; sourceTree = ""; }; + D9CF57E51BD877E3001B24F9 /* PhotoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoCell.m; sourceTree = ""; }; + D9E6A86A1BD43BCC0092BFA7 /* FoursquareAPIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FoursquareAPIManager.h; sourceTree = ""; }; + D9E6A86B1BD43BCC0092BFA7 /* FoursquareAPIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FoursquareAPIManager.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 84CF45231BCAD0EA00EAA3BF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0B17F5521BD83F9600EC7901 /* CoreLocation.framework in Frameworks */, + 84CF45681BCAD12100EAA3BF /* UIKit.framework in Frameworks */, + 84CF45661BCAD11A00EAA3BF /* CoreGraphics.framework in Frameworks */, + 84CF45641BCAD11300EAA3BF /* Foundation.framework in Frameworks */, + 84CF45621BCAD10D00EAA3BF /* QuartzCore.framework in Frameworks */, + 84CF45601BCAD10700EAA3BF /* Accelerate.framework in Frameworks */, + 44FA49C8E2DCD94AB1DEA855 /* libPods.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84CF453F1BCAD0EB00EAA3BF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84CF454A1BCAD0EB00EAA3BF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0B8208901BD43A3F00117BE1 /* Meetup */ = { + isa = PBXGroup; + children = ( + 0B8208911BD43A5B00117BE1 /* MeetupTableViewController.h */, + 0B8208921BD43A5B00117BE1 /* MeetupTableViewController.m */, + 0B8208941BD43CC500117BE1 /* MeetupTableViewCell.h */, + 0B8208951BD43CC500117BE1 /* MeetupTableViewCell.m */, + ); + name = Meetup; + sourceTree = ""; + }; + 847403A41BD8BA6C00A460D8 /* Candy */ = { + isa = PBXGroup; + children = ( + 847403A11BD8BA6800A460D8 /* CandyViewController.h */, + 847403A21BD8BA6800A460D8 /* CandyViewController.m */, + ); + name = Candy; + sourceTree = ""; + }; + 84CF451D1BCAD0EA00EAA3BF = { + isa = PBXGroup; + children = ( + 84CF45671BCAD12100EAA3BF /* UIKit.framework */, + 84CF45651BCAD11A00EAA3BF /* CoreGraphics.framework */, + 84CF45631BCAD11300EAA3BF /* Foundation.framework */, + 84CF45611BCAD10D00EAA3BF /* QuartzCore.framework */, + 84CF455F1BCAD10700EAA3BF /* Accelerate.framework */, + 84CF45281BCAD0EA00EAA3BF /* InControl */, + 84CF45451BCAD0EB00EAA3BF /* InControlTests */, + 84CF45501BCAD0EB00EAA3BF /* InControlUITests */, + 84CF45271BCAD0EA00EAA3BF /* Products */, + 84CF45691BCAD14300EAA3BF /* RNFrostedSidebar.h */, + 84CF456A1BCAD14300EAA3BF /* RNFrostedSidebar.m */, + BBBBE875D46502871F1B2251 /* Pods */, + B2BC0F9C4153A1759E333F8D /* Frameworks */, + ); + sourceTree = ""; + }; + 84CF45271BCAD0EA00EAA3BF /* Products */ = { + isa = PBXGroup; + children = ( + 84CF45261BCAD0EA00EAA3BF /* InControl.app */, + 84CF45421BCAD0EB00EAA3BF /* InControlTests.xctest */, + 84CF454D1BCAD0EB00EAA3BF /* InControlUITests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 84CF45281BCAD0EA00EAA3BF /* InControl */ = { + isa = PBXGroup; + children = ( + 84CF45761BCAD16400EAA3BF /* InfoPlist.strings */, + 84CF46671BCE2B4B00EAA3BF /* Visited */, + 84CF46631BCE29E100EAA3BF /* Games */, + 84CF45931BCAED1D00EAA3BF /* Images */, + 84CF452C1BCAD0EA00EAA3BF /* AppDelegate.h */, + 84CF452D1BCAD0EA00EAA3BF /* AppDelegate.m */, + D9682D5B1BCD4E1600647FD8 /* APIManager.h */, + D9682D5C1BCD4E1600647FD8 /* APIManager.m */, + 84E6D4D81BD8687000ECAE47 /* Insta */, + D9E6A86D1BD44C5E0092BFA7 /* Foursquare */, + 84CF45C11BCB4F0300EAA3BF /* NewTrip */, + 84CF45C81BCC519800EAA3BF /* Video */, + 84CF45BD1BCB4ECA00EAA3BF /* Food */, + 84CF45BE1BCB4ED900EAA3BF /* Image */, + 84CF45BF1BCB4EE700EAA3BF /* Welcome */, + 0B8208901BD43A3F00117BE1 /* Meetup */, + 84CF45C01BCB4EF700EAA3BF /* Hotel */, + 84CF45321BCAD0EA00EAA3BF /* Main.storyboard */, + 84CF45381BCAD0EB00EAA3BF /* Assets.xcassets */, + 84CF453A1BCAD0EB00EAA3BF /* LaunchScreen.storyboard */, + 84CF453D1BCAD0EB00EAA3BF /* Info.plist */, + 84CF45351BCAD0EA00EAA3BF /* InControl.xcdatamodeld */, + 84CF45291BCAD0EA00EAA3BF /* Supporting Files */, + ); + path = InControl; + sourceTree = ""; + }; + 84CF45291BCAD0EA00EAA3BF /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 84CF452A1BCAD0EA00EAA3BF /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 84CF45451BCAD0EB00EAA3BF /* InControlTests */ = { + isa = PBXGroup; + children = ( + 84CF45461BCAD0EB00EAA3BF /* InControlTests.m */, + 84CF45481BCAD0EB00EAA3BF /* Info.plist */, + ); + path = InControlTests; + sourceTree = ""; + }; + 84CF45501BCAD0EB00EAA3BF /* InControlUITests */ = { + isa = PBXGroup; + children = ( + 84CF45511BCAD0EB00EAA3BF /* InControlUITests.m */, + 84CF45531BCAD0EB00EAA3BF /* Info.plist */, + ); + path = InControlUITests; + sourceTree = ""; + }; + 84CF45931BCAED1D00EAA3BF /* Images */ = { + isa = PBXGroup; + children = ( + 84CF45771BCAD16400EAA3BF /* gear.png */, + 84CF46AA1BD0678700EAA3BF /* Tunnel.png */, + 84E6D4551BD08CCE00ECAE47 /* homeButton.png */, + 84CF46AB1BD0678700EAA3BF /* GameBack.png */, + 84CF46AC1BD0678700EAA3BF /* BirdUp.png */, + 84CF46AD1BD0678700EAA3BF /* BirdDown.png */, + 84CF456C1BCAD15A00EAA3BF /* burger.png */, + 84CF456D1BCAD15A00EAA3BF /* burger@2x.png */, + 84CF45981BCAF49900EAA3BF /* budget.png */, + 84CF46581BCDE80000EAA3BF /* meetup.png */, + 84CF456E1BCAD15A00EAA3BF /* Default-568h@2x.png */, + 84CF45A41BCAF71300EAA3BF /* video.png */, + 84CF45AC1BCAFA5A00EAA3BF /* insta.png */, + 84CF45A01BCAF64300EAA3BF /* hotel.png */, + 84CF45941BCAED3D00EAA3BF /* search.png */, + 84CF459A1BCAF50100EAA3BF /* food.png */, + 84CF456F1BCAD15A00EAA3BF /* Default.png */, + 84CF45A61BCAF7D300EAA3BF /* image.png */, + 84CF45701BCAD15A00EAA3BF /* Default@2x.png */, + 84CF45781BCAD16400EAA3BF /* gear@2x.png */, + 84CF45791BCAD16400EAA3BF /* globe.png */, + 84CF45831BCAD2AE00EAA3BF /* Profile_image.png */, + 84CF45841BCAD2AE00EAA3BF /* Profile_image@2x.png */, + 84CF45881BCAD2C900EAA3BF /* star.png */, + 84CF45891BCAD2C900EAA3BF /* star@2x.png */, + 84CF457A1BCAD16400EAA3BF /* globe@2x.png */, + 84CF45801BCAD2A600EAA3BF /* profile.png */, + 84CF45821BCAD2AE00EAA3BF /* profile@2x.png */, + ); + name = Images; + sourceTree = ""; + }; + 84CF45BD1BCB4ECA00EAA3BF /* Food */ = { + isa = PBXGroup; + children = ( + D9682D641BCD671000647FD8 /* FoodViewController.h */, + D9682D651BCD671000647FD8 /* FoodViewController.m */, + ); + name = Food; + sourceTree = ""; + }; + 84CF45BE1BCB4ED900EAA3BF /* Image */ = { + isa = PBXGroup; + children = ( + 84CF45BA1BCB0E9D00EAA3BF /* ImageTableViewController.h */, + 84CF45BB1BCB0E9D00EAA3BF /* ImageTableViewController.m */, + 0BAA7ABA1BD34A4D00CB7443 /* CustomTableViewCell.h */, + 0BAA7ABB1BD34A4D00CB7443 /* CustomTableViewCell.m */, + ); + name = Image; + sourceTree = ""; + }; + 84CF45BF1BCB4EE700EAA3BF /* Welcome */ = { + isa = PBXGroup; + children = ( + 84CF45B41BCB057600EAA3BF /* WelcomeViewController.h */, + 84CF45B51BCB057600EAA3BF /* WelcomeViewController.m */, + ); + name = Welcome; + sourceTree = ""; + }; + 84CF45C01BCB4EF700EAA3BF /* Hotel */ = { + isa = PBXGroup; + children = ( + D9682D611BCD665200647FD8 /* HotelViewController.h */, + D9682D621BCD665200647FD8 /* HotelViewController.m */, + ); + name = Hotel; + sourceTree = ""; + }; + 84CF45C11BCB4F0300EAA3BF /* NewTrip */ = { + isa = PBXGroup; + children = ( + 84CF452F1BCAD0EA00EAA3BF /* ViewController.h */, + 84CF45301BCAD0EA00EAA3BF /* ViewController.m */, + ); + name = NewTrip; + sourceTree = ""; + }; + 84CF45C81BCC519800EAA3BF /* Video */ = { + isa = PBXGroup; + children = ( + 84CF45C91BCC51C200EAA3BF /* VideoViewController.h */, + 84CF45CA1BCC51C200EAA3BF /* VideoViewController.m */, + 84CF45CC1BCD8F7200EAA3BF /* Youtube.h */, + 84CF45CD1BCD8F7200EAA3BF /* Youtube.m */, + ); + name = Video; + sourceTree = ""; + }; + 84CF46631BCE29E100EAA3BF /* Games */ = { + isa = PBXGroup; + children = ( + 84CF46601BCE29DB00EAA3BF /* GamesViewController.h */, + 84CF46611BCE29DB00EAA3BF /* GamesViewController.m */, + 847403A41BD8BA6C00A460D8 /* Candy */, + 84CF46B21BD067FC00EAA3BF /* FlappyBird */, + ); + name = Games; + sourceTree = ""; + }; + 84CF46671BCE2B4B00EAA3BF /* Visited */ = { + isa = PBXGroup; + children = ( + 84CF46641BCE2B4600EAA3BF /* VisitedViewController.h */, + 84CF46651BCE2B4600EAA3BF /* VisitedViewController.m */, + D9CF57D81BD86CA6001B24F9 /* City+CoreDataProperties.h */, + D9CF57D91BD86CA6001B24F9 /* City+CoreDataProperties.m */, + D9CF57DA1BD86CA6001B24F9 /* City.h */, + D9CF57DB1BD86CA6001B24F9 /* City.m */, + D9CF57DC1BD86CA6001B24F9 /* Photo+CoreDataProperties.h */, + D9CF57DD1BD86CA6001B24F9 /* Photo+CoreDataProperties.m */, + D9CF57DE1BD86CA6001B24F9 /* Photo.h */, + D9CF57DF1BD86CA6001B24F9 /* Photo.m */, + D9682E661BD1DD9C00647FD8 /* AddVisitedViewController.h */, + D9682E671BD1DD9C00647FD8 /* AddVisitedViewController.m */, + D9389C391BD1E173009A8A15 /* DetailVisitedViewController.h */, + D9389C3A1BD1E173009A8A15 /* DetailVisitedViewController.m */, + D9CF57E41BD877E3001B24F9 /* PhotoCell.h */, + D9CF57E51BD877E3001B24F9 /* PhotoCell.m */, + 84E6D4D21BD6F93200ECAE47 /* VisitedTableViewCell.h */, + 84E6D4D31BD6F93200ECAE47 /* VisitedTableViewCell.m */, + ); + name = Visited; + sourceTree = ""; + }; + 84CF46B21BD067FC00EAA3BF /* FlappyBird */ = { + isa = PBXGroup; + children = ( + 84CF46B31BD0681800EAA3BF /* FlappyViewController.h */, + 84CF46B41BD0681800EAA3BF /* FlappyViewController.m */, + 84CF46B61BD0683000EAA3BF /* FlappyGame.h */, + 84CF46B71BD0683000EAA3BF /* FlappyGame.m */, + ); + name = FlappyBird; + sourceTree = ""; + }; + 84E6D4D81BD8687000ECAE47 /* Insta */ = { + isa = PBXGroup; + children = ( + 84E6D4E41BD872D700ECAE47 /* InstaTableViewController.h */, + 84E6D4E51BD872D700ECAE47 /* InstaTableViewController.m */, + 84E6D4E21BD86D7400ECAE47 /* InstagramPostTableViewCell.xib */, + 84E6D4DF1BD86D0800ECAE47 /* InstagramPostTableViewCell.h */, + 84E6D4E01BD86D0800ECAE47 /* InstagramPostTableViewCell.m */, + 84E6D4DB1BD86CFB00ECAE47 /* InstagramPost.h */, + 84E6D4DC1BD86CFB00ECAE47 /* InstagramPost.m */, + ); + name = Insta; + sourceTree = ""; + }; + B2BC0F9C4153A1759E333F8D /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0B17F5511BD83F9600EC7901 /* CoreLocation.framework */, + CA12CD6286D3D05E336A1706 /* libPods.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + BBBBE875D46502871F1B2251 /* Pods */ = { + isa = PBXGroup; + children = ( + 4B5D5618892B20D168B80EB1 /* Pods.debug.xcconfig */, + CA3CA915C16CD3F8F7FFC788 /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + D9E6A86D1BD44C5E0092BFA7 /* Foursquare */ = { + isa = PBXGroup; + children = ( + D9E6A86A1BD43BCC0092BFA7 /* FoursquareAPIManager.h */, + D9E6A86B1BD43BCC0092BFA7 /* FoursquareAPIManager.m */, + D9682D5E1BCD501600647FD8 /* Venue.h */, + D9682D5F1BCD501700647FD8 /* Venue.m */, + ); + name = Foursquare; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 84CF45251BCAD0EA00EAA3BF /* InControl */ = { + isa = PBXNativeTarget; + buildConfigurationList = 84CF45561BCAD0EB00EAA3BF /* Build configuration list for PBXNativeTarget "InControl" */; + buildPhases = ( + 80E8B4ED873907B29B67D3E3 /* Check Pods Manifest.lock */, + 84CF45221BCAD0EA00EAA3BF /* Sources */, + 84CF45231BCAD0EA00EAA3BF /* Frameworks */, + 84CF45241BCAD0EA00EAA3BF /* Resources */, + 896E54D6877A100D870623DC /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = InControl; + productName = InControl; + productReference = 84CF45261BCAD0EA00EAA3BF /* InControl.app */; + productType = "com.apple.product-type.application"; + }; + 84CF45411BCAD0EB00EAA3BF /* InControlTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 84CF45591BCAD0EB00EAA3BF /* Build configuration list for PBXNativeTarget "InControlTests" */; + buildPhases = ( + 84CF453E1BCAD0EB00EAA3BF /* Sources */, + 84CF453F1BCAD0EB00EAA3BF /* Frameworks */, + 84CF45401BCAD0EB00EAA3BF /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 84CF45441BCAD0EB00EAA3BF /* PBXTargetDependency */, + ); + name = InControlTests; + productName = InControlTests; + productReference = 84CF45421BCAD0EB00EAA3BF /* InControlTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 84CF454C1BCAD0EB00EAA3BF /* InControlUITests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 84CF455C1BCAD0EB00EAA3BF /* Build configuration list for PBXNativeTarget "InControlUITests" */; + buildPhases = ( + 84CF45491BCAD0EB00EAA3BF /* Sources */, + 84CF454A1BCAD0EB00EAA3BF /* Frameworks */, + 84CF454B1BCAD0EB00EAA3BF /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 84CF454F1BCAD0EB00EAA3BF /* PBXTargetDependency */, + ); + name = InControlUITests; + productName = InControlUITests; + productReference = 84CF454D1BCAD0EB00EAA3BF /* InControlUITests.xctest */; + productType = "com.apple.product-type.bundle.ui-testing"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 84CF451E1BCAD0EA00EAA3BF /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0700; + ORGANIZATIONNAME = "Diana Elezaj"; + TargetAttributes = { + 84CF45251BCAD0EA00EAA3BF = { + CreatedOnToolsVersion = 7.0; + DevelopmentTeam = 85VFEKU7M5; + }; + 84CF45411BCAD0EB00EAA3BF = { + CreatedOnToolsVersion = 7.0; + TestTargetID = 84CF45251BCAD0EA00EAA3BF; + }; + 84CF454C1BCAD0EB00EAA3BF = { + CreatedOnToolsVersion = 7.0; + TestTargetID = 84CF45251BCAD0EA00EAA3BF; + }; + }; + }; + buildConfigurationList = 84CF45211BCAD0EA00EAA3BF /* Build configuration list for PBXProject "InControl" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 84CF451D1BCAD0EA00EAA3BF; + productRefGroup = 84CF45271BCAD0EA00EAA3BF /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 84CF45251BCAD0EA00EAA3BF /* InControl */, + 84CF45411BCAD0EB00EAA3BF /* InControlTests */, + 84CF454C1BCAD0EB00EAA3BF /* InControlUITests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 84CF45241BCAD0EA00EAA3BF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 84CF45751BCAD15A00EAA3BF /* Default@2x.png in Resources */, + 84CF458B1BCAD2C900EAA3BF /* star@2x.png in Resources */, + 84CF457F1BCAD16400EAA3BF /* globe@2x.png in Resources */, + 84CF45711BCAD15A00EAA3BF /* burger.png in Resources */, + 84CF45721BCAD15A00EAA3BF /* burger@2x.png in Resources */, + 84CF453C1BCAD0EB00EAA3BF /* LaunchScreen.storyboard in Resources */, + 84E6D4561BD08CCE00ECAE47 /* homeButton.png in Resources */, + 84CF46591BCDE80000EAA3BF /* meetup.png in Resources */, + 84CF46AE1BD0678700EAA3BF /* Tunnel.png in Resources */, + 84CF457D1BCAD16400EAA3BF /* gear@2x.png in Resources */, + 84CF45391BCAD0EB00EAA3BF /* Assets.xcassets in Resources */, + 84E6D4E31BD86D7400ECAE47 /* InstagramPostTableViewCell.xib in Resources */, + 84CF46AF1BD0678700EAA3BF /* GameBack.png in Resources */, + 84CF46B01BD0678700EAA3BF /* BirdUp.png in Resources */, + 84CF45861BCAD2AE00EAA3BF /* Profile_image.png in Resources */, + 84CF45741BCAD15A00EAA3BF /* Default.png in Resources */, + 84CF45A11BCAF64300EAA3BF /* hotel.png in Resources */, + 84CF45991BCAF49900EAA3BF /* budget.png in Resources */, + 84CF457C1BCAD16400EAA3BF /* gear.png in Resources */, + 84CF45AD1BCAFA5A00EAA3BF /* insta.png in Resources */, + 84CF45341BCAD0EA00EAA3BF /* Main.storyboard in Resources */, + 84CF46B11BD0678700EAA3BF /* BirdDown.png in Resources */, + 84CF45A71BCAF7D300EAA3BF /* image.png in Resources */, + 84CF459B1BCAF50100EAA3BF /* food.png in Resources */, + 84CF458A1BCAD2C900EAA3BF /* star.png in Resources */, + 84CF457E1BCAD16400EAA3BF /* globe.png in Resources */, + 84CF457B1BCAD16400EAA3BF /* InfoPlist.strings in Resources */, + 84CF45951BCAED3D00EAA3BF /* search.png in Resources */, + 84CF45A51BCAF71300EAA3BF /* video.png in Resources */, + 84CF45731BCAD15A00EAA3BF /* Default-568h@2x.png in Resources */, + 84CF45811BCAD2A600EAA3BF /* profile.png in Resources */, + 84CF45851BCAD2AE00EAA3BF /* profile@2x.png in Resources */, + 84CF45871BCAD2AE00EAA3BF /* Profile_image@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84CF45401BCAD0EB00EAA3BF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84CF454B1BCAD0EB00EAA3BF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 80E8B4ED873907B29B67D3E3 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 896E54D6877A100D870623DC /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 84CF45221BCAD0EA00EAA3BF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8474039E1BD8A18F00A460D8 /* InstagramPost.m in Sources */, + 8474039D1BD8A18700A460D8 /* InstaTableViewController.m in Sources */, + D9CF57E31BD86CA6001B24F9 /* Photo.m in Sources */, + D9CF57E11BD86CA6001B24F9 /* City.m in Sources */, + 84CF45CB1BCC51C200EAA3BF /* VideoViewController.m in Sources */, + D9682E681BD1DD9C00647FD8 /* AddVisitedViewController.m in Sources */, + 84CF45311BCAD0EA00EAA3BF /* ViewController.m in Sources */, + D9682D631BCD665200647FD8 /* HotelViewController.m in Sources */, + 84CF456B1BCAD14300EAA3BF /* RNFrostedSidebar.m in Sources */, + 84CF45BC1BCB0E9D00EAA3BF /* ImageTableViewController.m in Sources */, + 84CF452E1BCAD0EA00EAA3BF /* AppDelegate.m in Sources */, + D9389C3B1BD1E173009A8A15 /* DetailVisitedViewController.m in Sources */, + D9E6A86C1BD43BCC0092BFA7 /* FoursquareAPIManager.m in Sources */, + 84CF46661BCE2B4600EAA3BF /* VisitedViewController.m in Sources */, + 84CF46B81BD0683000EAA3BF /* FlappyGame.m in Sources */, + 84CF45CE1BCD8F7200EAA3BF /* Youtube.m in Sources */, + D9682D661BCD671000647FD8 /* FoodViewController.m in Sources */, + 84E6D4E11BD86D0800ECAE47 /* InstagramPostTableViewCell.m in Sources */, + 84CF45371BCAD0EB00EAA3BF /* InControl.xcdatamodeld in Sources */, + 84CF45B61BCB057600EAA3BF /* WelcomeViewController.m in Sources */, + D9CF57E01BD86CA6001B24F9 /* City+CoreDataProperties.m in Sources */, + 84CF46621BCE29DB00EAA3BF /* GamesViewController.m in Sources */, + 84CF46B51BD0681800EAA3BF /* FlappyViewController.m in Sources */, + 0B8208931BD43A5B00117BE1 /* MeetupTableViewController.m in Sources */, + 0B8208961BD43CC500117BE1 /* MeetupTableViewCell.m in Sources */, + D9682D601BCD501700647FD8 /* Venue.m in Sources */, + 84CF452B1BCAD0EA00EAA3BF /* main.m in Sources */, + D9CF57E61BD877E3001B24F9 /* PhotoCell.m in Sources */, + 0BAA7ABC1BD34A4D00CB7443 /* CustomTableViewCell.m in Sources */, + 84E6D4D41BD6F93200ECAE47 /* VisitedTableViewCell.m in Sources */, + 847403A31BD8BA6800A460D8 /* CandyViewController.m in Sources */, + D9682D5D1BCD4E1600647FD8 /* APIManager.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84CF453E1BCAD0EB00EAA3BF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 84CF45471BCAD0EB00EAA3BF /* InControlTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 84CF45491BCAD0EB00EAA3BF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 84CF45521BCAD0EB00EAA3BF /* InControlUITests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 84CF45441BCAD0EB00EAA3BF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84CF45251BCAD0EA00EAA3BF /* InControl */; + targetProxy = 84CF45431BCAD0EB00EAA3BF /* PBXContainerItemProxy */; + }; + 84CF454F1BCAD0EB00EAA3BF /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 84CF45251BCAD0EA00EAA3BF /* InControl */; + targetProxy = 84CF454E1BCAD0EB00EAA3BF /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 84CF45321BCAD0EA00EAA3BF /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 84CF45331BCAD0EA00EAA3BF /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 84CF453A1BCAD0EB00EAA3BF /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 84CF453B1BCAD0EB00EAA3BF /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 84CF45541BCAD0EB00EAA3BF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 84CF45551BCAD0EB00EAA3BF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 84CF45571BCAD0EB00EAA3BF /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4B5D5618892B20D168B80EB1 /* Pods.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + INFOPLIST_FILE = InControl/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = nyc.c4q.xiulanshi.InControl; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + }; + name = Debug; + }; + 84CF45581BCAD0EB00EAA3BF /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CA3CA915C16CD3F8F7FFC788 /* Pods.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + INFOPLIST_FILE = InControl/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = nyc.c4q.xiulanshi.InControl; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + }; + name = Release; + }; + 84CF455A1BCAD0EB00EAA3BF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = InControlTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = nyc.c4q.dianaelezaj.InControlTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/InControl.app/InControl"; + }; + name = Debug; + }; + 84CF455B1BCAD0EB00EAA3BF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = InControlTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = nyc.c4q.dianaelezaj.InControlTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/InControl.app/InControl"; + }; + name = Release; + }; + 84CF455D1BCAD0EB00EAA3BF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = InControlUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = nyc.c4q.dianaelezaj.InControlUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_TARGET_NAME = InControl; + USES_XCTRUNNER = YES; + }; + name = Debug; + }; + 84CF455E1BCAD0EB00EAA3BF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = InControlUITests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = nyc.c4q.dianaelezaj.InControlUITests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_TARGET_NAME = InControl; + USES_XCTRUNNER = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 84CF45211BCAD0EA00EAA3BF /* Build configuration list for PBXProject "InControl" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84CF45541BCAD0EB00EAA3BF /* Debug */, + 84CF45551BCAD0EB00EAA3BF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 84CF45561BCAD0EB00EAA3BF /* Build configuration list for PBXNativeTarget "InControl" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84CF45571BCAD0EB00EAA3BF /* Debug */, + 84CF45581BCAD0EB00EAA3BF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 84CF45591BCAD0EB00EAA3BF /* Build configuration list for PBXNativeTarget "InControlTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84CF455A1BCAD0EB00EAA3BF /* Debug */, + 84CF455B1BCAD0EB00EAA3BF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 84CF455C1BCAD0EB00EAA3BF /* Build configuration list for PBXNativeTarget "InControlUITests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 84CF455D1BCAD0EB00EAA3BF /* Debug */, + 84CF455E1BCAD0EB00EAA3BF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + 84CF45351BCAD0EA00EAA3BF /* InControl.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + 84CF45361BCAD0EB00EAA3BF /* InControl.xcdatamodel */, + ); + currentVersion = 84CF45361BCAD0EB00EAA3BF /* InControl.xcdatamodel */; + path = InControl.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = 84CF451E1BCAD0EA00EAA3BF /* Project object */; +} diff --git a/InControl/InControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/InControl/InControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..54f0910 --- /dev/null +++ b/InControl/InControl.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/InControl/InControl.xcworkspace/contents.xcworkspacedata b/InControl/InControl.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..916934f --- /dev/null +++ b/InControl/InControl.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/InControl/InControl/.DS_Store b/InControl/InControl/.DS_Store new file mode 100644 index 0000000..9ed5a17 Binary files /dev/null and b/InControl/InControl/.DS_Store differ diff --git a/InControl/InControl/APIManager.h b/InControl/InControl/APIManager.h new file mode 100644 index 0000000..acee444 --- /dev/null +++ b/InControl/InControl/APIManager.h @@ -0,0 +1,15 @@ +// +// APIManager.h +// InControl +// +// Created by Xiulan Shi on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface APIManager : NSObject + ++ (void) GETRequestWithURL:(NSURL *) URL completionHandler:(void(^)(NSData *, NSURLResponse *, NSError *)) completionHandler; + +@end diff --git a/InControl/InControl/APIManager.m b/InControl/InControl/APIManager.m new file mode 100644 index 0000000..e0c28a0 --- /dev/null +++ b/InControl/InControl/APIManager.m @@ -0,0 +1,26 @@ +// +// APIManager.m +// InControl +// +// Created by Xiulan Shi on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "APIManager.h" + +@implementation APIManager + ++ (void) GETRequestWithURL:(NSURL *) URL completionHandler:(void(^)(NSData *, NSURLResponse *, NSError *)) completionHandler { + + NSURLSession *session = [NSURLSession sharedSession]; + NSURLSessionDataTask *dataTask = [session dataTaskWithURL:URL completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + completionHandler(data, response, error); + }); + }]; + + [dataTask resume]; + +} + +@end diff --git a/InControl/InControl/AddVisitedViewController.h b/InControl/InControl/AddVisitedViewController.h new file mode 100644 index 0000000..a9fe29a --- /dev/null +++ b/InControl/InControl/AddVisitedViewController.h @@ -0,0 +1,15 @@ +// +// AddVisitedViewController.h +// InControl +// +// Created by Xiulan Shi on 10/16/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import "City.h" + +@interface AddVisitedViewController : UIViewController + +@property (nonatomic) City *city; +@end diff --git a/InControl/InControl/AddVisitedViewController.m b/InControl/InControl/AddVisitedViewController.m new file mode 100644 index 0000000..27bc5fd --- /dev/null +++ b/InControl/InControl/AddVisitedViewController.m @@ -0,0 +1,186 @@ +// +// AddVisitedViewController.m +// InControl +// +// Created by Xiulan Shi on 10/16/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import "AppDelegate.h" +#import "City.h" +#import "AddVisitedViewController.h" +#import "Photo.h" +#import "Photo+CoreDataProperties.h" + +@interface AddVisitedViewController () +@property (weak, nonatomic) IBOutlet UITextField *cityTextField; +@property (weak, nonatomic) IBOutlet UITextField *impressionTextField; +@property (weak, nonatomic) IBOutlet UIImageView *imageView; +@property (weak, nonatomic) IBOutlet UIButton *rate1Button; +@property (weak, nonatomic) IBOutlet UIButton *rate2Button; +@property (weak, nonatomic) IBOutlet UIButton *rate3Button; +@property (weak, nonatomic) IBOutlet UIButton *rate4Button; +@property (weak, nonatomic) IBOutlet UIButton *rate5Button; +@property (nonatomic) NSNumber *rateSelected; +@property (nonatomic) UIImage *whiteStarBackground; +@property (nonatomic) UIImage *yellowStarBackground; + + +@property (nonatomic) UIImagePickerController *picker; +@property (nonatomic) UIImagePickerController *picker2; +@property (nonatomic) UIImage *image; + +@property (nonatomic) NSMutableArray *photos; + +@property (nonatomic) Photo *photo; + +@end + +@implementation AddVisitedViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + if (!self.photos) { + self.photos = [NSMutableArray new]; + } + + self.whiteStarBackground = [UIImage imageNamed:@"WhiteStar"]; + self.yellowStarBackground = [UIImage imageNamed:@"YellowStar"]; + self.rateSelected = @1; + + [self setupNavigationBar]; + + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + + self.city = [NSEntityDescription insertNewObjectForEntityForName:@"City" inManagedObjectContext:delegate.managedObjectContext]; + +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:YES ]; + self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cc"]]; + +} + +- (void)setupNavigationBar { + + self.navigationItem.title = @"Create New Visited City"; + + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)]; + + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(save)]; +} + +- (void)cancel { + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + [delegate.managedObjectContext deleteObject:self.city]; + [self dismissViewControllerAnimated:YES completion:nil]; +} + +- (void)save { + self.city.name = self.cityTextField.text; + // [self.cityTextField resignFirstResponder]; + + NSNumberFormatter *f = [[NSNumberFormatter alloc] init]; + f.numberStyle = NSNumberFormatterDecimalStyle; + self.city.rate = self.rateSelected; + + self.city.impression = self.impressionTextField.text; +// [self.impressionTextField resignFirstResponder]; + + self.city.photos = [NSOrderedSet orderedSetWithArray:self.photos]; + + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + [delegate.managedObjectContext save:nil]; + + [self dismissViewControllerAnimated:YES completion:nil]; + +} + +- (IBAction)chooseExistingButtonTapped:(id)sender { + + self.picker2 = [[UIImagePickerController alloc] init]; + self.picker2.delegate = self; + [self.picker2 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; + [self presentViewController:self.picker2 animated:YES completion:NULL]; + [self.view endEditing:YES]; + +} + +- (IBAction)takePhotoButtonTapped:(id)sender { + + self.picker = [[UIImagePickerController alloc] init]; + self.picker.delegate = self; + [self.picker setSourceType:UIImagePickerControllerSourceTypeCamera]; + [self presentViewController:self.picker animated:YES completion:NULL]; + [self.view endEditing:YES]; +} + +- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ + + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + Photo *newPhoto = [NSEntityDescription insertNewObjectForEntityForName:@"Photo" inManagedObjectContext:delegate.managedObjectContext]; + + + self.image = [info objectForKey:UIImagePickerControllerOriginalImage]; + [self.imageView setImage:self.image]; + newPhoto.imageData = UIImagePNGRepresentation (self.image); + [self.photos addObject:newPhoto]; + + [self dismissViewControllerAnimated:YES completion:NULL]; +} + +- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { + [self dismissViewControllerAnimated:YES completion:NULL]; +} + + + +- (IBAction)rate1Selected:(UIButton *)sender { + self.rateSelected = @1; + [self.rate1Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate2Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; + [self.rate3Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; + [self.rate4Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; + [self.rate5Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; +} +- (IBAction)rate2Selected:(UIButton *)sender { + self.rateSelected = @2; + [self.rate1Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate2Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate3Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; + [self.rate4Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; + [self.rate5Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; +} +- (IBAction)rate3Selected:(UIButton *)sender { + self.rateSelected = @3; + [self.rate1Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate2Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate3Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate4Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; + [self.rate5Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; +} +- (IBAction)rate4Selected:(UIButton *)sender { + self.rateSelected = @4; + [self.rate1Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate2Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate3Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate4Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate5Button setBackgroundImage:self.whiteStarBackground forState:UIControlStateNormal]; +} +- (IBAction)rate5Selected:(UIButton *)sender { + self.rateSelected = @5; + [self.rate1Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate2Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate3Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate4Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; + [self.rate5Button setBackgroundImage:self.yellowStarBackground forState:UIControlStateNormal]; +} + + + + + +@end diff --git a/InControl/InControl/AppDelegate.h b/InControl/InControl/AppDelegate.h new file mode 100644 index 0000000..da82f93 --- /dev/null +++ b/InControl/InControl/AppDelegate.h @@ -0,0 +1,25 @@ +// +// AppDelegate.h +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; +@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; +@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; + +- (void)saveContext; +- (NSURL *)applicationDocumentsDirectory; + + +@end + diff --git a/InControl/InControl/AppDelegate.m b/InControl/InControl/AppDelegate.m new file mode 100644 index 0000000..4a68e6e --- /dev/null +++ b/InControl/InControl/AppDelegate.m @@ -0,0 +1,134 @@ +// +// AppDelegate.m +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + // Saves changes in the application's managed object context before the application terminates. + [self saveContext]; +} + +#pragma mark - Core Data stack + +@synthesize managedObjectContext = _managedObjectContext; +@synthesize managedObjectModel = _managedObjectModel; +@synthesize persistentStoreCoordinator = _persistentStoreCoordinator; + +- (NSURL *)applicationDocumentsDirectory { + // The directory the application uses to store the Core Data store file. This code uses a directory named "nyc.c4q.dianaelezaj.InControl" in the application's documents directory. + return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; +} + +- (NSManagedObjectModel *)managedObjectModel { + // 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. + if (_managedObjectModel != nil) { + return _managedObjectModel; + } + NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"InControl" withExtension:@"momd"]; + _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; + return _managedObjectModel; +} + +- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { + // The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. + if (_persistentStoreCoordinator != nil) { + return _persistentStoreCoordinator; + } + + // Create the coordinator and store + + _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; + NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"InControl.sqlite"]; + NSError *error = nil; + NSString *failureReason = @"There was an error creating or loading the application's saved data."; + if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { + // Report any error we got. + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + dict[NSLocalizedDescriptionKey] = @"Failed to initialize the application's saved data"; + dict[NSLocalizedFailureReasonErrorKey] = failureReason; + dict[NSUnderlyingErrorKey] = error; + error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict]; + // Replace this with code to handle the error appropriately. + // 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. + + NSLog(@"Attempting to recover from error by deleting data: %@, %@", error, [error userInfo]); + [[NSFileManager defaultManager] removeItemAtURL:storeURL error:NULL]; + + error = nil; + if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { + NSLog(@"Unresolved error %@, %@", error, [error userInfo]); + abort(); + } + } + + return _persistentStoreCoordinator; +} + + +- (NSManagedObjectContext *)managedObjectContext { + // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) + if (_managedObjectContext != nil) { + return _managedObjectContext; + } + + NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; + if (!coordinator) { + return nil; + } + _managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; + [_managedObjectContext setPersistentStoreCoordinator:coordinator]; + return _managedObjectContext; +} + +#pragma mark - Core Data Saving support + +- (void)saveContext { + NSManagedObjectContext *managedObjectContext = self.managedObjectContext; + if (managedObjectContext != nil) { + NSError *error = nil; + if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { + // Replace this implementation with code to handle the error appropriately. + // 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. + NSLog(@"Unresolved error %@, %@", error, [error userInfo]); + abort(); + } + } +} + +@end diff --git a/InControl/InControl/Assets.xcassets/66.imageset/66.jpg b/InControl/InControl/Assets.xcassets/66.imageset/66.jpg new file mode 100644 index 0000000..531dce3 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/66.imageset/66.jpg differ diff --git a/InControl/InControl/Assets.xcassets/66.imageset/Contents.json b/InControl/InControl/Assets.xcassets/66.imageset/Contents.json new file mode 100644 index 0000000..f4395a7 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/66.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "66.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/661.imageset/661.jpg b/InControl/InControl/Assets.xcassets/661.imageset/661.jpg new file mode 100644 index 0000000..d62e845 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/661.imageset/661.jpg differ diff --git a/InControl/InControl/Assets.xcassets/661.imageset/Contents.json b/InControl/InControl/Assets.xcassets/661.imageset/Contents.json new file mode 100644 index 0000000..a99736b --- /dev/null +++ b/InControl/InControl/Assets.xcassets/661.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "661.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/662.imageset/662.jpg b/InControl/InControl/Assets.xcassets/662.imageset/662.jpg new file mode 100644 index 0000000..7b59ba1 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/662.imageset/662.jpg differ diff --git a/InControl/InControl/Assets.xcassets/662.imageset/Contents.json b/InControl/InControl/Assets.xcassets/662.imageset/Contents.json new file mode 100644 index 0000000..460b00d --- /dev/null +++ b/InControl/InControl/Assets.xcassets/662.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "662.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/AppIcon.appiconset/Contents.json b/InControl/InControl/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/InControl/InControl/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/BlueCandy.imageset/BlueCandy.png b/InControl/InControl/Assets.xcassets/BlueCandy.imageset/BlueCandy.png new file mode 100644 index 0000000..585e34a Binary files /dev/null and b/InControl/InControl/Assets.xcassets/BlueCandy.imageset/BlueCandy.png differ diff --git a/InControl/InControl/Assets.xcassets/BlueCandy.imageset/Contents.json b/InControl/InControl/Assets.xcassets/BlueCandy.imageset/Contents.json new file mode 100644 index 0000000..d66997b --- /dev/null +++ b/InControl/InControl/Assets.xcassets/BlueCandy.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "BlueCandy.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/Contents.json b/InControl/InControl/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/GameBackGround.imageset/Contents.json b/InControl/InControl/Assets.xcassets/GameBackGround.imageset/Contents.json new file mode 100644 index 0000000..1f2e965 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/GameBackGround.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "GameBackGround.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/GameBackGround.imageset/GameBackGround.png b/InControl/InControl/Assets.xcassets/GameBackGround.imageset/GameBackGround.png new file mode 100644 index 0000000..5ad2bad Binary files /dev/null and b/InControl/InControl/Assets.xcassets/GameBackGround.imageset/GameBackGround.png differ diff --git a/InControl/InControl/Assets.xcassets/GreenCandy.imageset/Contents.json b/InControl/InControl/Assets.xcassets/GreenCandy.imageset/Contents.json new file mode 100644 index 0000000..8786011 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/GreenCandy.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "GreenCandy.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/GreenCandy.imageset/GreenCandy.png b/InControl/InControl/Assets.xcassets/GreenCandy.imageset/GreenCandy.png new file mode 100644 index 0000000..eab393c Binary files /dev/null and b/InControl/InControl/Assets.xcassets/GreenCandy.imageset/GreenCandy.png differ diff --git a/InControl/InControl/Assets.xcassets/MainMenu.imageset/Contents.json b/InControl/InControl/Assets.xcassets/MainMenu.imageset/Contents.json new file mode 100644 index 0000000..1c3ed6d --- /dev/null +++ b/InControl/InControl/Assets.xcassets/MainMenu.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "MainMenu.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/MainMenu.imageset/MainMenu.png b/InControl/InControl/Assets.xcassets/MainMenu.imageset/MainMenu.png new file mode 100644 index 0000000..f905dfb Binary files /dev/null and b/InControl/InControl/Assets.xcassets/MainMenu.imageset/MainMenu.png differ diff --git a/InControl/InControl/Assets.xcassets/OkGames.imageset/Contents.json b/InControl/InControl/Assets.xcassets/OkGames.imageset/Contents.json new file mode 100644 index 0000000..e1e8a38 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/OkGames.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "OkGames.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/OkGames.imageset/OkGames.png b/InControl/InControl/Assets.xcassets/OkGames.imageset/OkGames.png new file mode 100644 index 0000000..5c9efad Binary files /dev/null and b/InControl/InControl/Assets.xcassets/OkGames.imageset/OkGames.png differ diff --git a/InControl/InControl/Assets.xcassets/OkMyJourney.imageset/Contents.json b/InControl/InControl/Assets.xcassets/OkMyJourney.imageset/Contents.json new file mode 100644 index 0000000..44ced50 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/OkMyJourney.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "OkMyJourney.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/OkMyJourney.imageset/OkMyJourney.png b/InControl/InControl/Assets.xcassets/OkMyJourney.imageset/OkMyJourney.png new file mode 100644 index 0000000..4277ee8 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/OkMyJourney.imageset/OkMyJourney.png differ diff --git a/InControl/InControl/Assets.xcassets/OkNewTrip.imageset/Contents.json b/InControl/InControl/Assets.xcassets/OkNewTrip.imageset/Contents.json new file mode 100644 index 0000000..0032c1d --- /dev/null +++ b/InControl/InControl/Assets.xcassets/OkNewTrip.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "OkNewTrip.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/OkNewTrip.imageset/OkNewTrip.png b/InControl/InControl/Assets.xcassets/OkNewTrip.imageset/OkNewTrip.png new file mode 100644 index 0000000..08d0e59 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/OkNewTrip.imageset/OkNewTrip.png differ diff --git a/InControl/InControl/Assets.xcassets/OrangeCandy.imageset/Contents.json b/InControl/InControl/Assets.xcassets/OrangeCandy.imageset/Contents.json new file mode 100644 index 0000000..8fa2b74 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/OrangeCandy.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "OrangeCandy.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/OrangeCandy.imageset/OrangeCandy.png b/InControl/InControl/Assets.xcassets/OrangeCandy.imageset/OrangeCandy.png new file mode 100644 index 0000000..8d98617 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/OrangeCandy.imageset/OrangeCandy.png differ diff --git a/InControl/InControl/Assets.xcassets/PinkCandy.imageset/Contents.json b/InControl/InControl/Assets.xcassets/PinkCandy.imageset/Contents.json new file mode 100644 index 0000000..d9e32c9 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/PinkCandy.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "PinkCandy.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/PinkCandy.imageset/PinkCandy.png b/InControl/InControl/Assets.xcassets/PinkCandy.imageset/PinkCandy.png new file mode 100644 index 0000000..b5a57cb Binary files /dev/null and b/InControl/InControl/Assets.xcassets/PinkCandy.imageset/PinkCandy.png differ diff --git a/InControl/InControl/Assets.xcassets/SelectedCandy.imageset/Contents.json b/InControl/InControl/Assets.xcassets/SelectedCandy.imageset/Contents.json new file mode 100644 index 0000000..73a2205 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/SelectedCandy.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "SelectedCandy.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/SelectedCandy.imageset/SelectedCandy.png b/InControl/InControl/Assets.xcassets/SelectedCandy.imageset/SelectedCandy.png new file mode 100644 index 0000000..cace2cf Binary files /dev/null and b/InControl/InControl/Assets.xcassets/SelectedCandy.imageset/SelectedCandy.png differ diff --git a/InControl/InControl/Assets.xcassets/WhiteStar.imageset/Contents.json b/InControl/InControl/Assets.xcassets/WhiteStar.imageset/Contents.json new file mode 100644 index 0000000..08c75c0 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/WhiteStar.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "WhiteStar.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/WhiteStar.imageset/WhiteStar.png b/InControl/InControl/Assets.xcassets/WhiteStar.imageset/WhiteStar.png new file mode 100644 index 0000000..98e0cd6 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/WhiteStar.imageset/WhiteStar.png differ diff --git a/InControl/InControl/Assets.xcassets/YellowStar.imageset/Contents.json b/InControl/InControl/Assets.xcassets/YellowStar.imageset/Contents.json new file mode 100644 index 0000000..506052f --- /dev/null +++ b/InControl/InControl/Assets.xcassets/YellowStar.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "YellowStar.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/YellowStar.imageset/YellowStar.png b/InControl/InControl/Assets.xcassets/YellowStar.imageset/YellowStar.png new file mode 100644 index 0000000..4e1bc8f Binary files /dev/null and b/InControl/InControl/Assets.xcassets/YellowStar.imageset/YellowStar.png differ diff --git a/InControl/InControl/Assets.xcassets/back.imageset/Contents.json b/InControl/InControl/Assets.xcassets/back.imageset/Contents.json new file mode 100644 index 0000000..ea7ca34 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/back.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "back.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/back.imageset/back.jpg b/InControl/InControl/Assets.xcassets/back.imageset/back.jpg new file mode 100644 index 0000000..ba998f3 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/back.imageset/back.jpg differ diff --git a/InControl/InControl/Assets.xcassets/backButton.imageset/Contents.json b/InControl/InControl/Assets.xcassets/backButton.imageset/Contents.json new file mode 100644 index 0000000..b7fb066 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/backButton.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "backButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/backButton.imageset/backButton.png b/InControl/InControl/Assets.xcassets/backButton.imageset/backButton.png new file mode 100644 index 0000000..4eb39b2 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/backButton.imageset/backButton.png differ diff --git a/InControl/InControl/Assets.xcassets/backButtonSmall.imageset/Contents.json b/InControl/InControl/Assets.xcassets/backButtonSmall.imageset/Contents.json new file mode 100644 index 0000000..517c3b8 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/backButtonSmall.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "backButtonSmall.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/backButtonSmall.imageset/backButtonSmall.png b/InControl/InControl/Assets.xcassets/backButtonSmall.imageset/backButtonSmall.png new file mode 100644 index 0000000..efaccc3 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/backButtonSmall.imageset/backButtonSmall.png differ diff --git a/InControl/InControl/Assets.xcassets/candyCrushLogo.imageset/Contents.json b/InControl/InControl/Assets.xcassets/candyCrushLogo.imageset/Contents.json new file mode 100644 index 0000000..4b4809e --- /dev/null +++ b/InControl/InControl/Assets.xcassets/candyCrushLogo.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "candyCrushLogo.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/candyCrushLogo.imageset/candyCrushLogo.png b/InControl/InControl/Assets.xcassets/candyCrushLogo.imageset/candyCrushLogo.png new file mode 100644 index 0000000..1773880 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/candyCrushLogo.imageset/candyCrushLogo.png differ diff --git a/InControl/InControl/Assets.xcassets/cc.imageset/Contents.json b/InControl/InControl/Assets.xcassets/cc.imageset/Contents.json new file mode 100644 index 0000000..aad392b --- /dev/null +++ b/InControl/InControl/Assets.xcassets/cc.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "cc.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/cc.imageset/cc.jpg b/InControl/InControl/Assets.xcassets/cc.imageset/cc.jpg new file mode 100644 index 0000000..e2824f8 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/cc.imageset/cc.jpg differ diff --git a/InControl/InControl/Assets.xcassets/choosePhoto.imageset/Contents.json b/InControl/InControl/Assets.xcassets/choosePhoto.imageset/Contents.json new file mode 100644 index 0000000..442c29f --- /dev/null +++ b/InControl/InControl/Assets.xcassets/choosePhoto.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "choosePhoto.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/choosePhoto.imageset/choosePhoto.png b/InControl/InControl/Assets.xcassets/choosePhoto.imageset/choosePhoto.png new file mode 100644 index 0000000..132d601 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/choosePhoto.imageset/choosePhoto.png differ diff --git a/InControl/InControl/Assets.xcassets/common_background.imageset/Contents.json b/InControl/InControl/Assets.xcassets/common_background.imageset/Contents.json new file mode 100644 index 0000000..c1ac39e --- /dev/null +++ b/InControl/InControl/Assets.xcassets/common_background.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "common_background.pdf", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/common_background.imageset/common_background.pdf b/InControl/InControl/Assets.xcassets/common_background.imageset/common_background.pdf new file mode 100644 index 0000000..36207e3 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/common_background.imageset/common_background.pdf differ diff --git a/InControl/InControl/Assets.xcassets/emptyImage.imageset/Contents.json b/InControl/InControl/Assets.xcassets/emptyImage.imageset/Contents.json new file mode 100644 index 0000000..8daaa36 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/emptyImage.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "emptyImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/emptyImage.imageset/emptyImage.png b/InControl/InControl/Assets.xcassets/emptyImage.imageset/emptyImage.png new file mode 100644 index 0000000..3417962 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/emptyImage.imageset/emptyImage.png differ diff --git a/InControl/InControl/Assets.xcassets/flappyBack.imageset/Contents.json b/InControl/InControl/Assets.xcassets/flappyBack.imageset/Contents.json new file mode 100644 index 0000000..e3a8d9f --- /dev/null +++ b/InControl/InControl/Assets.xcassets/flappyBack.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "flappyBack.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/flappyBack.imageset/flappyBack.png b/InControl/InControl/Assets.xcassets/flappyBack.imageset/flappyBack.png new file mode 100644 index 0000000..4be292a Binary files /dev/null and b/InControl/InControl/Assets.xcassets/flappyBack.imageset/flappyBack.png differ diff --git a/InControl/InControl/Assets.xcassets/flappyGameOver.imageset/Contents.json b/InControl/InControl/Assets.xcassets/flappyGameOver.imageset/Contents.json new file mode 100644 index 0000000..fe26017 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/flappyGameOver.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "flappyGameOver.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/flappyGameOver.imageset/flappyGameOver.png b/InControl/InControl/Assets.xcassets/flappyGameOver.imageset/flappyGameOver.png new file mode 100644 index 0000000..f1e85d9 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/flappyGameOver.imageset/flappyGameOver.png differ diff --git a/InControl/InControl/Assets.xcassets/flappyGetReady.imageset/Contents.json b/InControl/InControl/Assets.xcassets/flappyGetReady.imageset/Contents.json new file mode 100644 index 0000000..bfc14bc --- /dev/null +++ b/InControl/InControl/Assets.xcassets/flappyGetReady.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "flappyGetReady.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/flappyGetReady.imageset/flappyGetReady.png b/InControl/InControl/Assets.xcassets/flappyGetReady.imageset/flappyGetReady.png new file mode 100644 index 0000000..00fccbe Binary files /dev/null and b/InControl/InControl/Assets.xcassets/flappyGetReady.imageset/flappyGetReady.png differ diff --git a/InControl/InControl/Assets.xcassets/flappyIcon.imageset/Contents.json b/InControl/InControl/Assets.xcassets/flappyIcon.imageset/Contents.json new file mode 100644 index 0000000..ecc4998 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/flappyIcon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "flappyIcon.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/flappyIcon.imageset/flappyIcon.png b/InControl/InControl/Assets.xcassets/flappyIcon.imageset/flappyIcon.png new file mode 100644 index 0000000..6e1cc75 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/flappyIcon.imageset/flappyIcon.png differ diff --git a/InControl/InControl/Assets.xcassets/flappyName.imageset/Contents.json b/InControl/InControl/Assets.xcassets/flappyName.imageset/Contents.json new file mode 100644 index 0000000..41ea7a5 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/flappyName.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "flappyName.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/flappyName.imageset/flappyName.png b/InControl/InControl/Assets.xcassets/flappyName.imageset/flappyName.png new file mode 100644 index 0000000..7b5b5d5 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/flappyName.imageset/flappyName.png differ diff --git a/InControl/InControl/Assets.xcassets/flappyPlayButton.imageset/Contents.json b/InControl/InControl/Assets.xcassets/flappyPlayButton.imageset/Contents.json new file mode 100644 index 0000000..571f23d --- /dev/null +++ b/InControl/InControl/Assets.xcassets/flappyPlayButton.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "flappyPlayButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/flappyPlayButton.imageset/flappyPlayButton.png b/InControl/InControl/Assets.xcassets/flappyPlayButton.imageset/flappyPlayButton.png new file mode 100644 index 0000000..665f3c0 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/flappyPlayButton.imageset/flappyPlayButton.png differ diff --git a/InControl/InControl/Assets.xcassets/foodimg.imageset/Contents.json b/InControl/InControl/Assets.xcassets/foodimg.imageset/Contents.json new file mode 100644 index 0000000..f99be46 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/foodimg.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "cute-best-japanese-food-art-bento-box-05_0.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/foodimg.imageset/cute-best-japanese-food-art-bento-box-05_0.png b/InControl/InControl/Assets.xcassets/foodimg.imageset/cute-best-japanese-food-art-bento-box-05_0.png new file mode 100644 index 0000000..2c68743 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/foodimg.imageset/cute-best-japanese-food-art-bento-box-05_0.png differ diff --git a/InControl/InControl/Assets.xcassets/g.imageset/Contents.json b/InControl/InControl/Assets.xcassets/g.imageset/Contents.json new file mode 100644 index 0000000..7f1c7ce --- /dev/null +++ b/InControl/InControl/Assets.xcassets/g.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "g.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/g.imageset/g.png b/InControl/InControl/Assets.xcassets/g.imageset/g.png new file mode 100644 index 0000000..6e68f79 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/g.imageset/g.png differ diff --git a/InControl/InControl/Assets.xcassets/games.imageset/Contents.json b/InControl/InControl/Assets.xcassets/games.imageset/Contents.json new file mode 100644 index 0000000..b9c566b --- /dev/null +++ b/InControl/InControl/Assets.xcassets/games.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "games.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/games.imageset/games.png b/InControl/InControl/Assets.xcassets/games.imageset/games.png new file mode 100644 index 0000000..bde57b8 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/games.imageset/games.png differ diff --git a/InControl/InControl/Assets.xcassets/goButton.imageset/Contents.json b/InControl/InControl/Assets.xcassets/goButton.imageset/Contents.json new file mode 100644 index 0000000..ec322c1 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/goButton.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "goButton.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/goButton.imageset/goButton.png b/InControl/InControl/Assets.xcassets/goButton.imageset/goButton.png new file mode 100644 index 0000000..127adf4 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/goButton.imageset/goButton.png differ diff --git a/InControl/InControl/Assets.xcassets/hotelimg.imageset/Contents.json b/InControl/InControl/Assets.xcassets/hotelimg.imageset/Contents.json new file mode 100644 index 0000000..3724c34 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/hotelimg.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "grand-park-city-hall-hotel-png.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/hotelimg.imageset/grand-park-city-hall-hotel-png.png b/InControl/InControl/Assets.xcassets/hotelimg.imageset/grand-park-city-hall-hotel-png.png new file mode 100644 index 0000000..c6de159 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/hotelimg.imageset/grand-park-city-hall-hotel-png.png differ diff --git a/InControl/InControl/Assets.xcassets/neew.imageset/Contents.json b/InControl/InControl/Assets.xcassets/neew.imageset/Contents.json new file mode 100644 index 0000000..a495741 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/neew.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "neew.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/neew.imageset/neew.png b/InControl/InControl/Assets.xcassets/neew.imageset/neew.png new file mode 100644 index 0000000..58fd9e0 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/neew.imageset/neew.png differ diff --git a/InControl/InControl/Assets.xcassets/newBackOk.imageset/Contents.json b/InControl/InControl/Assets.xcassets/newBackOk.imageset/Contents.json new file mode 100644 index 0000000..dedd1bf --- /dev/null +++ b/InControl/InControl/Assets.xcassets/newBackOk.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "newBackOk.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/newBackOk.imageset/newBackOk.jpg b/InControl/InControl/Assets.xcassets/newBackOk.imageset/newBackOk.jpg new file mode 100644 index 0000000..a96f746 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/newBackOk.imageset/newBackOk.jpg differ diff --git a/InControl/InControl/Assets.xcassets/newTrip.imageset/Contents.json b/InControl/InControl/Assets.xcassets/newTrip.imageset/Contents.json new file mode 100644 index 0000000..aaf2873 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/newTrip.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "newTrip.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/newTrip.imageset/newTrip.png b/InControl/InControl/Assets.xcassets/newTrip.imageset/newTrip.png new file mode 100644 index 0000000..3f199f9 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/newTrip.imageset/newTrip.png differ diff --git a/InControl/InControl/Assets.xcassets/ok.imageset/Contents.json b/InControl/InControl/Assets.xcassets/ok.imageset/Contents.json new file mode 100644 index 0000000..b98894c --- /dev/null +++ b/InControl/InControl/Assets.xcassets/ok.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ok.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/ok.imageset/ok.png b/InControl/InControl/Assets.xcassets/ok.imageset/ok.png new file mode 100644 index 0000000..c1e333d Binary files /dev/null and b/InControl/InControl/Assets.xcassets/ok.imageset/ok.png differ diff --git a/InControl/InControl/Assets.xcassets/or.imageset/Contents.json b/InControl/InControl/Assets.xcassets/or.imageset/Contents.json new file mode 100644 index 0000000..b580d7a --- /dev/null +++ b/InControl/InControl/Assets.xcassets/or.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "or.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/or.imageset/or.jpg b/InControl/InControl/Assets.xcassets/or.imageset/or.jpg new file mode 100644 index 0000000..df600c9 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/or.imageset/or.jpg differ diff --git a/InControl/InControl/Assets.xcassets/orr.imageset/Contents.json b/InControl/InControl/Assets.xcassets/orr.imageset/Contents.json new file mode 100644 index 0000000..5286047 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/orr.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "orr.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/orr.imageset/orr.jpg b/InControl/InControl/Assets.xcassets/orr.imageset/orr.jpg new file mode 100644 index 0000000..a956cca Binary files /dev/null and b/InControl/InControl/Assets.xcassets/orr.imageset/orr.jpg differ diff --git a/InControl/InControl/Assets.xcassets/orrr.imageset/Contents.json b/InControl/InControl/Assets.xcassets/orrr.imageset/Contents.json new file mode 100644 index 0000000..2b145bc --- /dev/null +++ b/InControl/InControl/Assets.xcassets/orrr.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "orrr.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/orrr.imageset/orrr.jpg b/InControl/InControl/Assets.xcassets/orrr.imageset/orrr.jpg new file mode 100644 index 0000000..f323619 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/orrr.imageset/orrr.jpg differ diff --git a/InControl/InControl/Assets.xcassets/q.imageset/Contents.json b/InControl/InControl/Assets.xcassets/q.imageset/Contents.json new file mode 100644 index 0000000..4a1c579 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/q.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "q.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/q.imageset/q.jpg b/InControl/InControl/Assets.xcassets/q.imageset/q.jpg new file mode 100644 index 0000000..f57bc17 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/q.imageset/q.jpg differ diff --git a/InControl/InControl/Assets.xcassets/qq.imageset/Contents.json b/InControl/InControl/Assets.xcassets/qq.imageset/Contents.json new file mode 100644 index 0000000..6f5c253 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/qq.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "qq.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/qq.imageset/qq.jpg b/InControl/InControl/Assets.xcassets/qq.imageset/qq.jpg new file mode 100644 index 0000000..3dd74e9 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/qq.imageset/qq.jpg differ diff --git a/InControl/InControl/Assets.xcassets/settings.imageset/Contents.json b/InControl/InControl/Assets.xcassets/settings.imageset/Contents.json new file mode 100644 index 0000000..30bf882 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/settings.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "settings@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/settings.imageset/settings@3x.png b/InControl/InControl/Assets.xcassets/settings.imageset/settings@3x.png new file mode 100644 index 0000000..a6e3c75 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/settings.imageset/settings@3x.png differ diff --git a/InControl/InControl/Assets.xcassets/takePhoto.imageset/Contents.json b/InControl/InControl/Assets.xcassets/takePhoto.imageset/Contents.json new file mode 100644 index 0000000..7a1adba --- /dev/null +++ b/InControl/InControl/Assets.xcassets/takePhoto.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "takePhoto.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/takePhoto.imageset/takePhoto.png b/InControl/InControl/Assets.xcassets/takePhoto.imageset/takePhoto.png new file mode 100644 index 0000000..3aec894 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/takePhoto.imageset/takePhoto.png differ diff --git a/InControl/InControl/Assets.xcassets/tr.imageset/Contents.json b/InControl/InControl/Assets.xcassets/tr.imageset/Contents.json new file mode 100644 index 0000000..5f1391f --- /dev/null +++ b/InControl/InControl/Assets.xcassets/tr.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "tr.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/tr.imageset/tr.jpg b/InControl/InControl/Assets.xcassets/tr.imageset/tr.jpg new file mode 100644 index 0000000..7f54286 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/tr.imageset/tr.jpg differ diff --git a/InControl/InControl/Assets.xcassets/tra.imageset/Contents.json b/InControl/InControl/Assets.xcassets/tra.imageset/Contents.json new file mode 100644 index 0000000..6282053 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/tra.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "tra.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/tra.imageset/tra.jpg b/InControl/InControl/Assets.xcassets/tra.imageset/tra.jpg new file mode 100644 index 0000000..e0e1849 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/tra.imageset/tra.jpg differ diff --git a/InControl/InControl/Assets.xcassets/trr.imageset/Contents.json b/InControl/InControl/Assets.xcassets/trr.imageset/Contents.json new file mode 100644 index 0000000..1f7d323 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/trr.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "trr.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/trr.imageset/trr.jpg b/InControl/InControl/Assets.xcassets/trr.imageset/trr.jpg new file mode 100644 index 0000000..82d0204 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/trr.imageset/trr.jpg differ diff --git a/InControl/InControl/Assets.xcassets/try.imageset/Contents.json b/InControl/InControl/Assets.xcassets/try.imageset/Contents.json new file mode 100644 index 0000000..5639310 --- /dev/null +++ b/InControl/InControl/Assets.xcassets/try.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "try.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/try.imageset/try.jpg b/InControl/InControl/Assets.xcassets/try.imageset/try.jpg new file mode 100644 index 0000000..e4737b4 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/try.imageset/try.jpg differ diff --git a/InControl/InControl/Assets.xcassets/visi.imageset/Contents.json b/InControl/InControl/Assets.xcassets/visi.imageset/Contents.json new file mode 100644 index 0000000..a1b2e1d --- /dev/null +++ b/InControl/InControl/Assets.xcassets/visi.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "visi.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/visi.imageset/visi.png b/InControl/InControl/Assets.xcassets/visi.imageset/visi.png new file mode 100644 index 0000000..b1beed9 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/visi.imageset/visi.png differ diff --git a/InControl/InControl/Assets.xcassets/visited.imageset/Contents.json b/InControl/InControl/Assets.xcassets/visited.imageset/Contents.json new file mode 100644 index 0000000..2690afd --- /dev/null +++ b/InControl/InControl/Assets.xcassets/visited.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "visited.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/InControl/InControl/Assets.xcassets/visited.imageset/visited.png b/InControl/InControl/Assets.xcassets/visited.imageset/visited.png new file mode 100644 index 0000000..bcf6f26 Binary files /dev/null and b/InControl/InControl/Assets.xcassets/visited.imageset/visited.png differ diff --git a/InControl/InControl/Base.lproj/LaunchScreen.storyboard b/InControl/InControl/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..2e721e1 --- /dev/null +++ b/InControl/InControl/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InControl/InControl/Base.lproj/Main.storyboard b/InControl/InControl/Base.lproj/Main.storyboard new file mode 100644 index 0000000..6d629f4 --- /dev/null +++ b/InControl/InControl/Base.lproj/Main.storyboard @@ -0,0 +1,2295 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InControl/InControl/BirdDown.png b/InControl/InControl/BirdDown.png new file mode 100644 index 0000000..296dcd2 Binary files /dev/null and b/InControl/InControl/BirdDown.png differ diff --git a/InControl/InControl/BirdUp.png b/InControl/InControl/BirdUp.png new file mode 100644 index 0000000..d71c9fd Binary files /dev/null and b/InControl/InControl/BirdUp.png differ diff --git a/InControl/InControl/CandyViewController.h b/InControl/InControl/CandyViewController.h new file mode 100644 index 0000000..d212d0c --- /dev/null +++ b/InControl/InControl/CandyViewController.h @@ -0,0 +1,187 @@ +// +// CandyViewController.h +// InControl +// +// Created by Diana Elezaj on 10/22/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +int Candy1Type; +int Candy2Type; +int Candy3Type; +int Candy4Type; +int Candy5Type; +int Candy6Type; +int Candy7Type; +int Candy8Type; +int Candy9Type; +int Candy10Type; +int Candy11Type; +int Candy12Type; +int Candy13Type; +int Candy14Type; +int Candy15Type; +int Candy16Type; + +int FirstCandyPushed; +int FirstCandyTypePushed; +int SecondCandyPushed; +int SecondCandyTypePushed; + +BOOL FirstCandySelected; + +BOOL Candy1Deleted; +BOOL Candy2Deleted; +BOOL Candy3Deleted; +BOOL Candy4Deleted; +BOOL Candy5Deleted; +BOOL Candy6Deleted; +BOOL Candy7Deleted; +BOOL Candy8Deleted; +BOOL Candy9Deleted; +BOOL Candy10Deleted; +BOOL Candy11Deleted; +BOOL Candy12Deleted; +BOOL Candy13Deleted; +BOOL Candy14Deleted; +BOOL Candy15Deleted; +BOOL Candy16Deleted; + +int MovesLeftNumber; +int candyScoreNumber; +int AddedScore; +NSInteger candyHighScoreNumber; + +BOOL GameFinished; + + +@interface CandyViewController : UIViewController + + +{ + + IBOutlet UIButton *Candy1; + IBOutlet UIButton *Candy2; + IBOutlet UIButton *Candy3; + IBOutlet UIButton *Candy4; + IBOutlet UIButton *Candy5; + IBOutlet UIButton *Candy6; + IBOutlet UIButton *Candy7; + IBOutlet UIButton *Candy8; + IBOutlet UIButton *Candy9; + IBOutlet UIButton *Candy10; + IBOutlet UIButton *Candy11; + IBOutlet UIButton *Candy12; + IBOutlet UIButton *Candy13; + IBOutlet UIButton *Candy14; + IBOutlet UIButton *Candy15; + IBOutlet UIButton *Candy16; + IBOutlet UIImageView *Candy1Selected; + IBOutlet UIImageView *Candy2Selected; + IBOutlet UIImageView *Candy3Selected; + IBOutlet UIImageView *Candy4Selected; + IBOutlet UIImageView *Candy5Selected; + IBOutlet UIImageView *Candy6Selected; + IBOutlet UIImageView *Candy7Selected; + IBOutlet UIImageView *Candy8Selected; + IBOutlet UIImageView *Candy9Selected; + IBOutlet UIImageView *Candy10Selected; + IBOutlet UIImageView *Candy11Selected; + IBOutlet UIImageView *Candy12Selected; + IBOutlet UIImageView *Candy13Selected; + IBOutlet UIImageView *Candy14Selected; + IBOutlet UIImageView *Candy15Selected; + IBOutlet UIImageView *Candy16Selected; + + IBOutlet UIButton *Shuffle; + IBOutlet UIButton *Exit; + IBOutlet UILabel *Score; + IBOutlet UILabel *MovesLeft; + IBOutlet UILabel *HighScore; + + +} + + + +-(IBAction)Candy1Button:(id)sender; +-(IBAction)Candy2Button:(id)sender; +-(IBAction)Candy3Button:(id)sender; +-(IBAction)Candy4Button:(id)sender; +-(IBAction)Candy5Button:(id)sender; +-(IBAction)Candy6Button:(id)sender; +-(IBAction)Candy7Button:(id)sender; +-(IBAction)Candy8Button:(id)sender; +-(IBAction)Candy9Button:(id)sender; +-(IBAction)Candy10Button:(id)sender; +-(IBAction)Candy11Button:(id)sender; +-(IBAction)Candy12Button:(id)sender; +-(IBAction)Candy13Button:(id)sender; +-(IBAction)Candy14Button:(id)sender; +-(IBAction)Candy15Button:(id)sender; +-(IBAction)Candy16Button:(id)sender; + + +-(void)CheckSwap; +-(void)UnselectCandies; +-(void)SwapCandies; + + +-(void)Candy1SelectedType; +-(void)Candy2SelectedType; +-(void)Candy3SelectedType; +-(void)Candy4SelectedType; +-(void)Candy5SelectedType; +-(void)Candy6SelectedType; +-(void)Candy7SelectedType; +-(void)Candy8SelectedType; +-(void)Candy9SelectedType; +-(void)Candy10SelectedType; +-(void)Candy11SelectedType; +-(void)Candy12SelectedType; +-(void)Candy13SelectedType; +-(void)Candy14SelectedType; +-(void)Candy15SelectedType; +-(void)Candy16SelectedType; +-(void)CheckConnection; +-(void)GetRidOfCandies; +-(void)ReplaceCandies; + +-(void)Move; +-(void)Scoring; +-(IBAction)Shuffle:(id)sender; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +@end diff --git a/InControl/InControl/CandyViewController.m b/InControl/InControl/CandyViewController.m new file mode 100644 index 0000000..72e4378 --- /dev/null +++ b/InControl/InControl/CandyViewController.m @@ -0,0 +1,1748 @@ +// +// CandyViewController.m +// InControl +// +// Created by Diana Elezaj on 10/22/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "CandyViewController.h" + +@interface CandyViewController () + +@end + +@implementation CandyViewController + + + +-(IBAction)Shuffle:(id)sender{ + + Candy1Type = arc4random() %4; + Candy2Type = arc4random() %4; + Candy3Type = arc4random() %4; + Candy4Type = arc4random() %4; + Candy5Type = arc4random() %4; + Candy6Type = arc4random() %4; + Candy7Type = arc4random() %4; + Candy8Type = arc4random() %4; + Candy9Type = arc4random() %4; + Candy10Type = arc4random() %4; + Candy11Type = arc4random() %4; + Candy12Type = arc4random() %4; + Candy13Type = arc4random() %4; + Candy14Type = arc4random() %4; + Candy15Type = arc4random() %4; + Candy16Type = arc4random() %4; + + [self Candy1SelectedType]; + [self Candy2SelectedType]; + [self Candy3SelectedType]; + [self Candy4SelectedType]; + [self Candy5SelectedType]; + [self Candy6SelectedType]; + [self Candy7SelectedType]; + [self Candy8SelectedType]; + [self Candy9SelectedType]; + [self Candy10SelectedType]; + [self Candy11SelectedType]; + [self Candy12SelectedType]; + [self Candy13SelectedType]; + [self Candy14SelectedType]; + [self Candy15SelectedType]; + [self Candy16SelectedType]; + + MovesLeftNumber = MovesLeftNumber - 2; + MovesLeft.text = [NSString stringWithFormat:@"Moves Left: %i", MovesLeftNumber]; + + if (MovesLeftNumber < 3) { + Shuffle.hidden = YES; + } + + [self performSelector:@selector(CheckConnection) withObject:self afterDelay:0.3]; + + + +} + + +-(void)Move{ + + MovesLeftNumber = MovesLeftNumber - 1; + MovesLeft.text = [NSString stringWithFormat:@"Moves Left: %i", MovesLeftNumber]; + + + if (MovesLeftNumber < 3) { + Shuffle.hidden = YES; + } + + if (MovesLeftNumber == 0) { + Candy1.hidden = YES; + Candy2.hidden = YES; + Candy3.hidden = YES; + Candy4.hidden = YES; + Candy5.hidden = YES; + Candy6.hidden = YES; + Candy7.hidden = YES; + Candy8.hidden = YES; + Candy9.hidden = YES; + Candy10.hidden = YES; + Candy11.hidden = YES; + Candy12.hidden = YES; + Candy13.hidden = YES; + Candy14.hidden = YES; + Candy15.hidden = YES; + Candy16.hidden = YES; + + MovesLeft.hidden = YES; + HighScore.hidden = YES; + + Exit.hidden = NO; + + GameFinished = YES; + + if (candyScoreNumber > candyHighScoreNumber) { + HighScore.hidden = NO; + [[NSUserDefaults standardUserDefaults] setInteger:candyScoreNumber forKey:@"HighScoreSaved"]; + } + + + } +} + + + +-(void)Scoring{ + + candyScoreNumber = candyScoreNumber + AddedScore; + Score.text = [NSString stringWithFormat:@"Score: %i", candyScoreNumber]; + + + if (candyScoreNumber > candyHighScoreNumber) { + HighScore.text = [NSString stringWithFormat:@"High Score: %i", candyScoreNumber]; + } + +} + + + + +-(void)ReplaceCandies{ + + [self Candy1SelectedType]; + [self Candy2SelectedType]; + [self Candy3SelectedType]; + [self Candy4SelectedType]; + [self Candy5SelectedType]; + [self Candy6SelectedType]; + [self Candy7SelectedType]; + [self Candy8SelectedType]; + [self Candy9SelectedType]; + [self Candy10SelectedType]; + [self Candy11SelectedType]; + [self Candy12SelectedType]; + [self Candy13SelectedType]; + [self Candy14SelectedType]; + [self Candy15SelectedType]; + [self Candy16SelectedType]; + + Candy1.hidden = NO; + Candy2.hidden = NO; + Candy3.hidden = NO; + Candy4.hidden = NO; + Candy5.hidden = NO; + Candy6.hidden = NO; + Candy7.hidden = NO; + Candy8.hidden = NO; + Candy9.hidden = NO; + Candy10.hidden = NO; + Candy11.hidden = NO; + Candy12.hidden = NO; + Candy13.hidden = NO; + Candy14.hidden = NO; + Candy15.hidden = NO; + Candy16.hidden = NO; + + Candy1Deleted = NO; + Candy2Deleted = NO; + Candy3Deleted = NO; + Candy4Deleted = NO; + Candy5Deleted = NO; + Candy6Deleted = NO; + Candy7Deleted = NO; + Candy8Deleted = NO; + Candy9Deleted = NO; + Candy10Deleted = NO; + Candy11Deleted = NO; + Candy12Deleted = NO; + Candy13Deleted = NO; + Candy14Deleted = NO; + Candy15Deleted = NO; + Candy16Deleted = NO; + + if (GameFinished == YES) { + Candy1.hidden = YES; + Candy2.hidden = YES; + Candy3.hidden = YES; + Candy4.hidden = YES; + Candy5.hidden = YES; + Candy6.hidden = YES; + Candy7.hidden = YES; + Candy8.hidden = YES; + Candy9.hidden = YES; + Candy10.hidden = YES; + Candy11.hidden = YES; + Candy12.hidden = YES; + Candy13.hidden = YES; + Candy14.hidden = YES; + Candy15.hidden = YES; + Candy16.hidden = YES; + } + else{ + [self performSelector:@selector(CheckConnection) withObject:self afterDelay:0.1]; + } +} + +-(void)GetRidOfCandies{ + + if (Candy1Deleted == YES) { + Candy1.hidden = YES; + Candy1Type = arc4random() %4; + } + if (Candy2Deleted == YES) { + Candy2.hidden = YES; + Candy2Type = arc4random() %4; + } + if (Candy3Deleted == YES) { + Candy3.hidden = YES; + Candy3Type = arc4random() %4; + } + if (Candy4Deleted == YES) { + Candy4.hidden = YES; + Candy4Type = arc4random() %4; + } + if (Candy5Deleted == YES) { + Candy5.hidden = YES; + Candy5Type = arc4random() %4; + } + if (Candy6Deleted == YES) { + Candy6.hidden = YES; + Candy6Type = arc4random() %4; + } + if (Candy7Deleted == YES) { + Candy7.hidden = YES; + Candy7Type = arc4random() %4; + } + if (Candy8Deleted == YES) { + Candy8.hidden = YES; + Candy8Type = arc4random() %4; + } + if (Candy9Deleted == YES) { + Candy9.hidden = YES; + Candy9Type = arc4random() %4; + } + if (Candy10Deleted == YES) { + Candy10.hidden = YES; + Candy10Type = arc4random() %4; + } + if (Candy11Deleted == YES) { + Candy11.hidden = YES; + Candy11Type = arc4random() %4; + } + if (Candy12Deleted == YES) { + Candy12.hidden = YES; + Candy12Type = arc4random() %4; + } + if (Candy13Deleted == YES) { + Candy13.hidden = YES; + Candy13Type = arc4random() %4; + } + if (Candy14Deleted == YES) { + Candy14.hidden = YES; + Candy14Type = arc4random() %4; + } + if (Candy15Deleted == YES) { + Candy15.hidden = YES; + Candy15Type = arc4random() %4; + } + if (Candy16Deleted == YES) { + Candy16.hidden = YES; + Candy16Type = arc4random() %4; + } + + [self performSelector:@selector(ReplaceCandies) withObject:self afterDelay:0.1]; + + +} + + + +-(void)CheckConnection{ + + if (Candy1Type == Candy2Type && Candy2Type == Candy3Type && Candy3Type == Candy4Type) { + Candy1Deleted = YES; + Candy2Deleted = YES; + Candy3Deleted = YES; + Candy4Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 2; + [self Scoring]; + } + + if (Candy5Type == Candy6Type && Candy6Type == Candy7Type && Candy7Type == Candy8Type) { + Candy5Deleted = YES; + Candy6Deleted = YES; + Candy7Deleted = YES; + Candy8Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 2; + [self Scoring]; + } + + if (Candy9Type == Candy10Type && Candy10Type == Candy11Type && Candy11Type == Candy12Type) { + Candy9Deleted = YES; + Candy10Deleted = YES; + Candy11Deleted = YES; + Candy12Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 2; + [self Scoring]; + } + + if (Candy13Type == Candy14Type && Candy14Type == Candy15Type && Candy15Type == Candy16Type) { + Candy13Deleted = YES; + Candy14Deleted = YES; + Candy15Deleted = YES; + Candy16Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 2; + [self Scoring]; + } + if (Candy1Type == Candy5Type && Candy5Type == Candy9Type && Candy9Type == Candy13Type) { + Candy1Deleted = YES; + Candy5Deleted = YES; + Candy9Deleted = YES; + Candy13Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 2; + [self Scoring]; + } + + if (Candy2Type == Candy6Type && Candy6Type == Candy10Type && Candy10Type == Candy14Type) { + Candy2Deleted = YES; + Candy6Deleted = YES; + Candy10Deleted = YES; + Candy14Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 2; + [self Scoring]; + } + if (Candy3Type == Candy7Type && Candy7Type == Candy11Type && Candy11Type == Candy15Type) { + Candy3Deleted = YES; + Candy7Deleted = YES; + Candy11Deleted = YES; + Candy15Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 2; + [self Scoring]; + } + if (Candy4Type == Candy8Type && Candy8Type == Candy12Type && Candy12Type == Candy16Type) { + Candy4Deleted = YES; + Candy8Deleted = YES; + Candy12Deleted = YES; + Candy16Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 2; + [self Scoring]; + } + + if (Candy1Type == Candy2Type && Candy2Type == Candy3Type) { + Candy1Deleted = YES; + Candy2Deleted = YES; + Candy3Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy2Type == Candy3Type && Candy3Type == Candy4Type) { + Candy2Deleted = YES; + Candy3Deleted = YES; + Candy4Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy5Type == Candy6Type && Candy6Type == Candy7Type) { + Candy5Deleted = YES; + Candy6Deleted = YES; + Candy7Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy6Type == Candy7Type && Candy7Type == Candy8Type) { + Candy6Deleted = YES; + Candy7Deleted = YES; + Candy8Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy9Type == Candy10Type && Candy10Type == Candy11Type) { + Candy9Deleted = YES; + Candy10Deleted = YES; + Candy11Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy10Type == Candy11Type && Candy11Type == Candy12Type) { + Candy10Deleted = YES; + Candy11Deleted = YES; + Candy12Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy13Type == Candy14Type && Candy14Type == Candy15Type) { + Candy13Deleted = YES; + Candy14Deleted = YES; + Candy15Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy14Type == Candy15Type && Candy15Type == Candy16Type) { + Candy14Deleted = YES; + Candy15Deleted = YES; + Candy16Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + + if (Candy1Type == Candy5Type && Candy5Type == Candy9Type) { + Candy1Deleted = YES; + Candy5Deleted = YES; + Candy9Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy5Type == Candy9Type && Candy9Type == Candy13Type) { + Candy5Deleted = YES; + Candy9Deleted = YES; + Candy13Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy2Type == Candy6Type && Candy6Type == Candy10Type) { + Candy2Deleted = YES; + Candy6Deleted = YES; + Candy10Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy6Type == Candy10Type && Candy10Type == Candy14Type) { + Candy6Deleted = YES; + Candy10Deleted = YES; + Candy14Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy3Type == Candy7Type && Candy7Type == Candy11Type) { + Candy3Deleted = YES; + Candy7Deleted = YES; + Candy11Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy7Type == Candy11Type && Candy11Type == Candy15Type) { + Candy7Deleted = YES; + Candy11Deleted = YES; + Candy15Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy4Type == Candy8Type && Candy8Type == Candy12Type) { + Candy4Deleted = YES; + Candy8Deleted = YES; + Candy12Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + if (Candy8Type == Candy12Type && Candy12Type == Candy16Type) { + Candy8Deleted = YES; + Candy12Deleted = YES; + Candy16Deleted = YES; + [self performSelector:@selector(GetRidOfCandies) withObject:self afterDelay:0.1]; + AddedScore = 1; + [self Scoring]; + } + + +} + + + +-(void)SwapCandies{ + + switch (FirstCandyPushed) { + case 1: + Candy1Type = SecondCandyTypePushed; + [self Candy1SelectedType]; + break; + case 2: + Candy2Type = SecondCandyTypePushed; + [self Candy2SelectedType]; + break; + case 3: + Candy3Type = SecondCandyTypePushed; + [self Candy3SelectedType]; + break; + case 4: + Candy4Type = SecondCandyTypePushed; + [self Candy4SelectedType]; + break; + case 5: + Candy5Type = SecondCandyTypePushed; + [self Candy5SelectedType]; + break; + case 6: + Candy6Type = SecondCandyTypePushed; + [self Candy6SelectedType]; + break; + case 7: + Candy7Type = SecondCandyTypePushed; + [self Candy7SelectedType]; + break; + case 8: + Candy8Type = SecondCandyTypePushed; + [self Candy8SelectedType]; + break; + case 9: + Candy9Type = SecondCandyTypePushed; + [self Candy9SelectedType]; + break; + case 10: + Candy10Type = SecondCandyTypePushed; + [self Candy10SelectedType]; + break; + case 11: + Candy11Type = SecondCandyTypePushed; + [self Candy11SelectedType]; + break; + case 12: + Candy12Type = SecondCandyTypePushed; + [self Candy12SelectedType]; + break; + case 13: + Candy13Type = SecondCandyTypePushed; + [self Candy13SelectedType]; + break; + case 14: + Candy14Type = SecondCandyTypePushed; + [self Candy14SelectedType]; + break; + case 15: + Candy15Type = SecondCandyTypePushed; + [self Candy15SelectedType]; + break; + case 16: + Candy16Type = SecondCandyTypePushed; + [self Candy16SelectedType]; + break; + default: + break; + } + + + + switch (SecondCandyPushed) { + case 1: + Candy1Type = FirstCandyTypePushed; + [self Candy1SelectedType]; + break; + case 2: + Candy2Type = FirstCandyTypePushed; + [self Candy2SelectedType]; + break; + case 3: + Candy3Type = FirstCandyTypePushed; + [self Candy3SelectedType]; + break; + case 4: + Candy4Type = FirstCandyTypePushed; + [self Candy4SelectedType]; + break; + case 5: + Candy5Type = FirstCandyTypePushed; + [self Candy5SelectedType]; + break; + case 6: + Candy6Type = FirstCandyTypePushed; + [self Candy6SelectedType]; + break; + case 7: + Candy7Type = FirstCandyTypePushed; + [self Candy7SelectedType]; + break; + case 8: + Candy8Type = FirstCandyTypePushed; + [self Candy8SelectedType]; + break; + case 9: + Candy9Type = FirstCandyTypePushed; + [self Candy9SelectedType]; + break; + case 10: + Candy10Type = FirstCandyTypePushed; + [self Candy10SelectedType]; + break; + case 11: + Candy11Type = FirstCandyTypePushed; + [self Candy11SelectedType]; + break; + case 12: + Candy12Type = FirstCandyTypePushed; + [self Candy12SelectedType]; + break; + case 13: + Candy13Type = FirstCandyTypePushed; + [self Candy13SelectedType]; + break; + case 14: + Candy14Type = FirstCandyTypePushed; + [self Candy14SelectedType]; + break; + case 15: + Candy15Type = FirstCandyTypePushed; + [self Candy15SelectedType]; + break; + case 16: + Candy16Type = FirstCandyTypePushed; + [self Candy16SelectedType]; + break; + default: + break; + } + + + [self UnselectCandies]; + [self CheckConnection]; + [self performSelector:@selector(Move) withObject:self afterDelay:0.5]; + + +} + +-(void)UnselectCandies{ + + Candy1Selected.hidden = YES; + Candy2Selected.hidden = YES; + Candy3Selected.hidden = YES; + Candy4Selected.hidden = YES; + Candy5Selected.hidden = YES; + Candy6Selected.hidden = YES; + Candy7Selected.hidden = YES; + Candy8Selected.hidden = YES; + Candy9Selected.hidden = YES; + Candy10Selected.hidden = YES; + Candy11Selected.hidden = YES; + Candy12Selected.hidden = YES; + Candy13Selected.hidden = YES; + Candy14Selected.hidden = YES; + Candy15Selected.hidden = YES; + Candy16Selected.hidden = YES; + + FirstCandySelected = NO; + FirstCandyPushed = 0; + FirstCandyTypePushed = 0; + SecondCandyPushed = 0; + SecondCandyTypePushed = 0; + +} + + + +-(void)CheckSwap{ + + + if (FirstCandyPushed == SecondCandyPushed + 1) { + if (FirstCandyPushed == 5) { + [self UnselectCandies]; + } + else if (FirstCandyPushed == 9){ + [self UnselectCandies]; + } + else if (FirstCandyPushed == 13){ + [self UnselectCandies]; + } + else{ + [self SwapCandies]; + } + + } + + + + + else if (FirstCandyPushed == SecondCandyPushed - 1){ + if (FirstCandyPushed == 4) { + [self UnselectCandies]; + } + else if (FirstCandyPushed == 8){ + [self UnselectCandies]; + } + else if (FirstCandyPushed == 12){ + [self UnselectCandies]; + } + else{ + [self SwapCandies]; + } + } + + + + + + else if (FirstCandyPushed == SecondCandyPushed + 4){ + [self SwapCandies]; + } + else if (FirstCandyPushed == SecondCandyPushed - 4){ + [self SwapCandies]; + } + else{ + [self UnselectCandies]; + } + + + +} + + + + + +-(IBAction)Candy1Button:(id)sender{ + NSLog(@"1"); + + if (FirstCandySelected == NO) { + Candy1Selected.hidden = NO; + FirstCandyPushed = 1; + FirstCandyTypePushed = Candy1Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 1; + SecondCandyTypePushed = Candy1Type; + [self CheckSwap]; + } + +} + +-(IBAction)Candy2Button:(id)sender{ + NSLog(@"2"); + + if (FirstCandySelected == NO) { + Candy2Selected.hidden = NO; + FirstCandyPushed = 2; + FirstCandyTypePushed = Candy2Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 2; + SecondCandyTypePushed = Candy2Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy3Button:(id)sender{ + NSLog(@"3"); + + if (FirstCandySelected == NO) { + Candy3Selected.hidden = NO; + FirstCandyPushed = 3; + FirstCandyTypePushed = Candy3Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 3; + SecondCandyTypePushed = Candy3Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy4Button:(id)sender{ + NSLog(@"4"); + + if (FirstCandySelected == NO) { + Candy4Selected.hidden = NO; + FirstCandyPushed = 4; + FirstCandyTypePushed = Candy4Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 4; + SecondCandyTypePushed = Candy4Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy5Button:(id)sender{ + NSLog(@"5"); + + if (FirstCandySelected == NO) { + Candy5Selected.hidden = NO; + FirstCandyPushed = 5; + FirstCandyTypePushed = Candy5Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 5; + SecondCandyTypePushed = Candy5Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy6Button:(id)sender{ + NSLog(@"6"); + + if (FirstCandySelected == NO) { + Candy6Selected.hidden = NO; + FirstCandyPushed = 6; + FirstCandyTypePushed = Candy6Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 6; + SecondCandyTypePushed = Candy6Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy7Button:(id)sender{ + NSLog(@"7"); + + if (FirstCandySelected == NO) { + Candy7Selected.hidden = NO; + FirstCandyPushed = 7; + FirstCandyTypePushed = Candy7Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 7; + SecondCandyTypePushed = Candy7Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy8Button:(id)sender{ + NSLog(@"8"); + + if (FirstCandySelected == NO) { + Candy8Selected.hidden = NO; + FirstCandyPushed = 8; + FirstCandyTypePushed = Candy8Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 8; + SecondCandyTypePushed = Candy8Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy9Button:(id)sender{ + NSLog(@"9"); + + if (FirstCandySelected == NO) { + Candy9Selected.hidden = NO; + FirstCandyPushed = 9; + FirstCandyTypePushed = Candy9Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 9; + SecondCandyTypePushed = Candy9Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy10Button:(id)sender{ + NSLog(@"10"); + + if (FirstCandySelected == NO) { + Candy10Selected.hidden = NO; + FirstCandyPushed = 10; + FirstCandyTypePushed = Candy10Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 10; + SecondCandyTypePushed = Candy10Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy11Button:(id)sender{ + NSLog(@"11"); + + if (FirstCandySelected == NO) { + Candy11Selected.hidden = NO; + FirstCandyPushed = 11; + FirstCandyTypePushed = Candy11Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 11; + SecondCandyTypePushed = Candy11Type; + [self CheckSwap]; + } + +} + +-(IBAction)Candy12Button:(id)sender{ + NSLog(@"12"); + + if (FirstCandySelected == NO) { + Candy12Selected.hidden = NO; + FirstCandyPushed = 12; + FirstCandyTypePushed = Candy12Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 12; + SecondCandyTypePushed = Candy12Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy13Button:(id)sender{ + NSLog(@"13"); + + if (FirstCandySelected == NO) { + Candy13Selected.hidden = NO; + FirstCandyPushed = 13; + FirstCandyTypePushed = Candy13Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 13; + SecondCandyTypePushed = Candy13Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy14Button:(id)sender{ + NSLog(@"14"); + + if (FirstCandySelected == NO) { + Candy14Selected.hidden = NO; + FirstCandyPushed = 14; + FirstCandyTypePushed = Candy14Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 14; + SecondCandyTypePushed = Candy14Type; + [self CheckSwap]; + } + + +} + +-(IBAction)Candy15Button:(id)sender{ + NSLog(@"15"); + + if (FirstCandySelected == NO) { + Candy15Selected.hidden = NO; + FirstCandyPushed = 15; + FirstCandyTypePushed = Candy15Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 15; + SecondCandyTypePushed = Candy15Type; + [self CheckSwap]; + } + +} + +-(IBAction)Candy16Button:(id)sender{ + NSLog(@"16"); + + if (FirstCandySelected == NO) { + Candy16Selected.hidden = NO; + FirstCandyPushed = 16; + FirstCandyTypePushed = Candy16Type; + FirstCandySelected = YES; + } + else{ + SecondCandyPushed = 16; + SecondCandyTypePushed = Candy16Type; + [self CheckSwap]; + } + + +} + +-(void)Candy1SelectedType{ + + switch (Candy1Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy1 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy1]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy1 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy1]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy1 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy1]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy1 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy1]; + } + break; + + default: + break; + } + + + + +} + +-(void)Candy2SelectedType{ + + switch (Candy2Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy2 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy2]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy2 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy2]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy2 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy2]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy2 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy2]; + } + break; + + default: + break; + } + + +} +-(void)Candy3SelectedType{ + + switch (Candy3Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy3 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy3]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy3 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy3]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy3 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy3]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy3 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy3]; + } + break; + + default: + break; + } + + + +} +-(void)Candy4SelectedType{ + + switch (Candy4Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy4 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy4]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy4 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy4]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy4 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy4]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy4 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy4]; + } + break; + + default: + break; + } + + + +} +-(void)Candy5SelectedType{ + + switch (Candy5Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy5 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy5]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy5 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy5]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy5 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy5]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy5 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy5]; + } + break; + + default: + break; + } + + + +} +-(void)Candy6SelectedType{ + + switch (Candy6Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy6 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy6]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy6 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy6]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy6 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy6]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy6 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy6]; + } + break; + + default: + break; + } + + + +} +-(void)Candy7SelectedType{ + + switch (Candy7Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy7 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy7]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy7 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy7]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy7 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy7]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy7 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy7]; + } + break; + + default: + break; + } + + + +} +-(void)Candy8SelectedType{ + + switch (Candy8Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy8 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy8]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy8 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy8]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy8 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy8]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy8 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy8]; + } + break; + + default: + break; + } + + + +} +-(void)Candy9SelectedType{ + + switch (Candy9Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy9 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy9]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy9 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy9]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy9 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy9]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy9 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy9]; + } + break; + + default: + break; + } + + + +} +-(void)Candy10SelectedType{ + + switch (Candy10Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy10 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy10]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy10 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy10]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy10 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy10]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy10 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy10]; + } + break; + + default: + break; + } + + + +} +-(void)Candy11SelectedType{ + switch (Candy11Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy11 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy11]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy11 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy11]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy11 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy11]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy11 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy11]; + } + break; + + default: + break; + } + + + +} +-(void)Candy12SelectedType{ + + switch (Candy12Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy12 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy12]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy12 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy12]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy12 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy12]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy12 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy12]; + } + break; + + default: + break; + } + + + +} +-(void)Candy13SelectedType{ + + switch (Candy13Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy13 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy13]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy13 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy13]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy13 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy13]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy13 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy13]; + } + break; + + default: + break; + } + + +} +-(void)Candy14SelectedType{ + + switch (Candy14Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy14 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy14]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy14 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy14]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy14 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy14]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy14 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy14]; + } + break; + + default: + break; + } + + +} +-(void)Candy15SelectedType{ + + switch (Candy15Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy15 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy15]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy15 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy15]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy15 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy15]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy15 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy15]; + } + break; + + default: + break; + } + + + +} +-(void)Candy16SelectedType{ + + switch (Candy16Type) { + case 0: + { + UIImage *buttonImage = [UIImage imageNamed:@"BlueCandy"]; + [Candy16 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy16]; + } + break; + case 1: + { + UIImage *buttonImage = [UIImage imageNamed:@"PinkCandy"]; + [Candy16 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy16]; + } + break; + case 2: + { + UIImage *buttonImage = [UIImage imageNamed:@"GreenCandy"]; + [Candy16 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy16]; + } + break; + case 3: + { + UIImage *buttonImage = [UIImage imageNamed:@"OrangeCandy"]; + [Candy16 setImage:buttonImage forState:UIControlStateNormal]; + [self.view addSubview:Candy16]; + } + break; + + default: + break; + } + + + +} + + + + + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + + candyScoreNumber = 0; + MovesLeftNumber = 10; + Score.text = [NSString stringWithFormat:@"Score: 0"]; + MovesLeft.text = [NSString stringWithFormat:@"Moves Left: 10"]; + + GameFinished = NO; + + Exit.hidden = NO; + + + Candy1Selected.hidden = YES; + Candy2Selected.hidden = YES; + Candy3Selected.hidden = YES; + Candy4Selected.hidden = YES; + Candy5Selected.hidden = YES; + Candy6Selected.hidden = YES; + Candy7Selected.hidden = YES; + Candy8Selected.hidden = YES; + Candy9Selected.hidden = YES; + Candy10Selected.hidden = YES; + Candy11Selected.hidden = YES; + Candy12Selected.hidden = YES; + Candy13Selected.hidden = YES; + Candy14Selected.hidden = YES; + Candy15Selected.hidden = YES; + Candy16Selected.hidden = YES; + + Candy1Type = arc4random() %4; + Candy2Type = arc4random() %4; + Candy3Type = arc4random() %4; + Candy4Type = arc4random() %4; + Candy5Type = arc4random() %4; + Candy6Type = arc4random() %4; + Candy7Type = arc4random() %4; + Candy8Type = arc4random() %4; + Candy9Type = arc4random() %4; + Candy10Type = arc4random() %4; + Candy11Type = arc4random() %4; + Candy12Type = arc4random() %4; + Candy13Type = arc4random() %4; + Candy14Type = arc4random() %4; + Candy15Type = arc4random() %4; + Candy16Type = arc4random() %4; + + [self Candy1SelectedType]; + [self Candy2SelectedType]; + [self Candy3SelectedType]; + [self Candy4SelectedType]; + [self Candy5SelectedType]; + [self Candy6SelectedType]; + [self Candy7SelectedType]; + [self Candy8SelectedType]; + [self Candy9SelectedType]; + [self Candy10SelectedType]; + [self Candy11SelectedType]; + [self Candy12SelectedType]; + [self Candy13SelectedType]; + [self Candy14SelectedType]; + [self Candy15SelectedType]; + [self Candy16SelectedType]; + + [self performSelector:@selector(CheckConnection) withObject:self afterDelay:0.3]; + + candyHighScoreNumber = [[NSUserDefaults standardUserDefaults] integerForKey:@"HighScoreSaved"]; + HighScore.text = [NSString stringWithFormat:@"High Score: %li", (long)candyHighScoreNumber]; + + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + + + + + + + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/InControl/InControl/City+CoreDataProperties.h b/InControl/InControl/City+CoreDataProperties.h new file mode 100644 index 0000000..5a2fc3f --- /dev/null +++ b/InControl/InControl/City+CoreDataProperties.h @@ -0,0 +1,41 @@ +// +// City+CoreDataProperties.h +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// +// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu +// to delete and recreate this implementation file for your updated model. +// + +#import "City.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface City (CoreDataProperties) + +@property (nullable, nonatomic, retain) NSString *impression; +@property (nullable, nonatomic, retain) NSString *name; +@property (nullable, nonatomic, retain) NSNumber *rate; +@property (nullable, nonatomic, retain) NSDate *createdAt; +@property (nullable, nonatomic, retain) NSOrderedSet *photos; + +@end + +@interface City (CoreDataGeneratedAccessors) + +- (void)insertObject:(Photo *)value inPhotosAtIndex:(NSUInteger)idx; +- (void)removeObjectFromPhotosAtIndex:(NSUInteger)idx; +- (void)insertPhotos:(NSArray *)value atIndexes:(NSIndexSet *)indexes; +- (void)removePhotosAtIndexes:(NSIndexSet *)indexes; +- (void)replaceObjectInPhotosAtIndex:(NSUInteger)idx withObject:(Photo *)value; +- (void)replacePhotosAtIndexes:(NSIndexSet *)indexes withPhotos:(NSArray *)values; +- (void)addPhotosObject:(Photo *)value; +- (void)removePhotosObject:(Photo *)value; +- (void)addPhotos:(NSOrderedSet *)values; +- (void)removePhotos:(NSOrderedSet *)values; + +@end + +NS_ASSUME_NONNULL_END diff --git a/InControl/InControl/City+CoreDataProperties.m b/InControl/InControl/City+CoreDataProperties.m new file mode 100644 index 0000000..442956d --- /dev/null +++ b/InControl/InControl/City+CoreDataProperties.m @@ -0,0 +1,22 @@ +// +// City+CoreDataProperties.m +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// +// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu +// to delete and recreate this implementation file for your updated model. +// + +#import "City+CoreDataProperties.h" + +@implementation City (CoreDataProperties) + +@dynamic impression; +@dynamic name; +@dynamic rate; +@dynamic createdAt; +@dynamic photos; + +@end diff --git a/InControl/InControl/City.h b/InControl/InControl/City.h new file mode 100644 index 0000000..0a90e1c --- /dev/null +++ b/InControl/InControl/City.h @@ -0,0 +1,24 @@ +// +// City.h +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import + +@class Photo; + +NS_ASSUME_NONNULL_BEGIN + +@interface City : NSManagedObject + +// Insert code here to declare functionality of your managed object subclass + +@end + +NS_ASSUME_NONNULL_END + +#import "City+CoreDataProperties.h" diff --git a/InControl/InControl/City.m b/InControl/InControl/City.m new file mode 100644 index 0000000..52d9301 --- /dev/null +++ b/InControl/InControl/City.m @@ -0,0 +1,16 @@ +// +// City.m +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "City.h" +#import "Photo.h" + +@implementation City + +// Insert code here to add functionality to your managed object subclass + +@end diff --git a/InControl/InControl/CustomTableViewCell.h b/InControl/InControl/CustomTableViewCell.h new file mode 100644 index 0000000..5592c33 --- /dev/null +++ b/InControl/InControl/CustomTableViewCell.h @@ -0,0 +1,14 @@ +// +// CustomTableViewCell.h +// InControl +// +// Created by Artur Lan on 10/17/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface CustomTableViewCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UIImageView *customImage; +@end diff --git a/InControl/InControl/CustomTableViewCell.m b/InControl/InControl/CustomTableViewCell.m new file mode 100644 index 0000000..8e0244d --- /dev/null +++ b/InControl/InControl/CustomTableViewCell.m @@ -0,0 +1,23 @@ +// +// CustomTableViewCell.m +// InControl +// +// Created by Artur Lan on 10/17/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "CustomTableViewCell.h" + +@implementation CustomTableViewCell + +- (void)awakeFromNib { + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/InControl/InControl/Default-568h@2x.png b/InControl/InControl/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/InControl/InControl/Default-568h@2x.png differ diff --git a/InControl/InControl/Default.png b/InControl/InControl/Default.png new file mode 100644 index 0000000..4c8ca6f Binary files /dev/null and b/InControl/InControl/Default.png differ diff --git a/InControl/InControl/Default@2x.png b/InControl/InControl/Default@2x.png new file mode 100644 index 0000000..35b84cf Binary files /dev/null and b/InControl/InControl/Default@2x.png differ diff --git a/InControl/InControl/DetailVisitedViewController.h b/InControl/InControl/DetailVisitedViewController.h new file mode 100644 index 0000000..1f08e1d --- /dev/null +++ b/InControl/InControl/DetailVisitedViewController.h @@ -0,0 +1,16 @@ +// +// DetailVisitedViewController.h +// InControl +// +// Created by Xiulan Shi on 10/16/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import "City.h" + +@interface DetailVisitedViewController : UIViewController + +@property (nonatomic) City *city; + +@end diff --git a/InControl/InControl/DetailVisitedViewController.m b/InControl/InControl/DetailVisitedViewController.m new file mode 100644 index 0000000..49ba384 --- /dev/null +++ b/InControl/InControl/DetailVisitedViewController.m @@ -0,0 +1,76 @@ +// +// DetailVisitedViewController.m +// InControl +// +// Created by Xiulan Shi on 10/16/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "DetailVisitedViewController.h" +#import "Photo.h" +#import "PhotoCell.h" + +@interface DetailVisitedViewController () +< +UICollectionViewDataSource, +UICollectionViewDelegate, +UICollectionViewDelegateFlowLayout +> + +@property (weak, nonatomic) IBOutlet UILabel *cityLabel; +@property (weak, nonatomic) IBOutlet UILabel *rateLabel; +@property (weak, nonatomic) IBOutlet UILabel *impressionLabel; +@property (weak, nonatomic) IBOutlet UIImageView *imageView; + +@property (weak, nonatomic) IBOutlet UICollectionView *collectionView; + +@property (nonatomic) NSMutableOrderedSet *photos; + +@end + +@implementation DetailVisitedViewController + + +- (void)viewDidLoad { + [super viewDidLoad]; + self.collectionView.dataSource = self; + self.collectionView.delegate = self; + + + + + self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cc"]]; + +// [self setupNavigationBar]; + self.cityLabel.text = self.city.name; + self.rateLabel.text = [NSString stringWithFormat:@"%@", self.city.rate]; + self.impressionLabel.text = self.city.impression; + // self.imageView.image = [UIImage imageWithData:self.city.photo]; + +} + + +#pragma mark + +- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { + return 1; +} + + +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.city.photos.count; +} + +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + + static NSString * const reuseIdentifier = @"Cell"; + PhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; + + Photo *photo = self.city.photos[indexPath.item]; + cell.imageView.image = [UIImage imageWithData:photo.imageData]; + + + return cell; +} + +@end diff --git a/InControl/InControl/FlappyGame.h b/InControl/InControl/FlappyGame.h new file mode 100644 index 0000000..afa633b --- /dev/null +++ b/InControl/InControl/FlappyGame.h @@ -0,0 +1,41 @@ +// +// FlappyGame.h +// InControl +// +// Created by Diana Elezaj on 10/15/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +int BirdFlight; +int RandomTopTunnelPosition; +int RandomBottomTunnelPosition; +int ScoreNumber; +NSInteger HighScoreNumberLabel; + + +@interface FlappyGame : UIViewController + +{ +IBOutlet UIImageView *Bird; +IBOutlet UIButton *StartGame; +IBOutlet UIImageView *TunnelTop; +IBOutlet UIImageView *TunnelBottom; +IBOutlet UIImageView *Top; +IBOutlet UIImageView *Bottom; +IBOutlet UIButton *Exit; +IBOutlet UILabel *ScoreLabel; + +NSTimer *BirdMovement; +NSTimer *TunnelMovement; +} + +-(IBAction)StartGame:(id)sender; +-(void)BirdMoving; +-(void)TunnelMoving; +-(void)PlaceTunnels; +-(void)Score; +-(void)GameOver; + +@end diff --git a/InControl/InControl/FlappyGame.m b/InControl/InControl/FlappyGame.m new file mode 100644 index 0000000..dd2e18e --- /dev/null +++ b/InControl/InControl/FlappyGame.m @@ -0,0 +1,170 @@ +// +// FlappyGame.m +// InControl +// +// Created by Diana Elezaj on 10/15/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "FlappyGame.h" + +@interface FlappyGame () + +@end + +@implementation FlappyGame + + + +-(void)GameOver{ + + if (ScoreNumber > HighScoreNumberLabel) { + [[NSUserDefaults standardUserDefaults] setInteger:ScoreNumber forKey:@"HighScoreSaved"]; + } + + [TunnelMovement invalidate]; + [BirdMovement invalidate]; + + Exit.hidden = NO; + TunnelTop.hidden = YES; + TunnelBottom.hidden = YES; + Bird.hidden = YES; + +} + + + +-(void)Score{ + + ScoreNumber = ScoreNumber + 1; + ScoreLabel.text = [NSString stringWithFormat:@"%i", ScoreNumber]; + + +} + + +-(IBAction)StartGame:(id)sender{ + + TunnelTop.hidden = NO; + TunnelBottom.hidden = NO; + + StartGame.hidden = YES; + + BirdMovement = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(BirdMoving) userInfo:nil repeats:YES]; + + [self PlaceTunnels]; + + TunnelMovement = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(TunnelMoving) userInfo:nil repeats:YES]; + +} + + +-(void)TunnelMoving{ + + TunnelTop.center = CGPointMake(TunnelTop.center.x - 1, TunnelTop.center.y); + TunnelBottom.center = CGPointMake(TunnelBottom.center.x - 1, TunnelBottom.center.y); + + if (TunnelTop.center.x < -28) { + [self PlaceTunnels]; + } + + if (TunnelTop.center.x == 30) { + [self Score]; + } + + if (CGRectIntersectsRect(Bird.frame, TunnelTop.frame)) { + [self GameOver]; + } + + if (CGRectIntersectsRect(Bird.frame, TunnelBottom.frame)) { + [self GameOver]; + } + + if (CGRectIntersectsRect(Bird.frame, Top.frame)) { + [self GameOver]; + } + + if (CGRectIntersectsRect(Bird.frame, Bottom.frame)) { + [self GameOver]; + } + +} + + +-(void)PlaceTunnels{ + + RandomTopTunnelPosition = arc4random() %350; + RandomTopTunnelPosition = RandomTopTunnelPosition - 228; + RandomBottomTunnelPosition = RandomTopTunnelPosition + 655; + + TunnelTop.center = CGPointMake(340, RandomTopTunnelPosition); + TunnelBottom.center = CGPointMake(340, RandomBottomTunnelPosition); + + +} + + + +-(void)BirdMoving{ + + Bird.center = CGPointMake(Bird.center.x, Bird.center.y - BirdFlight); + + BirdFlight = BirdFlight - 5; + + if (BirdFlight < -15) { + BirdFlight = -15; + } + + if (BirdFlight > 0) { + Bird.image = [UIImage imageNamed:@"BirdUp.png"]; + } + + if (BirdFlight < 0) { + Bird.image = [UIImage imageNamed:@"BirdDown.png"]; + } + + + +} + + +-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ + + BirdFlight = 30; + +} + + + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + + TunnelTop.hidden = YES; + TunnelBottom.hidden = YES; + + Exit.hidden = YES; + ScoreNumber = 0; + + HighScoreNumberLabel = [[NSUserDefaults standardUserDefaults] integerForKey:@"HighScoreSaved"]; + + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +@end diff --git a/InControl/InControl/FlappyViewController.h b/InControl/InControl/FlappyViewController.h new file mode 100644 index 0000000..ee3843c --- /dev/null +++ b/InControl/InControl/FlappyViewController.h @@ -0,0 +1,18 @@ +// +// FlappyViewController.h +// InControl +// +// Created by Diana Elezaj on 10/15/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +NSInteger HighScoreNumber; + +@interface FlappyViewController : UIViewController +{ + __weak IBOutlet UILabel *HighScore; +} + +@end diff --git a/InControl/InControl/FlappyViewController.m b/InControl/InControl/FlappyViewController.m new file mode 100644 index 0000000..c69358b --- /dev/null +++ b/InControl/InControl/FlappyViewController.m @@ -0,0 +1,41 @@ +// +// FlappyViewController.m +// InControl +// +// Created by Diana Elezaj on 10/15/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "FlappyViewController.h" + +@interface FlappyViewController () + +@end + +@implementation FlappyViewController + +- (void)viewDidLoad { + [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"flappyBack"]]]; + + HighScoreNumber = [[NSUserDefaults standardUserDefaults] integerForKey:@"HighScoreSaved"]; + HighScore.text = [NSString stringWithFormat:@"High Score: %li", (long)HighScoreNumber]; + + [super viewDidLoad]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/InControl/InControl/FoodViewController.h b/InControl/InControl/FoodViewController.h new file mode 100644 index 0000000..f3effd7 --- /dev/null +++ b/InControl/InControl/FoodViewController.h @@ -0,0 +1,15 @@ +// +// FoodViewController.h +// InControl +// +// Created by Xiulan Shi on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface FoodViewController : UIViewController + +@property (nonatomic) NSString *city; + +@end diff --git a/InControl/InControl/FoodViewController.m b/InControl/InControl/FoodViewController.m new file mode 100644 index 0000000..d86295e --- /dev/null +++ b/InControl/InControl/FoodViewController.m @@ -0,0 +1,101 @@ +// +// FoodViewController.m +// InControl +// +// Created by Xiulan Shi on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "FoodViewController.h" +#import "APIManager.h" +#import "Venue.h" +#import "FoursquareAPIManager.h" +#import + +@interface FoodViewController () +< +UITableViewDataSource, +UITableViewDelegate +> + +@property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (nonatomic) NSMutableArray *searchResults; + +@end + +@implementation FoodViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.tableView.dataSource = self; + self.tableView.delegate = self; + + [self fetchFoursquareVenues]; + +} + + +- (void)fetchFoursquareVenues { + [FoursquareAPIManager fetchResultsWithSearchTerm:@"food" location:self.city callbackBlock:^(id json){ + NSArray *results = json[@"response"][@"venues"]; + + self.searchResults =[[NSMutableArray alloc] init]; + + for (NSDictionary *result in results) { + + NSString *name = result[@"name"]; + NSString *venueID = result[@"id"]; + NSString *address = result[@"location"][@"address"]; + NSString *city = result[@"location"][@"city"]; + NSString *state = result[@"location"][@"state"]; + NSString *postCode = result[@"location"][@"postalCode"]; + + + Venue *venueObject = [[Venue alloc] init]; + venueObject.name = name; + venueObject.address = [NSString stringWithFormat:@"%@, %@, %@ %@", address, city, state, postCode]; + venueObject.venueID = venueID; + + [venueObject fetchPhotosWithCallbackBlock:nil]; + + [self.searchResults addObject:venueObject]; + + } + + [self.tableView reloadData]; + + }]; +} + + +# pragma mark - tableView delegate methods + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ + return self.searchResults.count; +} + +-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FoodCellIdentifier" forIndexPath:indexPath]; + Venue *result = [self.searchResults objectAtIndex:indexPath.row]; + + result.photoUpdateListener = ^{ + [cell.imageView sd_setImageWithURL:result.photoURL]; + NSLog(@"result.photoURL %@",result.photoURL); + }; + + [cell.imageView sd_setImageWithURL:result.photoURL placeholderImage:[UIImage imageNamed:@"foodimg"]]; + if (cell.imageView.image == nil) { + cell.imageView.image = [UIImage imageNamed:@"foodimg"]; + } + + cell.textLabel.text = result.name; + cell.detailTextLabel.text = result.address; + + return cell; +} + +@end diff --git a/InControl/InControl/FoursquareAPIManager.h b/InControl/InControl/FoursquareAPIManager.h new file mode 100644 index 0000000..1f32e60 --- /dev/null +++ b/InControl/InControl/FoursquareAPIManager.h @@ -0,0 +1,20 @@ +// +// FoursquareAPIManager.h +// InControl +// +// Created by Xiulan Shi on 10/18/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import "Venue.h" + +@interface FoursquareAPIManager : NSObject + ++ (void)fetchResultsWithSearchTerm:(NSString*)searchTerm location:(NSString*)location + callbackBlock:(void(^)(id response))block; + ++ (void)fetchPhotosForVenue:(Venue *)venue callbackBlock:(void(^)(id response))block; + + +@end diff --git a/InControl/InControl/FoursquareAPIManager.m b/InControl/InControl/FoursquareAPIManager.m new file mode 100644 index 0000000..8e016d0 --- /dev/null +++ b/InControl/InControl/FoursquareAPIManager.m @@ -0,0 +1,51 @@ +// +// FoursquareAPIManager.m +// InControl +// +// Created by Xiulan Shi on 10/18/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "FoursquareAPIManager.h" +#import "APIManager.h" + +@implementation FoursquareAPIManager + ++ (void)fetchResultsWithSearchTerm:(NSString*)searchTerm + location:(NSString*)location + callbackBlock:(void(^)(id response))callbackBlock { + + NSString *urlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/search?near=%@&query=%@&client_id=SVBBDTUHT5WOBDQ5NINYVTLNDNTHGD0XGRRE0LMB304VMWG1&client_secret=ZHPO4GOAGH3YSPQNQZAYC13YJ420Q2IPXAI0CRHQ0I3SB0HL&v=20151015", location, searchTerm]; + + NSString *encodedString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + NSURL *url = [NSURL URLWithString:encodedString]; + + [APIManager GETRequestWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + + if (data != nil) { + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + callbackBlock(json); + } + }]; +} + ++ (void)fetchPhotosForVenue:(Venue *)venue + callbackBlock:(void(^)(id response))callbackBlock { + + NSString *photoUrlString = [NSString stringWithFormat:@"https://api.foursquare.com/v2/venues/%@/photos?oauth_token=JJS3ZNRESBNYJF5OPZO3O4H2GYE5JBWSGTTZEVAKHCPALCLW&v=20151015", venue.venueID]; + NSString *encodedPhotoString = [photoUrlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + NSURL *photoUrl = [NSURL URLWithString:encodedPhotoString]; + + [APIManager GETRequestWithURL:photoUrl completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + + if (data != nil) { + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + callbackBlock(json); + } + }]; +} + + +@end diff --git a/InControl/InControl/GameBack.png b/InControl/InControl/GameBack.png new file mode 100644 index 0000000..77fc206 Binary files /dev/null and b/InControl/InControl/GameBack.png differ diff --git a/InControl/InControl/GamesViewController.h b/InControl/InControl/GamesViewController.h new file mode 100644 index 0000000..512c529 --- /dev/null +++ b/InControl/InControl/GamesViewController.h @@ -0,0 +1,13 @@ +// +// GamesViewController.h +// InControl +// +// Created by Diana Elezaj on 10/14/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface GamesViewController : UIViewController + +@end diff --git a/InControl/InControl/GamesViewController.m b/InControl/InControl/GamesViewController.m new file mode 100644 index 0000000..8131081 --- /dev/null +++ b/InControl/InControl/GamesViewController.m @@ -0,0 +1,38 @@ +// +// GamesViewController.m +// InControl +// +// Created by Diana Elezaj on 10/14/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "GamesViewController.h" + +@interface GamesViewController () + +@end + +@implementation GamesViewController + +- (void)viewDidLoad { + [super viewDidLoad]; +[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"flappyBack"]]]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/InControl/InControl/HotelViewController.h b/InControl/InControl/HotelViewController.h new file mode 100644 index 0000000..b31729d --- /dev/null +++ b/InControl/InControl/HotelViewController.h @@ -0,0 +1,15 @@ +// +// HotelViewController.h +// InControl +// +// Created by Xiulan Shi on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface HotelViewController : UIViewController + +@property NSString *city; + +@end diff --git a/InControl/InControl/HotelViewController.m b/InControl/InControl/HotelViewController.m new file mode 100644 index 0000000..3f7e4f1 --- /dev/null +++ b/InControl/InControl/HotelViewController.m @@ -0,0 +1,99 @@ +// +// HotelViewController.m +// InControl +// +// Created by Xiulan Shi on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "HotelViewController.h" +#import "APIManager.h" +#import "Venue.h" +#import "FoursquareAPIManager.h" +#import + +@interface HotelViewController () +< +UITableViewDataSource, +UITableViewDelegate +> + +@property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (nonatomic) NSMutableArray *searchResults; +@end + +@implementation HotelViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.tableView.dataSource = self; + self.tableView.delegate = self; + + [self fetchFoursquareVenues]; + +} + + +- (void)fetchFoursquareVenues { + [FoursquareAPIManager fetchResultsWithSearchTerm:@"hotel" location:self.city callbackBlock:^(id json){ + NSArray *results = json[@"response"][@"venues"]; + + self.searchResults =[[NSMutableArray alloc] init]; + + for (NSDictionary *result in results) { + + NSString *name = result[@"name"]; + NSString *venueID = result[@"id"]; + NSString *address = result[@"location"][@"address"]; + NSString *city = result[@"location"][@"city"]; + NSString *state = result[@"location"][@"state"]; + NSString *postCode = result[@"location"][@"postalCode"]; + + + Venue *venueObject = [[Venue alloc] init]; + venueObject.name = name; + venueObject.address = [NSString stringWithFormat:@"%@, %@, %@ %@", address, city, state, postCode]; + venueObject.venueID = venueID; + + [venueObject fetchPhotosWithCallbackBlock:nil]; + + [self.searchResults addObject:venueObject]; + + } + + [self.tableView reloadData]; + + }]; +} + + +# pragma mark - tableView delegate methods + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ + return self.searchResults.count; +} + +-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HotelCellIdentifier" forIndexPath:indexPath]; + Venue *result = [self.searchResults objectAtIndex:indexPath.row]; + + result.photoUpdateListener = ^{ + [cell.imageView sd_setImageWithURL:result.photoURL]; + }; + + [cell.imageView sd_setImageWithURL:result.photoURL placeholderImage:[UIImage imageNamed:@"hotelimg"]]; + if (cell.imageView.image == nil) { + cell.imageView.image = [UIImage imageNamed:@"hotelimg"]; + } + + cell.textLabel.text = result.name; + cell.detailTextLabel.text = result.address; + + return cell; +} + +@end diff --git a/InControl/InControl/ImageTableViewController.h b/InControl/InControl/ImageTableViewController.h new file mode 100644 index 0000000..afcda6e --- /dev/null +++ b/InControl/InControl/ImageTableViewController.h @@ -0,0 +1,15 @@ +// +// ImageTableViewController.h +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface ImageTableViewController : UITableViewController + +@property (nonatomic) NSString *city; + +@end diff --git a/InControl/InControl/ImageTableViewController.m b/InControl/InControl/ImageTableViewController.m new file mode 100644 index 0000000..8807995 --- /dev/null +++ b/InControl/InControl/ImageTableViewController.m @@ -0,0 +1,144 @@ +// +// ImageTableViewController.m +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "ImageTableViewController.h" +#import "APIManager.h" +#import "CustomTableViewCell.h" + + +@interface ImageTableViewController () + +@property (nonatomic) NSDictionary * imageData; + +@end + +@implementation ImageTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.tableView.dataSource = self; + self.navigationItem.title = @"Flickr"; + + [self makeApPIRequestWithNewTerm:self.city callbackBlock:^{ + [self.tableView reloadData]; + }]; +} + + + +- (void)makeApPIRequestWithNewTerm:(NSString *)searchTerm + callbackBlock:(void(^)())block { + + NSString *imageURL = [NSString stringWithFormat:@"https://api.flickr.com/services/rest/?&method=flickr.photos.search&api_key=4ef2fe2affcdd6e13218f5ddd0e2500d&tags=%@&per_page=100&format=json&nojsoncallback=1", searchTerm]; + + + + NSString *encodedString = [imageURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + NSURL *url = [NSURL URLWithString:encodedString]; + + NSLog(@"%@", url); + + [APIManager GETRequestWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + self.imageData = [json objectForKey:@"photos"]; + + [self.tableView reloadData]; + }]; +} + +- (void) viewWillAppear:(BOOL)animated +{ + + [self.navigationController setNavigationBarHidden:NO animated:animated]; + +} + + +- (void) viewWillDisappear:(BOOL)animated +{ + [self.navigationController setNavigationBarHidden:YES animated:animated]; + +} + + + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.imageData.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier" forIndexPath:indexPath]; + + //NSDictionary *currentInstagramItem = self.imageData[indexPath.row]; + NSArray *photos = [self.imageData objectForKey:@"photo"]; + NSDictionary *photo = photos[indexPath.row]; + + NSString *imageURL = [NSString stringWithFormat:@"https://farm%@.staticflickr.com/%@/%@_%@.jpg",[photo objectForKey:@"farm"] ,[photo objectForKey:@"server"], [photo objectForKey:@"id"], [photo objectForKey:@"secret"]]; +// cell.textLabel.text = imageURL; + + NSURL *url = [NSURL URLWithString:imageURL]; + NSData *pictureData = [NSData dataWithContentsOfURL:url]; + UIImage *picture = [UIImage imageWithData:pictureData]; + cell.customImage.image = picture; + + NSLog(@"%@", picture); + + return cell; +} + + +/* + // Override to support conditional editing of the table view. + - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; + } + */ + +/* + // Override to support editing the table view. + - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } + } + */ + +/* + // Override to support rearranging the table view. + - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { + } + */ + +/* + // Override to support conditional rearranging of the table view. + - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; + } + */ + +/* + #pragma mark - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ + +@end diff --git a/InControl/InControl/InControl.xcdatamodeld/.xccurrentversion b/InControl/InControl/InControl.xcdatamodeld/.xccurrentversion new file mode 100644 index 0000000..dc9888d --- /dev/null +++ b/InControl/InControl/InControl.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + InControl.xcdatamodel + + diff --git a/InControl/InControl/InControl.xcdatamodeld/InControl.xcdatamodel/contents b/InControl/InControl/InControl.xcdatamodeld/InControl.xcdatamodel/contents new file mode 100644 index 0000000..ea89feb --- /dev/null +++ b/InControl/InControl/InControl.xcdatamodeld/InControl.xcdatamodel/contents @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/InControl/InControl/Info.plist b/InControl/InControl/Info.plist new file mode 100644 index 0000000..65ca776 --- /dev/null +++ b/InControl/InControl/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/InControl/InControl/InfoPlist.strings b/InControl/InControl/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/InControl/InControl/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/InControl/InControl/InstaTableViewController.h b/InControl/InControl/InstaTableViewController.h new file mode 100644 index 0000000..4c184f0 --- /dev/null +++ b/InControl/InControl/InstaTableViewController.h @@ -0,0 +1,15 @@ +// +// InstaTableViewController.h +// InControl +// +// Created by Diana Elezaj on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface InstaTableViewController : UITableViewController +@property (nonatomic) NSMutableArray *searchResults; +@property (nonatomic) NSString *city; + +@end diff --git a/InControl/InControl/InstaTableViewController.m b/InControl/InControl/InstaTableViewController.m new file mode 100644 index 0000000..67467fa --- /dev/null +++ b/InControl/InControl/InstaTableViewController.m @@ -0,0 +1,165 @@ +// +// InstaTableViewController.m +// InControl +// +// Created by Diana Elezaj on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "InstaTableViewController.h" +#import +#import +#import "APIManager.h" +#import "InstagramPost.h" +#import "InstagramPostTableViewCell.h" + + + +@interface InstaTableViewController () +@property (nonatomic) NSMutableArray *detailsResults; + +@end + +@implementation InstaTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.navigationItem.title = @"Insta"; + + [[self navigationController] setNavigationBarHidden:NO animated:YES]; + + + + + [self fetchInstagramData]; + NSLog(@"detailsss"); + + // set up pull to refresh + self.refreshControl = [[UIRefreshControl alloc] init]; + [self.refreshControl addTarget:self action:@selector(pulledToRefresh:) forControlEvents:UIControlEventValueChanged]; + + // tell the table view to auto adjust the height of each cell + self.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableView.estimatedRowHeight = 12.0; + + // grab the nib from the main bundle + UINib *nib = [UINib nibWithNibName:@"InstagramPostTableViewCell" bundle:nil]; + + // register the nib for the cell identifer + [self.tableView registerNib:nib forCellReuseIdentifier:@"InstagramCellIdentifier"]; + + + + +} + +-(void) viewWillAppear:(BOOL)animated { + [[self navigationController] setNavigationBarHidden:NO animated:YES]; +} + + +- (IBAction)refreshTapped:(id)sender { + [self fetchInstagramData]; +} + + +- (void)fetchInstagramData { + + NSString *cityName_City = [NSString stringWithFormat:@"%@city",self.city]; + NSLog(@"cityName_City %@", cityName_City); + + // create an instagram url + NSString *urlString = [NSString stringWithFormat:@"https://api.instagram.com/v1/tags/%@/media/recent?client_id=a2c55d5958864f32a2b1af4f8b01c8db", cityName_City]; + + + + + + + + AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; + + [manager GET:urlString + parameters:nil + success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) { + NSArray *results = responseObject[@"data"]; + + // reset my array + self.detailsResults = [[NSMutableArray alloc] init]; + + // loop through all json posts + for (NSDictionary *result in results) { + + // create new post from json + InstagramPost *post = [[InstagramPost alloc] initWithJSON:result]; + + // add post to array + [self.detailsResults addObject:post]; + } + + [self.tableView reloadData]; + + } failure:^(AFHTTPRequestOperation * _Nonnull operation, NSError * _Nonnull error) { + NSLog(@"%@", error); + + }]; + +} + + +- (void)pulledToRefresh:(UIRefreshControl *)sender { + [self fetchInstagramData]; + [sender endRefreshing]; + + // sender == self.refreshControl +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +#pragma mark - Table view data source + + - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return self.detailsResults.count; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return 1; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + InstagramPostTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"InstagramCellIdentifier" forIndexPath:indexPath]; + + InstagramPost *post = self.detailsResults[indexPath.section]; + + cell.likeCountLabel.text = [NSString stringWithFormat:@"%ld likes", post.likeCount]; + +// cell.tagCountLabel.text = [NSString stringWithFormat:@"Tags: %ld", post.tags.count]; + + cell.captionLabel.text = post.caption[@"text"]; + + // NSData *data = [NSData dataWithContentsOfURL:url]; + // UIImage *image = [UIImage imageWithData:data]; + // + // cell.userMediaImageView.image = image; + + NSURL *url = [NSURL URLWithString:post.imageURL]; + + [cell.userMediaImageView sd_setImageWithURL:url completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + cell.userMediaImageView.image = image; + }]; + + return cell; +} + + + + + + +@end + diff --git a/InControl/InControl/InstagramPost.h b/InControl/InControl/InstagramPost.h new file mode 100644 index 0000000..2ba7832 --- /dev/null +++ b/InControl/InControl/InstagramPost.h @@ -0,0 +1,25 @@ +// +// InstagramPost.h +// TalkinToTheNet +// +// Created by Diana Elezaj on 9/26/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface InstagramPost : NSObject + +@property (nonatomic) NSArray *tags; +@property (nonatomic) NSInteger commentCount; +@property (nonatomic) NSInteger likeCount; +@property (nonatomic) NSString *username; +@property (nonatomic) NSString *fullName; +@property (nonatomic) NSDictionary *caption; +@property (nonatomic) NSString *imageURL; +@property (nonatomic) NSString *avatarImageURL; + +- (instancetype)initWithJSON:(NSDictionary *)json; + + +@end diff --git a/InControl/InControl/InstagramPost.m b/InControl/InControl/InstagramPost.m new file mode 100644 index 0000000..4c03412 --- /dev/null +++ b/InControl/InControl/InstagramPost.m @@ -0,0 +1,31 @@ +// +// InstagramPost.m +// TalkinToTheNet +// +// Created by Diana Elezaj on 9/26/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "InstagramPost.h" + +@implementation InstagramPost + +- (instancetype)initWithJSON:(NSDictionary *)json { + + if (self = [super init]) { + + self.tags = json[@"tags"]; + self.commentCount = [json[@"comments"][@"count"] integerValue]; + self.likeCount = [json[@"likes"][@"count"] integerValue]; + self.caption = json[@"caption"]; + self.username = json[@"user"][@"username"]; + self.fullName = json[@"user"][@"full_name"]; + self.imageURL = json[@"images"][@"standard_resolution"][@"url"]; + + self.avatarImageURL = json[@"user"][@"profile_picture"]; + + return self; + } + return nil; +} +@end diff --git a/InControl/InControl/InstagramPostTableViewCell.h b/InControl/InControl/InstagramPostTableViewCell.h new file mode 100644 index 0000000..ec9f93f --- /dev/null +++ b/InControl/InControl/InstagramPostTableViewCell.h @@ -0,0 +1,21 @@ +// +// InstagramPostTableViewCell.h +// TalkinToTheNet +// +// Created by Diana Elezaj on 9/26/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface InstagramPostTableViewCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UILabel *captionLabel; + +@property (weak, nonatomic) IBOutlet UILabel *usernameLabel; +@property (weak, nonatomic) IBOutlet UILabel *likeCountLabel; +@property (weak, nonatomic) IBOutlet UILabel *tagCountLabel; +@property (weak, nonatomic) IBOutlet UIImageView *userMediaImageView; + + +@end diff --git a/InControl/InControl/InstagramPostTableViewCell.m b/InControl/InControl/InstagramPostTableViewCell.m new file mode 100644 index 0000000..0e6420e --- /dev/null +++ b/InControl/InControl/InstagramPostTableViewCell.m @@ -0,0 +1,23 @@ +// +// InstagramPostTableViewCell.m +// TalkinToTheNet +// +// Created by Diana Elezaj on 9/26/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "InstagramPostTableViewCell.h" + +@implementation InstagramPostTableViewCell + +- (void)awakeFromNib { + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/InControl/InControl/InstagramPostTableViewCell.xib b/InControl/InControl/InstagramPostTableViewCell.xib new file mode 100644 index 0000000..54ec912 --- /dev/null +++ b/InControl/InControl/InstagramPostTableViewCell.xib @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/InControl/InControl/MeetupTableViewCell.h b/InControl/InControl/MeetupTableViewCell.h new file mode 100644 index 0000000..10ee321 --- /dev/null +++ b/InControl/InControl/MeetupTableViewCell.h @@ -0,0 +1,18 @@ +// +// MeetupTableViewCell.h +// InControl +// +// Created by Artur Lan on 10/18/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface MeetupTableViewCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UILabel *nameLabel; +@property (weak, nonatomic) IBOutlet UILabel *whoLabel; +@property (weak, nonatomic) IBOutlet UILabel *cityAndCountryLabel; +@property (weak, nonatomic) IBOutlet UILabel *descriptionMeetup; + +@end diff --git a/InControl/InControl/MeetupTableViewCell.m b/InControl/InControl/MeetupTableViewCell.m new file mode 100644 index 0000000..ea1798d --- /dev/null +++ b/InControl/InControl/MeetupTableViewCell.m @@ -0,0 +1,23 @@ +// +// MeetupTableViewCell.m +// InControl +// +// Created by Artur Lan on 10/18/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "MeetupTableViewCell.h" + +@implementation MeetupTableViewCell + +- (void)awakeFromNib { + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/InControl/InControl/MeetupTableViewController.h b/InControl/InControl/MeetupTableViewController.h new file mode 100644 index 0000000..002d9da --- /dev/null +++ b/InControl/InControl/MeetupTableViewController.h @@ -0,0 +1,17 @@ +// +// MeetupTableViewController.h +// InControl +// +// Created by Artur Lan on 10/18/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface MeetupTableViewController : UITableViewController + +@property (nonatomic) NSString *city; +@property (nonatomic) NSInteger cityLng; +@property (nonatomic) NSInteger cityLat; + +@end diff --git a/InControl/InControl/MeetupTableViewController.m b/InControl/InControl/MeetupTableViewController.m new file mode 100644 index 0000000..85544ce --- /dev/null +++ b/InControl/InControl/MeetupTableViewController.m @@ -0,0 +1,159 @@ +// +// MeetupTableViewController.m +// InControl +// +// Created by Artur Lan on 10/18/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "MeetupTableViewController.h" +#import "APIManager.h" +#import "MeetupTableViewCell.h" +#import +#import "FoursquareAPIManager.h" + + + +@interface MeetupTableViewController () + +@property (nonatomic) NSMutableArray *meetupData; +@property (nonatomic) CLLocationCoordinate2D center; +@property (nonatomic) NSString *lat; +@property (nonatomic) NSString *lng; + +@end + +@implementation MeetupTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.navigationItem.title = @"Meetup"; + + + [self getLocationFromAddressString:self.city withCompletionHandler:^{ + [self makeApPIRequestWithNewTerm:self.city callbackBlock:^{ + [self.tableView reloadData]; + }]; + }]; +} + +- (void)makeApPIRequestWithNewTerm:(NSString *)searchTerm + callbackBlock:(void(^)())block { + + + NSString *meetupURL = [NSString stringWithFormat:@"https://api.meetup.com/2/groups?lat=%@&lon=%@&page=20&key=1f5718c16a7fb3a5452f45193232",self.lat,self.lng]; + + NSString *encodedString = [meetupURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + + NSURL *url = [NSURL URLWithString:encodedString]; + + NSLog(@"%@", url); + + [APIManager GETRequestWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + self.meetupData = [json objectForKey:@"results"]; + + NSLog(@"%@", json); + + + [self.tableView reloadData]; + }]; +} + +- (void) viewWillAppear:(BOOL)animated +{ + + [self.navigationController setNavigationBarHidden:NO animated:animated]; + +} + + +- (void) viewWillDisappear:(BOOL)animated +{ + [self.navigationController setNavigationBarHidden:YES animated:animated]; + +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.meetupData.count; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + MeetupTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; + + NSDictionary *eachOrganizer = self.meetupData[indexPath.row]; + NSString *name = [eachOrganizer objectForKey:@"name"]; + NSString *who = [eachOrganizer objectForKey:@"who"]; + NSString *cityCountry = [NSString stringWithFormat:@"%@,%@", [eachOrganizer objectForKey:@"city"], [eachOrganizer objectForKey:@"country"]]; + double rate = [[eachOrganizer objectForKey:@"rating"] doubleValue]; + NSString *descriptionMeetup = [NSString stringWithFormat:@"Rate: %0.2f", rate]; + + cell.nameLabel.text = name; + cell.whoLabel.text = who; + cell.descriptionMeetup.text = descriptionMeetup; + cell.cityAndCountryLabel.text = cityCountry; + + NSLog(@"%@", self.city); + + return cell; +} + +- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { + NSDictionary *eachOrganizer = self.meetupData[indexPath.row]; + NSString *hyperlinkUrl = [eachOrganizer objectForKey:@"link"]; + NSURL *url = [NSURL URLWithString:hyperlinkUrl]; + + + [[UIApplication sharedApplication]openURL:url]; + +} + +-(void) getLocationFromAddressString: (NSString*) addressStr withCompletionHandler:(void(^)())completion { + + + double latitude = 0, longitude = 0; + NSString *esc_addr = [addressStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + NSString *req = [NSString stringWithFormat:@"http://maps.google.com/maps/api/geocode/json?sensor=false&address=%@", esc_addr]; + NSString *result = [NSString stringWithContentsOfURL:[NSURL URLWithString:req] encoding:NSUTF8StringEncoding error:NULL]; + + if (result) { + NSScanner *scanner = [NSScanner scannerWithString:result]; + if ([scanner scanUpToString:@"\"lat\" :" intoString:nil] && [scanner scanString:@"\"lat\" :" intoString:nil]) { + [scanner scanDouble:&latitude]; + if ([scanner scanUpToString:@"\"lng\" :" intoString:nil] && [scanner scanString:@"\"lng\" :" intoString:nil]) { + [scanner scanDouble:&longitude]; + } + } + } + CLLocationCoordinate2D center; + center.latitude=latitude; + center.longitude = longitude; + + + NSString *latitudeString = [NSString stringWithFormat:@"%f", center.latitude]; + NSString *longitudeString = [NSString stringWithFormat:@"%f", center.longitude]; + + self.lat = latitudeString; + self.lng = longitudeString; + + NSLog(@"View Controller get Location Logitute : %f",center.latitude); + NSLog(@"View Controller get Location Latitute : %f",center.longitude); + + completion(); +} + + +@end diff --git a/InControl/InControl/Photo+CoreDataProperties.h b/InControl/InControl/Photo+CoreDataProperties.h new file mode 100644 index 0000000..318e885 --- /dev/null +++ b/InControl/InControl/Photo+CoreDataProperties.h @@ -0,0 +1,24 @@ +// +// Photo+CoreDataProperties.h +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// +// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu +// to delete and recreate this implementation file for your updated model. +// + +#import "Photo.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface Photo (CoreDataProperties) + +@property (nullable, nonatomic, retain) NSData *imageData; +@property (nullable, nonatomic, retain) NSDate *createdAt; +@property (nullable, nonatomic, retain) City *city; + +@end + +NS_ASSUME_NONNULL_END diff --git a/InControl/InControl/Photo+CoreDataProperties.m b/InControl/InControl/Photo+CoreDataProperties.m new file mode 100644 index 0000000..491b116 --- /dev/null +++ b/InControl/InControl/Photo+CoreDataProperties.m @@ -0,0 +1,20 @@ +// +// Photo+CoreDataProperties.m +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// +// Choose "Create NSManagedObject Subclass…" from the Core Data editor menu +// to delete and recreate this implementation file for your updated model. +// + +#import "Photo+CoreDataProperties.h" + +@implementation Photo (CoreDataProperties) + +@dynamic imageData; +@dynamic createdAt; +@dynamic city; + +@end diff --git a/InControl/InControl/Photo.h b/InControl/InControl/Photo.h new file mode 100644 index 0000000..ae80b0f --- /dev/null +++ b/InControl/InControl/Photo.h @@ -0,0 +1,24 @@ +// +// Photo.h +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import + +@class City; + +NS_ASSUME_NONNULL_BEGIN + +@interface Photo : NSManagedObject + +// Insert code here to declare functionality of your managed object subclass + +@end + +NS_ASSUME_NONNULL_END + +#import "Photo+CoreDataProperties.h" diff --git a/InControl/InControl/Photo.m b/InControl/InControl/Photo.m new file mode 100644 index 0000000..fb6f055 --- /dev/null +++ b/InControl/InControl/Photo.m @@ -0,0 +1,16 @@ +// +// Photo.m +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "Photo.h" +#import "City.h" + +@implementation Photo + +// Insert code here to add functionality to your managed object subclass + +@end diff --git a/InControl/InControl/PhotoCell.h b/InControl/InControl/PhotoCell.h new file mode 100644 index 0000000..fb627c8 --- /dev/null +++ b/InControl/InControl/PhotoCell.h @@ -0,0 +1,14 @@ +// +// PhotoCell.h +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface PhotoCell : UICollectionViewCell +@property (weak, nonatomic) IBOutlet UIImageView *imageView; + +@end diff --git a/InControl/InControl/PhotoCell.m b/InControl/InControl/PhotoCell.m new file mode 100644 index 0000000..848b3a0 --- /dev/null +++ b/InControl/InControl/PhotoCell.m @@ -0,0 +1,13 @@ +// +// PhotoCell.m +// InControl +// +// Created by Xiulan Shi on 10/21/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "PhotoCell.h" + +@implementation PhotoCell + +@end diff --git a/InControl/InControl/Profile_image.png b/InControl/InControl/Profile_image.png new file mode 100644 index 0000000..6b7e3cb Binary files /dev/null and b/InControl/InControl/Profile_image.png differ diff --git a/InControl/InControl/Profile_image@2x.png b/InControl/InControl/Profile_image@2x.png new file mode 100644 index 0000000..e472ec8 Binary files /dev/null and b/InControl/InControl/Profile_image@2x.png differ diff --git a/InControl/InControl/Tunnel.png b/InControl/InControl/Tunnel.png new file mode 100644 index 0000000..73f55b4 Binary files /dev/null and b/InControl/InControl/Tunnel.png differ diff --git a/InControl/InControl/Venue.h b/InControl/InControl/Venue.h new file mode 100644 index 0000000..9e9c79c --- /dev/null +++ b/InControl/InControl/Venue.h @@ -0,0 +1,25 @@ +// +// Venue.h +// InControl +// +// Created by Xiulan Shi on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface Venue : NSObject + +@property (nonatomic) NSString *name; +@property (nonatomic) NSString *address; +@property (nonatomic) NSNumber *phone; +@property (nonatomic) NSURL *photoURL; + +@property (nonatomic) NSString *latlng; +@property (nonatomic) NSString *venueID; +@property (nonatomic, copy) void (^photoUpdateListener)(); + +- (void)fetchPhotosWithCallbackBlock:(void(^)())callbackBlock; + + +@end diff --git a/InControl/InControl/Venue.m b/InControl/InControl/Venue.m new file mode 100644 index 0000000..93d36b4 --- /dev/null +++ b/InControl/InControl/Venue.m @@ -0,0 +1,35 @@ +// +// Venue.m +// InControl +// +// Created by Xiulan Shi on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "Venue.h" +#import "FoursquareAPIManager.h" + +@implementation Venue + +- (void)fetchPhotosWithCallbackBlock:(void(^)())callbackBlock { + + [FoursquareAPIManager fetchPhotosForVenue:self callbackBlock:^(id response) { + NSDictionary *photoData = [response[@"response"][@"photos"][@"items"] firstObject]; + NSString *size = [NSString stringWithFormat:@"%@x%@", photoData[@"width"], photoData[@"height"]]; + NSString *photoURL = [NSString stringWithFormat:@"%@%@%@", photoData[@"prefix"], size, photoData[@"suffix"]]; + + self.photoURL = [NSURL URLWithString:photoURL]; + + if (self.photoUpdateListener) { + self.photoUpdateListener(); + } + + if (callbackBlock) { + callbackBlock(); + } + }]; +} + + + +@end diff --git a/InControl/InControl/VideoViewController.h b/InControl/InControl/VideoViewController.h new file mode 100644 index 0000000..2800255 --- /dev/null +++ b/InControl/InControl/VideoViewController.h @@ -0,0 +1,14 @@ +// +// VideoViewController.h +// InControl +// +// Created by Diana Elezaj on 10/12/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import "ViewController.h" +@interface VideoViewController : UIViewController +@property (nonatomic) NSString *city; + +@end diff --git a/InControl/InControl/VideoViewController.m b/InControl/InControl/VideoViewController.m new file mode 100644 index 0000000..39858a6 --- /dev/null +++ b/InControl/InControl/VideoViewController.m @@ -0,0 +1,141 @@ +// +// VideoViewController.m +// InControl +// +// Created by Diana Elezaj on 10/12/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "VideoViewController.h" +#import +#import "APIManager.h" +#import "ViewController.h" +#import "Youtube.h" +#import + +@interface VideoViewController () + +@property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (nonatomic) NSMutableArray *searchedVideos; + + +//comment +@end + +@implementation VideoViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [super viewDidLoad]; + [self.tableView setDataSource:self]; + [self.tableView setDelegate:self]; + + NSLog(@"you searched for %@", self.city); + [self printResults]; + + +} + + +-(void)printResults { + NSString * query = @""; + query = [ query stringByAppendingString: self.city]; + + [self makeFSAPIRequestWithSearchTerm:query callbackBlock:^{ + + [self.tableView reloadData]; + + + }]; + +} + + +- (void) makeFSAPIRequestWithSearchTerm:(NSString*) searchTerm callbackBlock:(void(^)())block{ + NSLog(@"%@", searchTerm); + + + //api key AIzaSyDt8qmOMAZJoW3F_q1_BSPW8P4P1fFPduM + + + NSString *urlString = [NSString stringWithFormat:@"https://www.googleapis.com/youtube/v3/search?part=id,snippet&q=%@&maxResults=50&key=AIzaSyDt8qmOMAZJoW3F_q1_BSPW8P4P1fFPduM", searchTerm]; + + + + NSLog(@"hhhhhhh %@", urlString); + + NSString *encodedString = [urlString stringByAddingPercentEncodingWithAllowedCharacters: [NSCharacterSet URLQueryAllowedCharacterSet]]; + NSURL *url = [NSURL URLWithString:encodedString]; + + NSLog(@"hhhhhhh %@", url); + + + [APIManager GETRequestWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (data != nil) { + NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil]; + self.searchedVideos = [[NSMutableArray alloc]init]; + + NSArray *results = [json objectForKey:@"items"]; + + //NSLog(@"%@", json); + for (NSDictionary *result in results) { + + Youtube *video = [[Youtube alloc] init]; + video.videoTitle = [[result objectForKey:@"snippet"]objectForKey:@"title"]; + + video.videoDescription = [[result objectForKey:@"snippet"]objectForKey:@"description"]; + video.videoID = [[result objectForKey:@"id"] objectForKey:@"videoId"]; + video.videoImage = [[[[result objectForKey:@"snippet"]objectForKey:@"thumbnails"] objectForKey:@"medium"] objectForKey:@"url"]; + [self.searchedVideos addObject:video]; + } + block(); + } + + }]; + +} + +# pragma mark -tableView delegate methods + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ + + return self.searchedVideos.count; + +} + +-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VideoCellID" forIndexPath:indexPath]; + Youtube * video = [self.searchedVideos objectAtIndex:indexPath.row]; + + NSURL *imgURL = [NSURL URLWithString:video.videoImage]; + NSData *imageData = [NSData dataWithContentsOfURL:imgURL]; + UIImage *image = [UIImage imageWithData:imageData]; + + cell.textLabel.text = video.videoTitle; + cell.detailTextLabel.text = video.videoDescription; + cell.imageView.image = image; + + return cell; +} + + + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + NSLog(@"errorrrrr"); + Youtube *video = [self.searchedVideos objectAtIndex:indexPath.row]; + + NSString *videoString = video.videoID; + XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:videoString]; + + [self presentViewController:videoPlayerViewController animated:YES completion:^{ + + + }]; //presentMoviePlayerViewControllerAnimated:videoPlayerViewController]; + +} + +@end diff --git a/InControl/InControl/ViewController.h b/InControl/InControl/ViewController.h new file mode 100644 index 0000000..2c13b34 --- /dev/null +++ b/InControl/InControl/ViewController.h @@ -0,0 +1,20 @@ +// +// ViewController.h +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import "RNFrostedSidebar.h" +#import "VideoViewController.h" + +@interface ViewController : UIViewController + + + +@property (weak, nonatomic) IBOutlet UISearchBar *searchBar; + +@end + diff --git a/InControl/InControl/ViewController.m b/InControl/InControl/ViewController.m new file mode 100644 index 0000000..2c6c48e --- /dev/null +++ b/InControl/InControl/ViewController.m @@ -0,0 +1,271 @@ +// +// ViewController.m +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "ViewController.h" +#import "FoodViewController.h" +#import "HotelViewController.h" +#import "ImageTableViewController.h" +#import "VideoViewController.h" +#import "MeetupTableViewController.h" +#import "InstaTableViewController.h" + +@interface ViewController () + +@property (weak, nonatomic) IBOutlet UIButton *goButton; +@property (weak, nonatomic) IBOutlet UIView *budgetView; +@property (nonatomic, strong) NSMutableIndexSet *optionIndices; +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.searchBar.hidden = YES; + self.goButton.hidden = YES; + self.budgetView.hidden = YES; + + UIGraphicsBeginImageContext(self.view.frame.size); + [[UIImage imageNamed:@"newBackOk"] drawInRect:self.view.bounds]; + UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + self.view.backgroundColor = [UIColor colorWithPatternImage:image]; + + self.optionIndices = [NSMutableIndexSet indexSetWithIndex:1]; +} + + +- (IBAction)goButton:(id)sender { + [self ShowMenu]; + self.goButton.hidden = YES; + self.searchBar.hidden = YES; + [self.view endEditing:YES]; + + //save user's input + NSString *saveString = self.searchBar.text; + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [defaults setObject:saveString forKey:@"savedString"]; + [defaults synchronize]; +} + +- (IBAction)onBurger:(id)sender { + self.budgetView.hidden = YES; + [self ShowMenu]; +} + +-(void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:YES]; + + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *loadString = [defaults objectForKey:@"savedString"]; + [self.searchBar setText:loadString]; + NSLog(@"will appear search bar %@",self.searchBar.text); + +} + +-(void) ShowMenu { + + NSArray *images = @[ + [UIImage imageNamed:@"search"], + [UIImage imageNamed:@"budget"], + [UIImage imageNamed:@"food"], + [UIImage imageNamed:@"hotel"], + [UIImage imageNamed:@"image"], + [UIImage imageNamed:@"video"], + [UIImage imageNamed:@"insta"], + [UIImage imageNamed:@"meetup"], +// [UIImage imageNamed:@"star"], +// [UIImage imageNamed:@"star"], +// [UIImage imageNamed:@"star"], +// [UIImage imageNamed:@"star"], + ]; + NSArray *colors = @[ + [UIColor colorWithRed:240/255.f green:159/255.f blue:254/255.f alpha:1], + [UIColor colorWithRed:255/255.f green:137/255.f blue:167/255.f alpha:1], + [UIColor colorWithRed:126/255.f green:242/255.f blue:195/255.f alpha:1], + [UIColor colorWithRed:119/255.f green:152/255.f blue:255/255.f alpha:1], + [UIColor colorWithRed:240/255.f green:159/255.f blue:254/255.f alpha:1], + [UIColor colorWithRed:255/255.f green:137/255.f blue:167/255.f alpha:1], + [UIColor colorWithRed:126/255.f green:242/255.f blue:195/255.f alpha:1], + [UIColor colorWithRed:119/255.f green:152/255.f blue:255/255.f alpha:1], +// [UIColor colorWithRed:240/255.f green:159/255.f blue:254/255.f alpha:1], +// [UIColor colorWithRed:255/255.f green:137/255.f blue:167/255.f alpha:1], +// [UIColor colorWithRed:126/255.f green:242/255.f blue:195/255.f alpha:1], +// [UIColor colorWithRed:119/255.f green:152/255.f blue:255/255.f alpha:1], + ]; + + RNFrostedSidebar *callout = [[RNFrostedSidebar alloc] initWithImages:images selectedIndices:self.optionIndices borderColors:colors]; + // RNFrostedSidebar *callout = [[RNFrostedSidebar alloc] initWithImages:images]; + callout.delegate = self; + // callout.showFromRight = YES; + [callout show]; +} + +#pragma mark - RNFrostedSidebarDelegate + +- (void)sidebar:(RNFrostedSidebar *)sidebar didTapItemAtIndex:(NSUInteger)index { + NSLog(@"Tapped item at index %lu",(unsigned long)index); + if (index == 0) { //search Bar + + self.searchBar.hidden = NO; + self.goButton.hidden = NO; + [sidebar dismissAnimated:YES completion:nil]; + + } + + if (index == 1) { //budget + + if ([self.searchBar.text isEqualToString:@""]) { + [self EmptySearchBarAlert]; + } + else { + + NSString *url = [NSString stringWithFormat:@"http://www.budgetyourtrip.com/united-states-of-america/%@", self.searchBar.text]; + + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]]; + self.budgetView.hidden = YES; + [sidebar dismissAnimated:YES completion:nil]; + } + } + if (index == 2) { //food + + if ([self.searchBar.text isEqualToString:@""]) { + [self EmptySearchBarAlert]; + } + else { + FoodViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"FoodID"]; + vc.city = self.searchBar.text; + [self presentViewController:vc animated:YES completion:nil]; + [sidebar dismissAnimated:YES completion:^(BOOL finished) { + + }]; + } + } + if (index == 3) { //hotel + + if ([self.searchBar.text isEqualToString:@""]) { + [self EmptySearchBarAlert]; + } + else { + HotelViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"HotelID"]; + vc.city = self.searchBar.text; + [self presentViewController:vc animated:YES completion:nil]; + [sidebar dismissAnimated:YES completion:^(BOOL finished) { + }]; + } + } + if (index == 4) { //image + if ([self.searchBar.text isEqualToString:@""]) { + [self EmptySearchBarAlert]; + } + else { + ImageTableViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ImageID"]; + UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc]; + vc.city = self.searchBar.text; + + [self presentViewController:nc animated:YES completion:nil]; + + [sidebar dismissAnimated:YES completion:^(BOOL finished) { + }]; + } + } + if (index == 5) { //video + if ([self.searchBar.text isEqualToString:@""]) { + [self EmptySearchBarAlert]; + } + else { + + VideoViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VideoID"]; + + vc.city = self.searchBar.text; + + [self presentViewController:vc animated:YES completion:nil]; + + [sidebar dismissAnimated:YES completion:^(BOOL finished) { + }]; + } + } + if (index == 6) { //insta + if ([self.searchBar.text isEqualToString:@""]) { + [self EmptySearchBarAlert]; + } + else { + + InstaTableViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"InstaID"]; + UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc]; + vc.city = self.searchBar.text; + + [self presentViewController:nc animated:YES completion:nil]; + + [sidebar dismissAnimated:YES completion:^(BOOL finished) { + }]; + } + } + if (index == 7) { //meetup + if ([self.searchBar.text isEqualToString:@""]) { + [self EmptySearchBarAlert]; + } + else { + + MeetupTableViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MeetupID"]; + UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:vc]; + + vc.city = self.searchBar.text; + + [self presentViewController:nc animated:YES completion:nil]; + + [sidebar dismissAnimated:YES completion:^(BOOL finished) { + }]; + } + } + +} + +-(void) EmptySearchBarAlert { + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"NEW TRIP ? ✈️" message:@"Please tell me your next destination! 😉 " preferredStyle: UIAlertControllerStyleAlert]; + + UIAlertAction *okAction = [UIAlertAction + actionWithTitle:NSLocalizedString(@"OK", @"OK action") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) + { + NSLog(@"OK action"); + }]; + + [alert addAction:okAction]; + [self presentViewController:alert animated:YES completion:nil]; +} + + +- (IBAction)budgetViewButton:(id)sender { + self.budgetView.hidden=YES; + [self ShowMenu]; +} + + + + +- (void)sidebar:(RNFrostedSidebar *)sidebar didEnable:(BOOL)itemEnabled itemAtIndex:(NSUInteger)index { + if (itemEnabled) { + [self.optionIndices addIndex:index]; + NSLog(@"something"); + } + else { + [self.optionIndices removeIndex:index]; + NSLog(@"else"); + + } +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +@end diff --git a/InControl/InControl/VisitedTableViewCell.h b/InControl/InControl/VisitedTableViewCell.h new file mode 100644 index 0000000..5167806 --- /dev/null +++ b/InControl/InControl/VisitedTableViewCell.h @@ -0,0 +1,16 @@ +// +// VisitedTableViewCell.h +// InControl +// +// Created by Diana Elezaj on 10/20/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface VisitedTableViewCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UIImageView *cityImageView; +@property (weak, nonatomic) IBOutlet UILabel *cityNameLabel; +@property (weak, nonatomic) IBOutlet UILabel *cityRateLabel; + +@end diff --git a/InControl/InControl/VisitedTableViewCell.m b/InControl/InControl/VisitedTableViewCell.m new file mode 100644 index 0000000..94a74d2 --- /dev/null +++ b/InControl/InControl/VisitedTableViewCell.m @@ -0,0 +1,23 @@ +// +// VisitedTableViewCell.m +// InControl +// +// Created by Diana Elezaj on 10/20/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "VisitedTableViewCell.h" + +@implementation VisitedTableViewCell + +- (void)awakeFromNib { + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/InControl/InControl/VisitedViewController.h b/InControl/InControl/VisitedViewController.h new file mode 100644 index 0000000..312b2b1 --- /dev/null +++ b/InControl/InControl/VisitedViewController.h @@ -0,0 +1,13 @@ +// +// VisitedViewController.h +// InControl +// +// Created by Diana Elezaj on 10/14/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface VisitedViewController : UIViewController + +@end diff --git a/InControl/InControl/VisitedViewController.m b/InControl/InControl/VisitedViewController.m new file mode 100644 index 0000000..ae3bace --- /dev/null +++ b/InControl/InControl/VisitedViewController.m @@ -0,0 +1,158 @@ +// +// VisitedViewController.m +// InControl +// +// Created by Diana Elezaj on 10/14/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "VisitedViewController.h" +#import "AppDelegate.h" +#import +#import "City.h" +#import "DetailVisitedViewController.h" +#import "VisitedTableViewCell.h" +#import "Photo.h" +#import "Photo+CoreDataProperties.h" + +@interface VisitedViewController () +< +NSFetchedResultsControllerDelegate, +UITableViewDataSource, +UITableViewDelegate +> + +@property (nonatomic) NSFetchedResultsController *fetchedResultsController; + +@property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (nonatomic) NSSortDescriptor *sort; +@property (weak, nonatomic) IBOutlet UISegmentedControl *segmentedControl; + +@end + +@implementation VisitedViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cc"]]; + + + self.navigationController.view.backgroundColor = + [UIColor colorWithPatternImage:[UIImage imageNamed:@"cc"]]; + self.tableView.backgroundColor = [UIColor clearColor]; + + + + + [self sorting]; + self.tableView.dataSource = self; + self.tableView.delegate = self; + [self.tableView reloadData]; + +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + [self sorting]; + [self.tableView reloadData]; + +} + + +-(void) sorting { + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"City"]; + + + + + + + if (self.segmentedControl.selectedSegmentIndex == 0) { + + self.sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; + } + else if (self.segmentedControl.selectedSegmentIndex == 1) { + + self.sort = [NSSortDescriptor sortDescriptorWithKey:@"rate" ascending:NO]; + } + + + fetchRequest.sortDescriptors = @[self.sort]; + + self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:delegate.managedObjectContext sectionNameKeyPath:nil cacheName:nil]; + + self.fetchedResultsController.delegate = self; + + [self.fetchedResultsController performFetch:nil]; + [self.tableView reloadData]; + +} +- (IBAction)segmentSelected:(UISegmentedControl *)sender { + [self sorting]; + [self.tableView reloadData]; + +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + return self.fetchedResultsController.fetchedObjects.count; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + VisitedTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VisitedCellIdentifier" forIndexPath:indexPath]; + + City *city = self.fetchedResultsController.fetchedObjects[indexPath.row]; + cell.cityNameLabel.text = city.name; + cell.cityRateLabel.text = [NSString stringWithFormat:@"%@", city.rate ]; + + if (city.photos.count > 0) { + cell.cityImageView.image = [UIImage imageWithData:[city.photos[0] imageData]]; + } else { + NSLog(@"No photo!"); + } + + + return cell; +} + +- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath{ + + [self.tableView reloadData]; +} + + +#pragma mark - segue + +-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ + + if ([segue.identifier isEqualToString:@"showDetail"]){ + + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + + DetailVisitedViewController *vc = segue.destinationViewController; + + City *currentCity = self.fetchedResultsController.fetchedObjects[indexPath.row]; + + vc.city = currentCity; + } + +} + + + + + + + +@end diff --git a/InControl/InControl/WelcomeViewController.h b/InControl/InControl/WelcomeViewController.h new file mode 100644 index 0000000..f2d89d3 --- /dev/null +++ b/InControl/InControl/WelcomeViewController.h @@ -0,0 +1,33 @@ +// +// WelcomeViewController.h +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface WelcomeViewController : UIViewController + + + +@end + + +@protocol EFItemViewDelegate + +- (void)didTapped:(NSInteger)index; + +@end + + + + +@interface EFItemView : UIButton + +@property (nonatomic, weak) id delegate; + +- (instancetype)initWithNormalImage:(NSString *)normal highlightedImage:(NSString *)highlighted tag:(NSInteger)tag title:(NSString *)title; + +@end \ No newline at end of file diff --git a/InControl/InControl/WelcomeViewController.m b/InControl/InControl/WelcomeViewController.m new file mode 100644 index 0000000..5fb3966 --- /dev/null +++ b/InControl/InControl/WelcomeViewController.m @@ -0,0 +1,279 @@ +// +// WelcomeViewController.m +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "WelcomeViewController.h" +#import "ViewController.h" +#import "GamesViewController.h" +#import "VisitedViewController.h" + +#define RADIUS 100.0 +#define PHOTONUM 3 +#define TAGSTART 1000 +#define TIME 0.6 +#define SCALENUMBER 1.25 +NSInteger array [PHOTONUM][PHOTONUM] = { + + {0,1,2}, + {2,0,1}, + {1,2,0} +}; + + +@interface WelcomeViewController () + + +@property (nonatomic, assign) NSInteger currentTag; +@property (weak, nonatomic) IBOutlet UIButton *okButton; + +@end + +@implementation WelcomeViewController + +CATransform3D rotationTransform1[PHOTONUM]; + +- (void)viewDidLoad { + + [super viewDidLoad]; + + [self configViews]; +} +- (IBAction)okButtonTapped:(UIButton *)sender { + + NSLog(@"index ok %ld ",self.currentTag); + + if (self.currentTag == 1000) { //new + + + ViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"newTrip"]; + + [self presentViewController:vc animated:YES completion:nil]; + + + } + else if (self.currentTag == 1001) { //Visited + VisitedViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"visited"]; + + [self presentViewController:vc animated:YES completion:nil]; + + } + else if (self.currentTag == 1002) { //games + + GamesViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"games"]; + + [self presentViewController:vc animated:YES completion:nil]; + + + } + + +} + +#pragma mark - configViews + + +- (void)configViews { + + self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"orrr"]]; + NSArray *dataArray = @[@"neew", @"visi", @"g"]; + + //new 1000 + //visited 1001 + //games 1002 + + CGFloat centery = self.view.center.y - 50; + CGFloat centerx = self.view.center.x; + + for (NSInteger i = 0;i < PHOTONUM;i++) { + CGFloat tmpy = centery + RADIUS*cos(2.0*M_PI *i/PHOTONUM); + CGFloat tmpx = centerx - RADIUS*sin(2.0*M_PI *i/PHOTONUM); + + EFItemView *view = [[EFItemView alloc] initWithNormalImage:dataArray[i] highlightedImage:[dataArray[i] stringByAppendingFormat:@"%@", @"_hover"] tag:TAGSTART+i title:nil]; + view.frame = CGRectMake(0.0, 0.0,115,115); + view.center = CGPointMake(tmpx,tmpy); + view.delegate = self; + rotationTransform1[i] = CATransform3DIdentity; + + CGFloat Scalenumber = fabs(i - PHOTONUM/2.0)/(PHOTONUM/2.0); + if (Scalenumber < 0.3) { + Scalenumber = 0.4; + } + CATransform3D rotationTransform = CATransform3DIdentity; + rotationTransform = CATransform3DScale (rotationTransform, Scalenumber*SCALENUMBER,Scalenumber*SCALENUMBER, 1); + view.layer.transform=rotationTransform; + [self.view addSubview:view]; + + } + self.currentTag = TAGSTART; +} + +#pragma mark - EFItemViewDelegate + +- (void)didTapped:(NSInteger)index { + + + if (index == 1000){ + [self.okButton setBackgroundImage:[UIImage imageNamed:@"OkNewTrip" ] forState:UIControlStateNormal]; + + } + if (index == 1001){ + [self.okButton setBackgroundImage:[UIImage imageNamed:@"OkMyJourney" ] forState:UIControlStateNormal]; + + } + if (index == 1002){ + [self.okButton setBackgroundImage:[UIImage imageNamed:@"OkGames" ] forState:UIControlStateNormal]; + + } + + + if (self.currentTag == index) { + NSLog(@"self.currentTag %ld", (long)self.currentTag); + return; + } + + + NSInteger t = [self getIemViewTag:index]; + + for (NSInteger i = 0;itag){ + return self.currentTag - tag; + } else { + return PHOTONUM - tag + self.currentTag ; + } +} + +@end + + + + +@interface EFItemView () + +@property (nonatomic, strong) NSString *normal; +@property (nonatomic, strong) NSString *highlighted_; +@property (nonatomic, assign) NSInteger tag_; +@property (nonatomic, strong) NSString *title; + +@end + +@implementation EFItemView + +- (instancetype)initWithNormalImage:(NSString *)normal highlightedImage:(NSString *)highlighted tag:(NSInteger)tag title:(NSString *)title { + + self = [super init]; + if (self) { + _normal = normal; + _highlighted_ = highlighted; + _tag_ = tag; + _title = title; + [self configViews]; + } + return self; +} + +#pragma mark - configViews + +- (void)configViews { + + self.tag = _tag_; + [self setBackgroundImage:[UIImage imageNamed:_normal] forState:UIControlStateNormal]; + [self setBackgroundImage:[UIImage imageNamed:_highlighted_] forState:UIControlStateHighlighted]; + [self addTarget:self action:@selector(btnTapped:) forControlEvents:UIControlEventTouchUpInside]; + [self setTitle:_title forState:UIControlStateNormal]; + [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [self.titleLabel setFont:[UIFont systemFontOfSize:30.0]]; +} + +- (void)btnTapped:(UIButton *)sender { + + if (self.delegate && [self.delegate respondsToSelector:@selector(didTapped:)]) { + [self.delegate didTapped:sender.tag]; + } +} + + + + + + + +@end diff --git a/InControl/InControl/Youtube.h b/InControl/InControl/Youtube.h new file mode 100644 index 0000000..27733be --- /dev/null +++ b/InControl/InControl/Youtube.h @@ -0,0 +1,18 @@ +// +// Youtube.h +// InControl +// +// Created by Diana Elezaj on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface Youtube : NSObject + +@property (nonatomic) NSString *videoTitle; +@property (nonatomic) NSString *videoDescription; +@property (nonatomic) NSString *videoImage; +@property (nonatomic) NSString *videoID; + +@end diff --git a/InControl/InControl/Youtube.m b/InControl/InControl/Youtube.m new file mode 100644 index 0000000..3414ae9 --- /dev/null +++ b/InControl/InControl/Youtube.m @@ -0,0 +1,13 @@ +// +// Youtube.m +// InControl +// +// Created by Diana Elezaj on 10/13/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import "Youtube.h" + +@implementation Youtube + +@end diff --git a/InControl/InControl/budget.png b/InControl/InControl/budget.png new file mode 100644 index 0000000..286dda5 Binary files /dev/null and b/InControl/InControl/budget.png differ diff --git a/InControl/InControl/burger.png b/InControl/InControl/burger.png new file mode 100644 index 0000000..fb61821 Binary files /dev/null and b/InControl/InControl/burger.png differ diff --git a/InControl/InControl/burger@2x.png b/InControl/InControl/burger@2x.png new file mode 100644 index 0000000..400b1ab Binary files /dev/null and b/InControl/InControl/burger@2x.png differ diff --git a/InControl/InControl/food.png b/InControl/InControl/food.png new file mode 100644 index 0000000..01924b4 Binary files /dev/null and b/InControl/InControl/food.png differ diff --git a/InControl/InControl/gear.png b/InControl/InControl/gear.png new file mode 100644 index 0000000..83a4768 Binary files /dev/null and b/InControl/InControl/gear.png differ diff --git a/InControl/InControl/gear@2x.png b/InControl/InControl/gear@2x.png new file mode 100644 index 0000000..868dcfc Binary files /dev/null and b/InControl/InControl/gear@2x.png differ diff --git a/InControl/InControl/globe.png b/InControl/InControl/globe.png new file mode 100644 index 0000000..ef28044 Binary files /dev/null and b/InControl/InControl/globe.png differ diff --git a/InControl/InControl/globe@2x.png b/InControl/InControl/globe@2x.png new file mode 100644 index 0000000..97c1b89 Binary files /dev/null and b/InControl/InControl/globe@2x.png differ diff --git a/InControl/InControl/homeButton.png b/InControl/InControl/homeButton.png new file mode 100644 index 0000000..e2a54c0 Binary files /dev/null and b/InControl/InControl/homeButton.png differ diff --git a/InControl/InControl/hotel.png b/InControl/InControl/hotel.png new file mode 100644 index 0000000..2ce3a1e Binary files /dev/null and b/InControl/InControl/hotel.png differ diff --git a/InControl/InControl/image.png b/InControl/InControl/image.png new file mode 100644 index 0000000..09a23a6 Binary files /dev/null and b/InControl/InControl/image.png differ diff --git a/InControl/InControl/insta.png b/InControl/InControl/insta.png new file mode 100644 index 0000000..fabf5ea Binary files /dev/null and b/InControl/InControl/insta.png differ diff --git a/InControl/InControl/main.m b/InControl/InControl/main.m new file mode 100644 index 0000000..f13365e --- /dev/null +++ b/InControl/InControl/main.m @@ -0,0 +1,16 @@ +// +// main.m +// InControl +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/InControl/InControl/meetup.png b/InControl/InControl/meetup.png new file mode 100644 index 0000000..07d6a61 Binary files /dev/null and b/InControl/InControl/meetup.png differ diff --git a/InControl/InControl/profile.png b/InControl/InControl/profile.png new file mode 100644 index 0000000..e65ca5f Binary files /dev/null and b/InControl/InControl/profile.png differ diff --git a/InControl/InControl/profile@2x.png b/InControl/InControl/profile@2x.png new file mode 100644 index 0000000..d39052f Binary files /dev/null and b/InControl/InControl/profile@2x.png differ diff --git a/InControl/InControl/search.png b/InControl/InControl/search.png new file mode 100644 index 0000000..39b3b4d Binary files /dev/null and b/InControl/InControl/search.png differ diff --git a/InControl/InControl/star.png b/InControl/InControl/star.png new file mode 100644 index 0000000..c943bfa Binary files /dev/null and b/InControl/InControl/star.png differ diff --git a/InControl/InControl/star@2x.png b/InControl/InControl/star@2x.png new file mode 100644 index 0000000..83af260 Binary files /dev/null and b/InControl/InControl/star@2x.png differ diff --git a/InControl/InControl/video.png b/InControl/InControl/video.png new file mode 100644 index 0000000..0eb3fa9 Binary files /dev/null and b/InControl/InControl/video.png differ diff --git a/InControl/InControlTests/InControlTests.m b/InControl/InControlTests/InControlTests.m new file mode 100644 index 0000000..1dbf4bc --- /dev/null +++ b/InControl/InControlTests/InControlTests.m @@ -0,0 +1,39 @@ +// +// InControlTests.m +// InControlTests +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface InControlTests : XCTestCase + +@end + +@implementation InControlTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/InControl/InControlTests/Info.plist b/InControl/InControlTests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/InControl/InControlTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/InControl/InControlUITests/InControlUITests.m b/InControl/InControlUITests/InControlUITests.m new file mode 100644 index 0000000..9de78e9 --- /dev/null +++ b/InControl/InControlUITests/InControlUITests.m @@ -0,0 +1,40 @@ +// +// InControlUITests.m +// InControlUITests +// +// Created by Diana Elezaj on 10/11/15. +// Copyright © 2015 Diana Elezaj. All rights reserved. +// + +#import + +@interface InControlUITests : XCTestCase + +@end + +@implementation InControlUITests + +- (void)setUp { + [super setUp]; + + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + self.continueAfterFailure = NO; + // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. + [[[XCUIApplication alloc] init] launch]; + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // Use recording to get started writing UI tests. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +@end diff --git a/InControl/InControlUITests/Info.plist b/InControl/InControlUITests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/InControl/InControlUITests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/InControl/Podfile b/InControl/Podfile new file mode 100644 index 0000000..ee45e5f --- /dev/null +++ b/InControl/Podfile @@ -0,0 +1,3 @@ +pod "XCDYouTubeKit", "~> 2.3.2" +pod 'SDWebImage', '~> 3.7' +pod "AFNetworking" \ No newline at end of file diff --git a/InControl/Podfile.lock b/InControl/Podfile.lock new file mode 100644 index 0000000..b143bba --- /dev/null +++ b/InControl/Podfile.lock @@ -0,0 +1,38 @@ +PODS: + - AFNetworking (2.6.1): + - AFNetworking/NSURLConnection (= 2.6.1) + - AFNetworking/NSURLSession (= 2.6.1) + - AFNetworking/Reachability (= 2.6.1) + - AFNetworking/Security (= 2.6.1) + - AFNetworking/Serialization (= 2.6.1) + - AFNetworking/UIKit (= 2.6.1) + - AFNetworking/NSURLConnection (2.6.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/NSURLSession (2.6.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (2.6.1) + - AFNetworking/Security (2.6.1) + - AFNetworking/Serialization (2.6.1) + - AFNetworking/UIKit (2.6.1): + - AFNetworking/NSURLConnection + - AFNetworking/NSURLSession + - SDWebImage (3.7.3): + - SDWebImage/Core (= 3.7.3) + - SDWebImage/Core (3.7.3) + - XCDYouTubeKit (2.3.2) + +DEPENDENCIES: + - AFNetworking + - SDWebImage (~> 3.7) + - XCDYouTubeKit (~> 2.3.2) + +SPEC CHECKSUMS: + AFNetworking: 8e4e60500beb8bec644cf575beee72990a76d399 + SDWebImage: 1d2b1a1efda1ade1b00b6f8498865f8ddedc8a84 + XCDYouTubeKit: 6aff378bcbbf06d058f2c2d2df655c376970ee03 + +COCOAPODS: 0.38.2 diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h new file mode 100644 index 0000000..cf6def4 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1,70 @@ +// AFHTTPRequestOperation.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import "AFURLConnectionOperation.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. + */ +@interface AFHTTPRequestOperation : AFURLConnectionOperation + +///------------------------------------------------ +/// @name Getting HTTP URL Connection Information +///------------------------------------------------ + +/** + The last HTTP response received by the operation's connection. + */ +@property (readonly, nonatomic, strong, nullable) NSHTTPURLResponse *response; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. + + @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error. + */ +@property (readonly, nonatomic, strong, nullable) id responseObject; + +///----------------------------------------------------------- +/// @name Setting Completion Block Success / Failure Callbacks +///----------------------------------------------------------- + +/** + Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. + + This method should be overridden in subclasses in order to specify the response object passed into the success block. + + @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. + @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. + */ +- (void)setCompletionBlockWithSuccess:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m new file mode 100644 index 0000000..b8deda8 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m @@ -0,0 +1,206 @@ +// AFHTTPRequestOperation.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPRequestOperation.h" + +static dispatch_queue_t http_request_operation_processing_queue() { + static dispatch_queue_t af_http_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_http_request_operation_processing_queue; +} + +static dispatch_group_t http_request_operation_completion_group() { + static dispatch_group_t af_http_request_operation_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_http_request_operation_completion_group = dispatch_group_create(); + }); + + return af_http_request_operation_completion_group; +} + +#pragma mark - + +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSURLResponse *response; +@end + +@interface AFHTTPRequestOperation () +@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; +@property (readwrite, nonatomic, strong) id responseObject; +@property (readwrite, nonatomic, strong) NSError *responseSerializationError; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@end + +@implementation AFHTTPRequestOperation +@dynamic response; +@dynamic lock; + +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { + self = [super initWithRequest:urlRequest]; + if (!self) { + return nil; + } + + self.responseSerializer = [AFHTTPResponseSerializer serializer]; + + return self; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [self.lock lock]; + _responseSerializer = responseSerializer; + self.responseObject = nil; + self.responseSerializationError = nil; + [self.lock unlock]; +} + +- (id)responseObject { + [self.lock lock]; + if (!_responseObject && [self isFinished] && !self.error) { + NSError *error = nil; + self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error]; + if (error) { + self.responseSerializationError = error; + } + } + [self.lock unlock]; + + return _responseObject; +} + +- (NSError *)error { + if (_responseSerializationError) { + return _responseSerializationError; + } else { + return [super error]; + } +} + +#pragma mark - AFHTTPRequestOperation + +- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + self.completionBlock = ^{ + if (self.completionGroup) { + dispatch_group_enter(self.completionGroup); + } + + dispatch_async(http_request_operation_processing_queue(), ^{ + if (self.error) { + if (failure) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + id responseObject = self.responseObject; + if (self.error) { + if (failure) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + success(self, responseObject); + }); + } + } + } + + if (self.completionGroup) { + dispatch_group_leave(self.completionGroup); + } + }); + }; +#pragma clang diagnostic pop +} + +#pragma mark - AFURLRequestOperation + +- (void)pause { + [super pause]; + + u_int64_t offset = 0; + if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { + offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; + } else { + offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; + } + + NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; + if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { + [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; + } + [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; + self.request = mutableURLRequest; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestOperation *operation = [super copyWithZone:zone]; + + operation.responseSerializer = [self.responseSerializer copyWithZone:zone]; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +@end diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h new file mode 100644 index 0000000..d2385ed --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1,326 @@ +// AFHTTPRequestOperationManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +#import "AFHTTPRequestOperation.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#import "AFNetworkReachabilityManager.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all request operation construction for an `AFHTTPRequestOperationManager` subclass, override `HTTPRequestOperationWithRequest:success:failure`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSSecureCoding & NSCopying Caveats + + `AFHTTPRequestOperationManager` conforms to the `NSSecureCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however: + + - Archives and copies of HTTP clients will be initialized with an empty operation queue. + - NSSecureCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set. + */ +@interface AFHTTPRequestOperationManager : NSObject + +/** + The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong, nullable) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to a JSON serializer, which serializes data from responses with a `application/json` MIME type, and falls back to the raw data object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + The operation queue on which request operations are scheduled and run. + */ +@property (nonatomic, strong) NSOperationQueue *operationQueue; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether request operations should consult the credential storage for authenticating the connection. `YES` by default. + + @see AFURLConnectionOperation -shouldUseCredentialStorage + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + The credential used by request operations for authentication challenges. + + @see AFURLConnectionOperation -credential + */ +@property (nonatomic, strong, nullable) NSURLCredential *credential; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created request operations to evaluate server trust for secure connections. `AFHTTPRequestOperationManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///------------------------------------ +/// @name Managing Network Reachability +///------------------------------------ + +/** + The network reachability manager. `AFHTTPRequestOperationManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for the `completionBlock` of request operations. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign, nullable) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for the `completionBlock` of request operations. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign, nullable) dispatch_group_t completionGroup; +#endif + +///--------------------------------------------- +/// @name Creating and Initializing HTTP Clients +///--------------------------------------------- + +/** + Creates and returns an `AFHTTPRequestOperationManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPRequestOperationManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url NS_DESIGNATED_INITIALIZER; + +///--------------------------------------- +/// @name Managing HTTP Request Operations +///--------------------------------------- + +/** + Creates an `AFHTTPRequestOperation`, and sets the response serializers to that of the HTTP client. + + @param request The request object to be loaded asynchronously during execution of the operation. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + */ +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `AFHTTPRequestOperation` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)GET:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single arguments: the request operation. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)HEAD:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)PUT:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)PATCH:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)DELETE:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m new file mode 100644 index 0000000..60739e5 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m @@ -0,0 +1,284 @@ +// AFHTTPRequestOperationManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "AFHTTPRequestOperationManager.h" +#import "AFHTTPRequestOperation.h" + +#import +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +@interface AFHTTPRequestOperationManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPRequestOperationManager + ++ (instancetype)manager { + return [[self alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + self = [super init]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; + + self.operationQueue = [[NSOperationQueue alloc] init]; + + self.shouldUseCredentialStorage = YES; + + return self; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +#endif + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - + +- (AFHTTPRequestOperation *)HTTPRequestOperationWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + return [self HTTPRequestOperationWithRequest:request success:success failure:failure]; +} + +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + operation.responseSerializer = self.responseSerializer; + operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + operation.credential = self.credential; + operation.securityPolicy = self.securityPolicy; + + [operation setCompletionBlockWithSuccess:success failure:failure]; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +#pragma mark - + +- (AFHTTPRequestOperation *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) { + if (success) { + success(requestOperation); + } + } failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))]; + + self = [self initWithBaseURL:baseURL]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestOperationManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + + return HTTPClient; +} + +@end diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h new file mode 100644 index 0000000..e516e6d --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1,253 @@ +// AFHTTPSessionManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#if !TARGET_OS_WATCH +#import +#endif +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +#import "AFURLSessionManager.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || TARGET_OS_WATCH + +NS_ASSUME_NONNULL_BEGIN + +@interface AFHTTPSessionManager : AFURLSessionManager + +/** + The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong, nullable) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns an `AFHTTPSessionManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + @param configuration The configuration used to create the managed session. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url + sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask *task, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m new file mode 100644 index 0000000..bd9163f --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m @@ -0,0 +1,323 @@ +// AFHTTPSessionManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPSessionManager.h" + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || TARGET_WATCH_OS + +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" + +#import +#import + +#ifdef _SYSTEMCONFIGURATION_H +#import +#import +#import +#import +#import +#endif + +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#endif + +@interface AFHTTPSessionManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPSessionManager +@dynamic responseSerializer; + ++ (instancetype)manager { + return [[[self class] alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + return [self initWithBaseURL:url sessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + return [self initWithBaseURL:nil sessionConfiguration:configuration]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration +{ + self = [super initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + return self; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +#endif + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [super setResponseSerializer:responseSerializer]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(NSURLSessionDataTask *task, __unused id responseObject) { + if (success) { + success(task); + } + } failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(task, error); + } + } else { + if (success) { + success(task, responseObject); + } + } + }]; + + [task resume]; + + return task; +} + +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *, id))success + failure:(void (^)(NSURLSessionDataTask *, NSError *))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *dataTask = nil; + dataTask = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(dataTask, error); + } + } else { + if (success) { + success(dataTask, responseObject); + } + } + }]; + + return dataTask; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + if (!configuration) { + NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"]; + if (configurationIdentifier) { +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100) + configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier]; +#else + configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier]; +#endif + } + } + + self = [self initWithBaseURL:baseURL sessionConfiguration:configuration]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; + } else { + [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"]; + } + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + + return HTTPClient; +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h b/InControl/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h new file mode 100644 index 0000000..e2eb945 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1,207 @@ +// AFNetworkReachabilityManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if !TARGET_OS_WATCH +#import + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { + AFNetworkReachabilityStatusUnknown = -1, + AFNetworkReachabilityStatusNotReachable = 0, + AFNetworkReachabilityStatusReachableViaWWAN = 1, + AFNetworkReachabilityStatusReachableViaWiFi = 2, +}; + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + + Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. + + See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/) + + @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. + */ +@interface AFNetworkReachabilityManager : NSObject + +/** + The current network reachability status. + */ +@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; + +/** + Whether or not the network is currently reachable. + */ +@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; + +/** + Whether or not the network is currently reachable via WWAN. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; + +/** + Whether or not the network is currently reachable via WiFi. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Returns the shared network reachability manager. + */ ++ (instancetype)sharedManager; + +/** + Creates and returns a network reachability manager for the specified domain. + + @param domain The domain used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified domain. + */ ++ (instancetype)managerForDomain:(NSString *)domain; + +/** + Creates and returns a network reachability manager for the socket address. + + @param address The socket address (`sockaddr_in`) used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified socket address. + */ ++ (instancetype)managerForAddress:(const void *)address; + +/** + Initializes an instance of a network reachability manager from the specified reachability object. + + @param reachability The reachability object to monitor. + + @return An initialized network reachability manager, actively monitoring the specified reachability. + */ +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; + +///-------------------------------------------------- +/// @name Starting & Stopping Reachability Monitoring +///-------------------------------------------------- + +/** + Starts monitoring for changes in network reachability status. + */ +- (void)startMonitoring; + +/** + Stops monitoring for changes in network reachability status. + */ +- (void)stopMonitoring; + +///------------------------------------------------- +/// @name Getting Localized Reachability Description +///------------------------------------------------- + +/** + Returns a localized string representation of the current network reachability status. + */ +- (NSString *)localizedNetworkReachabilityStatusString; + +///--------------------------------------------------- +/// @name Setting Network Reachability Change Callback +///--------------------------------------------------- + +/** + Sets a callback to be executed when the network availability of the `baseURL` host changes. + + @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. + */ +- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Network Reachability + + The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. + + enum { + AFNetworkReachabilityStatusUnknown, + AFNetworkReachabilityStatusNotReachable, + AFNetworkReachabilityStatusReachableViaWWAN, + AFNetworkReachabilityStatusReachableViaWiFi, + } + + `AFNetworkReachabilityStatusUnknown` + The `baseURL` host reachability is not known. + + `AFNetworkReachabilityStatusNotReachable` + The `baseURL` host cannot be reached. + + `AFNetworkReachabilityStatusReachableViaWWAN` + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. + + `AFNetworkReachabilityStatusReachableViaWiFi` + The `baseURL` host can be reached via a Wi-Fi connection. + + ### Keys for Notification UserInfo Dictionary + + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. + + `AFNetworkingReachabilityNotificationStatusItem` + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. + */ + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when network reachability changes. + This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. + + @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). + */ +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification; +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem; + +///-------------------- +/// @name Functions +///-------------------- + +/** + Returns a localized string representation of an `AFNetworkReachabilityStatus` value. + */ +FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); + +NS_ASSUME_NONNULL_END +#endif diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m b/InControl/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m new file mode 100644 index 0000000..2e5e2ed --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m @@ -0,0 +1,262 @@ +// AFNetworkReachabilityManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkReachabilityManager.h" +#if !TARGET_OS_WATCH + +#import +#import +#import +#import +#import + +NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; +NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; + +typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); + +typedef NS_ENUM(NSUInteger, AFNetworkReachabilityAssociation) { + AFNetworkReachabilityForAddress = 1, + AFNetworkReachabilityForAddressPair = 2, + AFNetworkReachabilityForName = 3, +}; + +NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusNotReachable: + return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWWAN: + return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWiFi: + return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); + case AFNetworkReachabilityStatusUnknown: + default: + return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); + } +} + +static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { + BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); + BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); + BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); + BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); + BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); + + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; + if (isNetworkReachable == NO) { + status = AFNetworkReachabilityStatusNotReachable; + } +#if TARGET_OS_IPHONE + else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { + status = AFNetworkReachabilityStatusReachableViaWWAN; + } +#endif + else { + status = AFNetworkReachabilityStatusReachableViaWiFi; + } + + return status; +} + +static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + AFNetworkReachabilityStatusBlock block = (__bridge AFNetworkReachabilityStatusBlock)info; + if (block) { + block(status); + } + + + dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; + }); + +} + +static const void * AFNetworkReachabilityRetainCallback(const void *info) { + return Block_copy(info); +} + +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + Block_release(info); + } +} + +@interface AFNetworkReachabilityManager () +@property (readwrite, nonatomic, strong) id networkReachability; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityAssociation networkReachabilityAssociation; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; +@end + +@implementation AFNetworkReachabilityManager + ++ (instancetype)sharedManager { + static AFNetworkReachabilityManager *_sharedManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + struct sockaddr_in address; + bzero(&address, sizeof(address)); + address.sin_len = sizeof(address); + address.sin_family = AF_INET; + + _sharedManager = [self managerForAddress:&address]; + }); + + return _sharedManager; +} + ++ (instancetype)managerForDomain:(NSString *)domain { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + manager.networkReachabilityAssociation = AFNetworkReachabilityForName; + + return manager; +} + ++ (instancetype)managerForAddress:(const void *)address { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + manager.networkReachabilityAssociation = AFNetworkReachabilityForAddress; + + return manager; +} + +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { + self = [super init]; + if (!self) { + return nil; + } + + self.networkReachability = CFBridgingRelease(reachability); + self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; + + return self; +} + +- (instancetype)init NS_UNAVAILABLE +{ + return nil; +} + +- (void)dealloc { + [self stopMonitoring]; +} + +#pragma mark - + +- (BOOL)isReachable { + return [self isReachableViaWWAN] || [self isReachableViaWiFi]; +} + +- (BOOL)isReachableViaWWAN { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; +} + +- (BOOL)isReachableViaWiFi { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; +} + +#pragma mark - + +- (void)startMonitoring { + [self stopMonitoring]; + + if (!self.networkReachability) { + return; + } + + __weak __typeof(self)weakSelf = self; + AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf.networkReachabilityStatus = status; + if (strongSelf.networkReachabilityStatusBlock) { + strongSelf.networkReachabilityStatusBlock(status); + } + + }; + + id networkReachability = self.networkReachability; + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; + SCNetworkReachabilitySetCallback((__bridge SCNetworkReachabilityRef)networkReachability, AFNetworkReachabilityCallback, &context); + SCNetworkReachabilityScheduleWithRunLoop((__bridge SCNetworkReachabilityRef)networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); + + switch (self.networkReachabilityAssociation) { + case AFNetworkReachabilityForName: + break; + case AFNetworkReachabilityForAddress: + case AFNetworkReachabilityForAddressPair: + default: { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ + SCNetworkReachabilityFlags flags; + SCNetworkReachabilityGetFlags((__bridge SCNetworkReachabilityRef)networkReachability, &flags); + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + dispatch_async(dispatch_get_main_queue(), ^{ + callback(status); + + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }]; + + + }); + }); + } + break; + } +} + +- (void)stopMonitoring { + if (!self.networkReachability) { + return; + } + + SCNetworkReachabilityUnscheduleFromRunLoop((__bridge SCNetworkReachabilityRef)self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); +} + +#pragma mark - + +- (NSString *)localizedNetworkReachabilityStatusString { + return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); +} + +#pragma mark - + +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { + self.networkReachabilityStatusBlock = block; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { + return [NSSet setWithObject:@"networkReachabilityStatus"]; + } + + return [super keyPathsForValuesAffectingValueForKey:key]; +} + +@end +#endif diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFNetworking.h b/InControl/Pods/AFNetworking/AFNetworking/AFNetworking.h new file mode 100644 index 0000000..6d442bb --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFNetworking.h @@ -0,0 +1,46 @@ +// AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#ifndef _AFNETWORKING_ + #define _AFNETWORKING_ + + #import "AFURLRequestSerialization.h" + #import "AFURLResponseSerialization.h" + #import "AFSecurityPolicy.h" +#if !TARGET_OS_WATCH + #import "AFNetworkReachabilityManager.h" + #import "AFURLConnectionOperation.h" + #import "AFHTTPRequestOperation.h" + #import "AFHTTPRequestOperationManager.h" +#endif + +#if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ + ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) || \ + TARGET_OS_WATCH ) + #import "AFURLSessionManager.h" + #import "AFHTTPSessionManager.h" +#endif + +#endif /* _AFNETWORKING_ */ diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h b/InControl/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h new file mode 100644 index 0000000..3c38da8 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1,142 @@ +// AFSecurityPolicy.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, +}; + +/** + `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + + Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFSecurityPolicy : NSObject + +/** + The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. + */ +@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; + +/** + The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. + */ +@property (nonatomic, strong, nullable) NSArray *pinnedCertificates; + +/** + Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowInvalidCertificates; + +/** + Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. + */ +@property (nonatomic, assign) BOOL validatesDomainName; + +///----------------------------------------- +/// @name Getting Specific Security Policies +///----------------------------------------- + +/** + Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. + + @return The default security policy. + */ ++ (instancetype)defaultPolicy; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + + @return A new security policy. + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; + +///------------------------------ +/// @name Evaluating Server Trust +///------------------------------ + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + + @return Whether or not to trust the server. + + @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + @param domain The domain of serverTrust. If `nil`, the domain will not be validated. + + @return Whether or not to trust the server. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(nullable NSString *)domain; + +@end + +NS_ASSUME_NONNULL_END + +///---------------- +/// @name Constants +///---------------- + +/** + ## SSL Pinning Modes + + The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. + + enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModeNone` + Do not used pinned certificates to validate servers. + + `AFSSLPinningModePublicKey` + Validate host certificates against public keys of pinned certificates. + + `AFSSLPinningModeCertificate` + Validate host certificates against pinned certificates. +*/ diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m b/InControl/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m new file mode 100644 index 0000000..e8eaa65 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m @@ -0,0 +1,311 @@ +// AFSecurityPolicy.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFSecurityPolicy.h" + +#import + +#if !TARGET_OS_IOS && !TARGET_OS_WATCH +static NSData * AFSecKeyGetData(SecKeyRef key) { + CFDataRef data = NULL; + + __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); + + return (__bridge_transfer NSData *)data; + +_out: + if (data) { + CFRelease(data); + } + + return nil; +} +#endif + +static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { +#if TARGET_OS_IOS || TARGET_OS_WATCH + return [(__bridge id)key1 isEqual:(__bridge id)key2]; +#else + return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; +#endif +} + +static id AFPublicKeyForCertificate(NSData *certificate) { + id allowedPublicKey = nil; + SecCertificateRef allowedCertificate; + SecCertificateRef allowedCertificates[1]; + CFArrayRef tempCertificates = nil; + SecPolicyRef policy = nil; + SecTrustRef allowedTrust = nil; + SecTrustResultType result; + + allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); + __Require_Quiet(allowedCertificate != NULL, _out); + + allowedCertificates[0] = allowedCertificate; + tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); + + policy = SecPolicyCreateBasicX509(); + __Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); + __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); + + allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); + +_out: + if (allowedTrust) { + CFRelease(allowedTrust); + } + + if (policy) { + CFRelease(policy); + } + + if (tempCertificates) { + CFRelease(tempCertificates); + } + + if (allowedCertificate) { + CFRelease(allowedCertificate); + } + + return allowedPublicKey; +} + +static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { + BOOL isValid = NO; + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); + + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + +_out: + return isValid; +} + +static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } + + return [NSArray arrayWithArray:trustChain]; +} + +static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + + SecTrustRef trust; + __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); + + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); + + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + _out: + if (trust) { + CFRelease(trust); + } + + if (certificates) { + CFRelease(certificates); + } + + continue; + } + CFRelease(policy); + + return [NSArray arrayWithArray:trustChain]; +} + +#pragma mark - + +@interface AFSecurityPolicy() +@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; +@property (readwrite, nonatomic, strong) NSArray *pinnedPublicKeys; +@end + +@implementation AFSecurityPolicy + ++ (NSArray *)defaultPinnedCertificates { + static NSArray *_defaultPinnedCertificates = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + + NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } + + _defaultPinnedCertificates = [[NSArray alloc] initWithArray:certificates]; + }); + + return _defaultPinnedCertificates; +} + ++ (instancetype)defaultPolicy { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = AFSSLPinningModeNone; + + return securityPolicy; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = pinningMode; + + [securityPolicy setPinnedCertificates:[self defaultPinnedCertificates]]; + + return securityPolicy; +} + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + self.validatesDomainName = YES; + + return self; +} + +- (void)setPinnedCertificates:(NSArray *)pinnedCertificates { + _pinnedCertificates = [[NSOrderedSet orderedSetWithArray:pinnedCertificates] array]; + + if (self.pinnedCertificates) { + NSMutableArray *mutablePinnedPublicKeys = [NSMutableArray arrayWithCapacity:[self.pinnedCertificates count]]; + for (NSData *certificate in self.pinnedCertificates) { + id publicKey = AFPublicKeyForCertificate(certificate); + if (!publicKey) { + continue; + } + [mutablePinnedPublicKeys addObject:publicKey]; + } + self.pinnedPublicKeys = [NSArray arrayWithArray:mutablePinnedPublicKeys]; + } else { + self.pinnedPublicKeys = nil; + } +} + +#pragma mark - + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust { + return [self evaluateServerTrust:serverTrust forDomain:nil]; +} + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain +{ + if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) { + // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html + // According to the docs, you should only trust your provided certs for evaluation. + // Pinned certificates are added to the trust. Without pinned certificates, + // there is nothing to evaluate against. + // + // From Apple Docs: + // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors). + // Instead, add your own (self-signed) CA certificate to the list of trusted anchors." + NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning."); + return NO; + } + + NSMutableArray *policies = [NSMutableArray array]; + if (self.validatesDomainName) { + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; + } else { + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; + } + + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); + + if (self.SSLPinningMode == AFSSLPinningModeNone) { + if (self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust)){ + return YES; + } else { + return NO; + } + } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { + return NO; + } + + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); + switch (self.SSLPinningMode) { + case AFSSLPinningModeNone: + default: + return NO; + case AFSSLPinningModeCertificate: { + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + for (NSData *certificateData in self.pinnedCertificates) { + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + } + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + + if (!AFServerTrustIsValid(serverTrust)) { + return NO; + } + + NSUInteger trustedCertificateCount = 0; + for (NSData *trustChainCertificate in serverCertificates) { + if ([self.pinnedCertificates containsObject:trustChainCertificate]) { + trustedCertificateCount++; + } + } + return trustedCertificateCount > 0; + } + case AFSSLPinningModePublicKey: { + NSUInteger trustedPublicKeyCount = 0; + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); + + for (id trustChainPublicKey in publicKeys) { + for (id pinnedPublicKey in self.pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + trustedPublicKeyCount += 1; + } + } + } + return trustedPublicKeyCount > 0; + } + } + + return NO; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { + return [NSSet setWithObject:@"pinnedCertificates"]; +} + +@end diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h b/InControl/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h new file mode 100644 index 0000000..c21119e --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1,344 @@ +// AFURLConnectionOperation.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" +#import "AFSecurityPolicy.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods. + + ## Subclassing Notes + + This is the base class of all network request operations. You may wish to create your own subclass in order to implement additional `NSURLConnection` delegate methods (see "`NSURLConnection` Delegate Methods" below), or to provide additional properties and/or class constructors. + + If you are creating a subclass that communicates over the HTTP or HTTPS protocols, you may want to consider subclassing `AFHTTPRequestOperation` instead, as it supports specifying acceptable content types or status codes. + + ## NSURLConnection Delegate Methods + + `AFURLConnectionOperation` implements the following `NSURLConnection` delegate methods: + + - `connection:didReceiveResponse:` + - `connection:didReceiveData:` + - `connectionDidFinishLoading:` + - `connection:didFailWithError:` + - `connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:` + - `connection:willCacheResponse:` + - `connectionShouldUseCredentialStorage:` + - `connection:needNewBodyStream:` + - `connection:willSendRequestForAuthenticationChallenge:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Callbacks and Completion Blocks + + The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this. + + Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/). + + ## SSL Pinning + + Relying on the CA trust model to validate SSL certificates exposes your app to security vulnerabilities, such as man-in-the-middle attacks. For applications that connect to known servers, SSL certificate pinning provides an increased level of security, by checking server certificate validity against those specified in the app bundle. + + SSL with certificate pinning is strongly recommended for any application that transmits sensitive information to an external webservice. + + Connections will be validated on all matching certificates with a `.cer` extension in the bundle root. + + ## NSCoding & NSCopying Conformance + + `AFURLConnectionOperation` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. However, because of the intrinsic limitations of capturing the exact state of an operation at a particular moment, there are some important caveats to keep in mind: + + ### NSCoding Caveats + + - Encoded operations do not include any block or stream properties. Be sure to set `completionBlock`, `outputStream`, and any callback blocks as necessary when using `-initWithCoder:` or `NSKeyedUnarchiver`. + - Operations are paused on `encodeWithCoder:`. If the operation was encoded while paused or still executing, its archived state will return `YES` for `isReady`. Otherwise, the state of an operation when encoding will remain unchanged. + + ### NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new operation with the `NSURLRequest` of the original. So rather than an exact copy of the operation at that particular instant, the copying mechanism returns a completely new instance, which can be useful for retrying operations. + - A copy of an operation will not include the `outputStream` of the original. + - Operation copies do not include `completionBlock`, as it often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFURLConnectionOperation : NSOperation + +///------------------------------- +/// @name Accessing Run Loop Modes +///------------------------------- + +/** + The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing `NSRunLoopCommonModes`. + */ +@property (nonatomic, strong) NSSet *runLoopModes; + +///----------------------------------------- +/// @name Getting URL Connection Information +///----------------------------------------- + +/** + The request used by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSURLRequest *request; + +/** + The last response received by the operation's connection. + */ +@property (readonly, nonatomic, strong, nullable) NSURLResponse *response; + +/** + The error, if any, that occurred in the lifecycle of the request. + */ +@property (readonly, nonatomic, strong, nullable) NSError *error; + +///---------------------------- +/// @name Getting Response Data +///---------------------------- + +/** + The data received during the request. + */ +@property (readonly, nonatomic, strong, nullable) NSData *responseData; + +/** + The string representation of the response data. + */ +@property (readonly, nonatomic, copy, nullable) NSString *responseString; + +/** + The string encoding of the response. + + If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. + */ +@property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. + + This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. + + This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + */ +@property (nonatomic, strong, nullable) NSURLCredential *credential; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used to evaluate server trust for secure connections. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///------------------------ +/// @name Accessing Streams +///------------------------ + +/** + The input stream used to read data to be sent during the request. + + This property acts as a proxy to the `HTTPBodyStream` property of `request`. + */ +@property (nonatomic, strong) NSInputStream *inputStream; + +/** + The output stream that is used to write data received until the request is finished. + + By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request, with the intermediary `outputStream` property set to `nil`. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. + */ +@property (nonatomic, strong, nullable) NSOutputStream *outputStream; + +///--------------------------------- +/// @name Managing Callback Queues +///--------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_USE_OBJC +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign, nullable) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_USE_OBJC +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign, nullable) dispatch_group_t completionGroup; +#endif + +///--------------------------------------------- +/// @name Managing Request Operation Information +///--------------------------------------------- + +/** + The user info dictionary for the receiver. + */ +@property (nonatomic, strong) NSDictionary *userInfo; +// FIXME: It doesn't seem that this userInfo is used anywhere in the implementation. + +///------------------------------------------------------ +/// @name Initializing an AFURLConnectionOperation Object +///------------------------------------------------------ + +/** + Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. + + This is the designated initializer. + + @param urlRequest The request object to be used by the operation connection. + */ +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest NS_DESIGNATED_INITIALIZER; + +///---------------------------------- +/// @name Pausing / Resuming Requests +///---------------------------------- + +/** + Pauses the execution of the request operation. + + A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. + */ +- (void)pause; + +/** + Whether the request operation is currently paused. + + @return `YES` if the operation is currently paused, otherwise `NO`. + */ +- (BOOL)isPaused; + +/** + Resumes the execution of the paused request operation. + + Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. + */ +- (void)resume; + +///---------------------------------------------- +/// @name Configuring Backgrounding Task Behavior +///---------------------------------------------- + +/** + Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task. + + @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. + */ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(nullable void (^)(void))handler NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); +#endif + +///--------------------------------- +/// @name Setting Progress Callbacks +///--------------------------------- + +/** + Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setUploadProgressBlock:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; + +/** + Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setDownloadProgressBlock:(nullable void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; + +///------------------------------------------------- +/// @name Setting NSURLConnection Delegate Callbacks +///------------------------------------------------- + +/** + Sets a block to be executed when the connection will authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequestForAuthenticationChallenge:`. + + @param block A block object to be executed when the connection will authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. This block must invoke one of the challenge-responder methods (NSURLAuthenticationChallengeSender protocol). + + If `allowsInvalidSSLCertificate` is set to YES, `connection:willSendRequestForAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + */ +- (void)setWillSendRequestForAuthenticationChallengeBlock:(nullable void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; + +/** + Sets a block to be executed when the server redirects the request from one URL to another URL, or when the request URL changed by the `NSURLProtocol` subclass handling the request in order to standardize its format, as handled by the `NSURLConnectionDataDelegate` method `connection:willSendRequest:redirectResponse:`. + + @param block A block object to be executed when the request URL was changed. The block returns an `NSURLRequest` object, the URL request to redirect, and takes three arguments: the URL connection object, the the proposed redirected request, and the URL response that caused the redirect. + */ +- (void)setRedirectResponseBlock:(nullable NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block; + + +/** + Sets a block to be executed to modify the response a connection will cache, if any, as handled by the `NSURLConnectionDelegate` method `connection:willCacheResponse:`. + + @param block A block object to be executed to determine what response a connection will cache, if any. The block returns an `NSCachedURLResponse` object, the cached response to store in memory or `nil` to prevent the response from being cached, and takes two arguments: the URL connection object, and the cached response provided for the request. + */ +- (void)setCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block; + +/// + +/** + + */ ++ (NSArray *)batchOfRequestOperations:(nullable NSArray *)operations + progressBlock:(nullable void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(nullable void (^)(NSArray *operations))completionBlock; + +@end + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when an operation begins executing. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationDidStartNotification; + +/** + Posted when an operation finishes. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationDidFinishNotification; + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m b/InControl/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m new file mode 100644 index 0000000..0568005 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m @@ -0,0 +1,792 @@ +// AFURLConnectionOperation.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLConnectionOperation.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +#if !__has_feature(objc_arc) +#error AFNetworking must be built with ARC. +// You can turn on ARC for only AFNetworking files by adding -fobjc-arc to the build phase for each of its files. +#endif + +typedef NS_ENUM(NSInteger, AFOperationState) { + AFOperationPausedState = -1, + AFOperationReadyState = 1, + AFOperationExecutingState = 2, + AFOperationFinishedState = 3, +}; + +static dispatch_group_t url_request_operation_completion_group() { + static dispatch_group_t af_url_request_operation_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_request_operation_completion_group = dispatch_group_create(); + }); + + return af_url_request_operation_completion_group; +} + +static dispatch_queue_t url_request_operation_completion_queue() { + static dispatch_queue_t af_url_request_operation_completion_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_request_operation_completion_queue = dispatch_queue_create("com.alamofire.networking.operation.queue", DISPATCH_QUEUE_CONCURRENT ); + }); + + return af_url_request_operation_completion_queue; +} + +static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock"; + +NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start"; +NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish"; + +typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge); +typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse); +typedef NSURLRequest * (^AFURLConnectionOperationRedirectResponseBlock)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse); +typedef void (^AFURLConnectionOperationBackgroundTaskCleanupBlock)(); + +static inline NSString * AFKeyPathFromOperationState(AFOperationState state) { + switch (state) { + case AFOperationReadyState: + return @"isReady"; + case AFOperationExecutingState: + return @"isExecuting"; + case AFOperationFinishedState: + return @"isFinished"; + case AFOperationPausedState: + return @"isPaused"; + default: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + return @"state"; +#pragma clang diagnostic pop + } + } +} + +static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperationState toState, BOOL isCancelled) { + switch (fromState) { + case AFOperationReadyState: + switch (toState) { + case AFOperationPausedState: + case AFOperationExecutingState: + return YES; + case AFOperationFinishedState: + return isCancelled; + default: + return NO; + } + case AFOperationExecutingState: + switch (toState) { + case AFOperationPausedState: + case AFOperationFinishedState: + return YES; + default: + return NO; + } + case AFOperationFinishedState: + return NO; + case AFOperationPausedState: + return toState == AFOperationReadyState; + default: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + switch (toState) { + case AFOperationPausedState: + case AFOperationReadyState: + case AFOperationExecutingState: + case AFOperationFinishedState: + return YES; + default: + return NO; + } + } +#pragma clang diagnostic pop + } +} + +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, assign) AFOperationState state; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@property (readwrite, nonatomic, strong) NSURLConnection *connection; +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSURLResponse *response; +@property (readwrite, nonatomic, strong) NSError *error; +@property (readwrite, nonatomic, strong) NSData *responseData; +@property (readwrite, nonatomic, copy) NSString *responseString; +@property (readwrite, nonatomic, assign) NSStringEncoding responseStringEncoding; +@property (readwrite, nonatomic, assign) long long totalBytesRead; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationBackgroundTaskCleanupBlock backgroundTaskCleanup; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationChallengeBlock authenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationCacheResponseBlock cacheResponse; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse; + +- (void)operationDidStart; +- (void)finish; +- (void)cancelConnection; +@end + +@implementation AFURLConnectionOperation +@synthesize outputStream = _outputStream; + ++ (void)networkRequestThreadEntryPoint:(id)__unused object { + @autoreleasepool { + [[NSThread currentThread] setName:@"AFNetworking"]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + [runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode]; + [runLoop run]; + } +} + ++ (NSThread *)networkRequestThread { + static NSThread *_networkRequestThread = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil]; + [_networkRequestThread start]; + }); + + return _networkRequestThread; +} + +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { + NSParameterAssert(urlRequest); + + self = [super init]; + if (!self) { + return nil; + } + + _state = AFOperationReadyState; + + self.lock = [[NSRecursiveLock alloc] init]; + self.lock.name = kAFNetworkingLockName; + + self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; + + self.request = urlRequest; + + self.shouldUseCredentialStorage = YES; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + return self; +} + +- (instancetype)init NS_UNAVAILABLE +{ + return nil; +} + +- (void)dealloc { + if (_outputStream) { + [_outputStream close]; + _outputStream = nil; + } + + if (_backgroundTaskCleanup) { + _backgroundTaskCleanup(); + } +} + +#pragma mark - + +- (void)setResponseData:(NSData *)responseData { + [self.lock lock]; + if (!responseData) { + _responseData = nil; + } else { + _responseData = [NSData dataWithBytes:responseData.bytes length:responseData.length]; + } + [self.lock unlock]; +} + +- (NSString *)responseString { + [self.lock lock]; + if (!_responseString && self.response && self.responseData) { + self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding]; + } + [self.lock unlock]; + + return _responseString; +} + +- (NSStringEncoding)responseStringEncoding { + [self.lock lock]; + if (!_responseStringEncoding && self.response) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (self.response.textEncodingName) { + CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName); + if (IANAEncoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding); + } + } + + self.responseStringEncoding = stringEncoding; + } + [self.lock unlock]; + + return _responseStringEncoding; +} + +- (NSInputStream *)inputStream { + return self.request.HTTPBodyStream; +} + +- (void)setInputStream:(NSInputStream *)inputStream { + NSMutableURLRequest *mutableRequest = [self.request mutableCopy]; + mutableRequest.HTTPBodyStream = inputStream; + self.request = mutableRequest; +} + +- (NSOutputStream *)outputStream { + if (!_outputStream) { + self.outputStream = [NSOutputStream outputStreamToMemory]; + } + + return _outputStream; +} + +- (void)setOutputStream:(NSOutputStream *)outputStream { + [self.lock lock]; + if (outputStream != _outputStream) { + if (_outputStream) { + [_outputStream close]; + } + + _outputStream = outputStream; + } + [self.lock unlock]; +} + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler { + [self.lock lock]; + if (!self.backgroundTaskCleanup) { + UIApplication *application = [UIApplication sharedApplication]; + UIBackgroundTaskIdentifier __block backgroundTaskIdentifier = UIBackgroundTaskInvalid; + __weak __typeof(self)weakSelf = self; + + self.backgroundTaskCleanup = ^(){ + if (backgroundTaskIdentifier != UIBackgroundTaskInvalid) { + [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier]; + backgroundTaskIdentifier = UIBackgroundTaskInvalid; + } + }; + + backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ + __strong __typeof(weakSelf)strongSelf = weakSelf; + + if (handler) { + handler(); + } + + if (strongSelf) { + [strongSelf cancel]; + strongSelf.backgroundTaskCleanup(); + } + }]; + } + [self.lock unlock]; +} +#endif + +#pragma mark - + +- (void)setState:(AFOperationState)state { + if (!AFStateTransitionIsValid(self.state, state, [self isCancelled])) { + return; + } + + [self.lock lock]; + NSString *oldStateKey = AFKeyPathFromOperationState(self.state); + NSString *newStateKey = AFKeyPathFromOperationState(state); + + [self willChangeValueForKey:newStateKey]; + [self willChangeValueForKey:oldStateKey]; + _state = state; + [self didChangeValueForKey:oldStateKey]; + [self didChangeValueForKey:newStateKey]; + [self.lock unlock]; +} + +- (void)pause { + if ([self isPaused] || [self isFinished] || [self isCancelled]) { + return; + } + + [self.lock lock]; + if ([self isExecuting]) { + [self performSelector:@selector(operationDidPause) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + + dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); + } + + self.state = AFOperationPausedState; + [self.lock unlock]; +} + +- (void)operationDidPause { + [self.lock lock]; + [self.connection cancel]; + [self.lock unlock]; +} + +- (BOOL)isPaused { + return self.state == AFOperationPausedState; +} + +- (void)resume { + if (![self isPaused]) { + return; + } + + [self.lock lock]; + self.state = AFOperationReadyState; + + [self start]; + [self.lock unlock]; +} + +#pragma mark - + +- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block { + self.uploadProgress = block; +} + +- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block { + self.downloadProgress = block; +} + +- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block { + self.authenticationChallenge = block; +} + +- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block { + self.cacheResponse = block; +} + +- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block { + self.redirectResponse = block; +} + +#pragma mark - NSOperation + +- (void)setCompletionBlock:(void (^)(void))block { + [self.lock lock]; + if (!block) { + [super setCompletionBlock:nil]; + } else { + __weak __typeof(self)weakSelf = self; + [super setCompletionBlock:^ { + __strong __typeof(weakSelf)strongSelf = weakSelf; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_group_t group = strongSelf.completionGroup ?: url_request_operation_completion_group(); + dispatch_queue_t queue = strongSelf.completionQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + + dispatch_group_async(group, queue, ^{ + block(); + }); + + dispatch_group_notify(group, url_request_operation_completion_queue(), ^{ + [strongSelf setCompletionBlock:nil]; + }); + }]; + } + [self.lock unlock]; +} + +- (BOOL)isReady { + return self.state == AFOperationReadyState && [super isReady]; +} + +- (BOOL)isExecuting { + return self.state == AFOperationExecutingState; +} + +- (BOOL)isFinished { + return self.state == AFOperationFinishedState; +} + +- (BOOL)isConcurrent { + return YES; +} + +- (void)start { + [self.lock lock]; + if ([self isCancelled]) { + [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } else if ([self isReady]) { + self.state = AFOperationExecutingState; + + [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } + [self.lock unlock]; +} + +- (void)operationDidStart { + [self.lock lock]; + if (![self isCancelled]) { + self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + for (NSString *runLoopMode in self.runLoopModes) { + [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode]; + [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; + } + + [self.outputStream open]; + [self.connection start]; + } + [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + }); +} + +- (void)finish { + [self.lock lock]; + self.state = AFOperationFinishedState; + [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); +} + +- (void)cancel { + [self.lock lock]; + if (![self isFinished] && ![self isCancelled]) { + [super cancel]; + + if ([self isExecuting]) { + [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } + } + [self.lock unlock]; +} + +- (void)cancelConnection { + NSDictionary *userInfo = nil; + if ([self.request URL]) { + userInfo = @{NSURLErrorFailingURLErrorKey : [self.request URL]}; + } + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + + if (![self isFinished]) { + if (self.connection) { + [self.connection cancel]; + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:error]; + } else { + // Accommodate race condition where `self.connection` has not yet been set before cancellation + self.error = error; + [self finish]; + } + } +} + +#pragma mark - + ++ (NSArray *)batchOfRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock +{ + if (!operations || [operations count] == 0) { + return @[[NSBlockOperation blockOperationWithBlock:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(@[]); + } + }); + }]]; + } + + __block dispatch_group_t group = dispatch_group_create(); + NSBlockOperation *batchedOperation = [NSBlockOperation blockOperationWithBlock:^{ + dispatch_group_notify(group, dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(operations); + } + }); + }]; + + for (AFURLConnectionOperation *operation in operations) { + operation.completionGroup = group; + void (^originalCompletionBlock)(void) = [operation.completionBlock copy]; + __weak __typeof(operation)weakOperation = operation; + operation.completionBlock = ^{ + __strong __typeof(weakOperation)strongOperation = weakOperation; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_queue_t queue = strongOperation.completionQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + dispatch_group_async(group, queue, ^{ + if (originalCompletionBlock) { + originalCompletionBlock(); + } + + NSUInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger __unused idx, BOOL __unused *stop) { + return [op isFinished]; + }] count]; + + if (progressBlock) { + progressBlock(numberOfFinishedOperations, [operations count]); + } + + dispatch_group_leave(group); + }); + }; + + dispatch_group_enter(group); + [batchedOperation addDependency:operation]; + } + + return [operations arrayByAddingObject:batchedOperation]; +} + +#pragma mark - NSObject + +- (NSString *)description { + [self.lock lock]; + NSString *description = [NSString stringWithFormat:@"<%@: %p, state: %@, cancelled: %@ request: %@, response: %@>", NSStringFromClass([self class]), self, AFKeyPathFromOperationState(self.state), ([self isCancelled] ? @"YES" : @"NO"), self.request, self.response]; + [self.lock unlock]; + return description; +} + +#pragma mark - NSURLConnectionDelegate + +- (void)connection:(NSURLConnection *)connection +willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +{ + if (self.authenticationChallenge) { + self.authenticationChallenge(connection, challenge); + return; + } + + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + } else { + if ([challenge previousFailureCount] == 0) { + if (self.credential) { + [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } +} + +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + +- (NSURLRequest *)connection:(NSURLConnection *)connection + willSendRequest:(NSURLRequest *)request + redirectResponse:(NSURLResponse *)redirectResponse +{ + if (self.redirectResponse) { + return self.redirectResponse(connection, request, redirectResponse); + } else { + return request; + } +} + +- (void)connection:(NSURLConnection __unused *)connection + didSendBodyData:(NSInteger)bytesWritten + totalBytesWritten:(NSInteger)totalBytesWritten +totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite +{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.uploadProgress) { + self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } + }); +} + +- (void)connection:(NSURLConnection __unused *)connection +didReceiveResponse:(NSURLResponse *)response +{ + self.response = response; +} + +- (void)connection:(NSURLConnection __unused *)connection + didReceiveData:(NSData *)data +{ + NSUInteger length = [data length]; + while (YES) { + NSInteger totalNumberOfBytesWritten = 0; + if ([self.outputStream hasSpaceAvailable]) { + const uint8_t *dataBuffer = (uint8_t *)[data bytes]; + + NSInteger numberOfBytesWritten = 0; + while (totalNumberOfBytesWritten < (NSInteger)length) { + numberOfBytesWritten = [self.outputStream write:&dataBuffer[(NSUInteger)totalNumberOfBytesWritten] maxLength:(length - (NSUInteger)totalNumberOfBytesWritten)]; + if (numberOfBytesWritten == -1) { + break; + } + + totalNumberOfBytesWritten += numberOfBytesWritten; + } + + break; + } else { + [self.connection cancel]; + if (self.outputStream.streamError) { + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError]; + } + return; + } + } + + dispatch_async(dispatch_get_main_queue(), ^{ + self.totalBytesRead += (long long)length; + + if (self.downloadProgress) { + self.downloadProgress(length, self.totalBytesRead, self.response.expectedContentLength); + } + }); +} + +- (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection { + self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey]; + + [self.outputStream close]; + if (self.responseData) { + self.outputStream = nil; + } + + self.connection = nil; + + [self finish]; +} + +- (void)connection:(NSURLConnection __unused *)connection + didFailWithError:(NSError *)error +{ + self.error = error; + + [self.outputStream close]; + if (self.responseData) { + self.outputStream = nil; + } + + self.connection = nil; + + [self finish]; +} + +- (NSCachedURLResponse *)connection:(NSURLConnection *)connection + willCacheResponse:(NSCachedURLResponse *)cachedResponse +{ + if (self.cacheResponse) { + return self.cacheResponse(connection, cachedResponse); + } else { + if ([self isCancelled]) { + return nil; + } + + return cachedResponse; + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURLRequest *request = [decoder decodeObjectOfClass:[NSURLRequest class] forKey:NSStringFromSelector(@selector(request))]; + + self = [self initWithRequest:request]; + if (!self) { + return nil; + } + + self.state = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(state))] integerValue]; + self.response = [decoder decodeObjectOfClass:[NSHTTPURLResponse class] forKey:NSStringFromSelector(@selector(response))]; + self.error = [decoder decodeObjectOfClass:[NSError class] forKey:NSStringFromSelector(@selector(error))]; + self.responseData = [decoder decodeObjectOfClass:[NSData class] forKey:NSStringFromSelector(@selector(responseData))]; + self.totalBytesRead = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(totalBytesRead))] longLongValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [self pause]; + + [coder encodeObject:self.request forKey:NSStringFromSelector(@selector(request))]; + + switch (self.state) { + case AFOperationExecutingState: + case AFOperationPausedState: + [coder encodeInteger:AFOperationReadyState forKey:NSStringFromSelector(@selector(state))]; + break; + default: + [coder encodeInteger:self.state forKey:NSStringFromSelector(@selector(state))]; + break; + } + + [coder encodeObject:self.response forKey:NSStringFromSelector(@selector(response))]; + [coder encodeObject:self.error forKey:NSStringFromSelector(@selector(error))]; + [coder encodeObject:self.responseData forKey:NSStringFromSelector(@selector(responseData))]; + [coder encodeInt64:self.totalBytesRead forKey:NSStringFromSelector(@selector(totalBytesRead))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; + + operation.uploadProgress = self.uploadProgress; + operation.downloadProgress = self.downloadProgress; + operation.authenticationChallenge = self.authenticationChallenge; + operation.cacheResponse = self.cacheResponse; + operation.redirectResponse = self.redirectResponse; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +@end diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h b/InControl/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h new file mode 100644 index 0000000..ef4d366 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1,473 @@ +// AFURLRequestSerialization.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#endif + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary. + + For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`. + */ +@protocol AFURLRequestSerialization + +/** + Returns a request with the specified parameters encoded into a copy of the original request. + + @param request The original request. + @param parameters The parameters to be encoded. + @param error The error that occurred while attempting to encode the request parameters. + + @return A serialized request. + */ +- (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(nullable id)parameters + error:(NSError * __nullable __autoreleasing *)error; + +@end + +#pragma mark - + +/** + + */ +typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) { + AFHTTPRequestQueryStringDefaultStyle = 0, +}; + +@protocol AFMultipartFormData; + +/** + `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPRequestSerializer : NSObject + +/** + The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Whether created requests can use the device’s cellular radio (if present). `YES` by default. + + @see NSMutableURLRequest -setAllowsCellularAccess: + */ +@property (nonatomic, assign) BOOL allowsCellularAccess; + +/** + The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default. + + @see NSMutableURLRequest -setCachePolicy: + */ +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; + +/** + Whether created requests should use the default cookie handling. `YES` by default. + + @see NSMutableURLRequest -setHTTPShouldHandleCookies: + */ +@property (nonatomic, assign) BOOL HTTPShouldHandleCookies; + +/** + Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default + + @see NSMutableURLRequest -setHTTPShouldUsePipelining: + */ +@property (nonatomic, assign) BOOL HTTPShouldUsePipelining; + +/** + The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default. + + @see NSMutableURLRequest -setNetworkServiceType: + */ +@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType; + +/** + The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds. + + @see NSMutableURLRequest -setTimeoutInterval: + */ +@property (nonatomic, assign) NSTimeInterval timeoutInterval; + +///--------------------------------------- +/// @name Configuring HTTP Request Headers +///--------------------------------------- + +/** + Default HTTP header field values to be applied to serialized requests. By default, these include the following: + + - `Accept-Language` with the contents of `NSLocale +preferredLanguages` + - `User-Agent` with the contents of various bundle identifiers and OS designations + + @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +/** + Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header. + + @param field The HTTP header to set a default value for + @param value The value set as default for the specified header, or `nil` + */ +- (void)setValue:(nullable NSString *)value +forHTTPHeaderField:(NSString *)field; + +/** + Returns the value for the HTTP headers set in the request serializer. + + @param field The HTTP header to retrieve the default value for + + @return The value set as default for the specified header, or `nil` + */ +- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. + + @param username The HTTP basic auth username + @param password The HTTP basic auth password + */ +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password; + +/** + @deprecated This method has been deprecated. Use -setValue:forHTTPHeaderField: instead. + */ +- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token DEPRECATED_ATTRIBUTE; + + +/** + Clears any existing value for the "Authorization" HTTP header. + */ +- (void)clearAuthorizationHeader; + +///------------------------------------------------------- +/// @name Configuring Query String Parameter Serialization +///------------------------------------------------------- + +/** + HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. + */ +@property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; + +/** + Set the method of query string serialization according to one of the pre-defined styles. + + @param style The serialization style. + + @see AFHTTPRequestQueryStringSerializationStyle + */ +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style; + +/** + Set the a custom method of query string serialization according to the specified block. + + @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request. + */ +- (void)setQueryStringSerializationWithBlock:(nullable NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block; + +///------------------------------- +/// @name Creating Request Objects +///------------------------------- + +/** + @deprecated This method has been deprecated. Use -requestWithMethod:URLString:parameters:error: instead. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters DEPRECATED_ATTRIBUTE; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. + + If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. + + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable id)parameters + error:(NSError * __nullable __autoreleasing *)error; + +/** + @deprecated This method has been deprecated. Use -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error: instead. + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block DEPRECATED_ATTRIBUTE; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 + + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. + + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable NSDictionary *)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + error:(NSError * __nullable __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished. + + @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`. + @param fileURL The file URL to write multipart form contents to. + @param handler A handler block to execute. + + @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request. + + @see https://github.com/AFNetworking/AFNetworking/issues/1398 + */ +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(nullable void (^)(NSError * __nullable error))handler; + +@end + +#pragma mark - + +/** + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`. + */ +@protocol AFMultipartFormData + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended, otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + */ + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name; + + +/** + Appends HTTP headers, followed by the encoded data and the multipart form boundary. + + @param headers The HTTP headers to be appended to the form data. + @param body The data to be encoded and appended to the form data. This parameter must not be `nil`. + */ +- (void)appendPartWithHeaders:(nullable NSDictionary *)headers + body:(NSData *)body; + +/** + Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. + + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb. + @param delay Duration of delay each time a packet is read. By default, no delay is set. + */ +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay; + +@end + +#pragma mark - + +/** + `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`. + */ +@interface AFJSONRequestSerializer : AFHTTPRequestSerializer + +/** + Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONWritingOptions writingOptions; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param writingOptions The specified JSON writing options. + */ ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions; + +@end + +#pragma mark - + +/** + `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`. + */ +@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + @warning The `writeOptions` property is currently unused. + */ +@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param writeOptions The property list write options. + + @warning The `writeOptions` property is currently unused. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions; + +@end + +#pragma mark - + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLRequestSerializationErrorDomain` + + ### Constants + + `AFURLRequestSerializationErrorDomain` + AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLRequestErrorKey` + The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey; + +/** + ## Throttling Bandwidth for HTTP Request Input Streams + + @see -throttleBandwidthWithPacketSize:delay: + + ### Constants + + `kAFUploadStream3GSuggestedPacketSize` + Maximum packet size, in number of bytes. Equal to 16kb. + + `kAFUploadStream3GSuggestedDelay` + Duration of delay each time a packet is read. Equal to 0.2 seconds. + */ +FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize; +FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay; + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m b/InControl/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m new file mode 100644 index 0000000..e387c24 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m @@ -0,0 +1,1425 @@ +// AFURLRequestSerialization.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLRequestSerialization.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request"; +NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response"; + +typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error); + +static NSString * AFBase64EncodedStringFromString(NSString *string) { + NSData *data = [NSData dataWithBytes:[string UTF8String] length:[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]; + NSUInteger length = [data length]; + NSMutableData *mutableData = [NSMutableData dataWithLength:((length + 2) / 3) * 4]; + + uint8_t *input = (uint8_t *)[data bytes]; + uint8_t *output = (uint8_t *)[mutableData mutableBytes]; + + for (NSUInteger i = 0; i < length; i += 3) { + NSUInteger value = 0; + for (NSUInteger j = i; j < (i + 3); j++) { + value <<= 8; + if (j < length) { + value |= (0xFF & input[j]); + } + } + + static uint8_t const kAFBase64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + NSUInteger idx = (i / 3) * 4; + output[idx + 0] = kAFBase64EncodingTable[(value >> 18) & 0x3F]; + output[idx + 1] = kAFBase64EncodingTable[(value >> 12) & 0x3F]; + output[idx + 2] = (i + 1) < length ? kAFBase64EncodingTable[(value >> 6) & 0x3F] : '='; + output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '='; + } + + return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding]; +} + +/** + Returns a percent-escaped string following RFC 3986 for a query string key or value. + RFC 3986 states that the following characters are "reserved" characters. + - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + should be percent-escaped in the query string. + - parameter string: The string to be percent-escaped. + - returns: The percent-escaped string. + */ +static NSString * AFPercentEscapedStringFromString(NSString *string) { + static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4 + static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;="; + + NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; + [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]]; + + // FIXME: https://github.com/AFNetworking/AFNetworking/pull/3028 + // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + + static NSUInteger const batchSize = 50; + + NSInteger index = 0; + NSMutableString *escaped = @"".mutableCopy; + + while (index < string.length) { + NSUInteger length = MIN(string.length - index, batchSize); + NSRange range = NSMakeRange(index, length); + + // To avoid breaking up character sequences such as 👴🏻👮🏽 + range = [string rangeOfComposedCharacterSequencesForRange:range]; + + NSString *substring = [string substringWithRange:range]; + NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + [escaped appendString:encoded]; + + index += range.length; + } + + return escaped; +} + +#pragma mark - + +@interface AFQueryStringPair : NSObject +@property (readwrite, nonatomic, strong) id field; +@property (readwrite, nonatomic, strong) id value; + +- (id)initWithField:(id)field value:(id)value; + +- (NSString *)URLEncodedStringValue; +@end + +@implementation AFQueryStringPair + +- (id)initWithField:(id)field value:(id)value { + self = [super init]; + if (!self) { + return nil; + } + + self.field = field; + self.value = value; + + return self; +} + +- (NSString *)URLEncodedStringValue { + if (!self.value || [self.value isEqual:[NSNull null]]) { + return AFPercentEscapedStringFromString([self.field description]); + } else { + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedStringFromString([self.field description]), AFPercentEscapedStringFromString([self.value description])]; + } +} + +@end + +#pragma mark - + +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary); +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value); + +static NSString * AFQueryStringFromParameters(NSDictionary *parameters) { + NSMutableArray *mutablePairs = [NSMutableArray array]; + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + [mutablePairs addObject:[pair URLEncodedStringValue]]; + } + + return [mutablePairs componentsJoinedByString:@"&"]; +} + +NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) { + return AFQueryStringPairsFromKeyAndValue(nil, dictionary); +} + +NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; + + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)]; + + if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = dictionary[nestedKey]; + if (nestedValue) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; + } + } + } else if ([value isKindOfClass:[NSArray class]]) { + NSArray *array = value; + for (id nestedValue in array) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; + } + } else { + [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; + } + + return mutableQueryStringComponents; +} + +#pragma mark - + +@interface AFStreamingMultipartFormData : NSObject +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding; + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; +@end + +#pragma mark - + +static NSArray * AFHTTPRequestSerializerObservedKeyPaths() { + static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))]; + }); + + return _AFHTTPRequestSerializerObservedKeyPaths; +} + +static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext; + +@interface AFHTTPRequestSerializer () +@property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders; +@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle; +@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization; +@end + +@implementation AFHTTPRequestSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary]; + + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + float q = 1.0f - (idx * 0.1f); + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; + *stop = q <= 0.5f; + }]; + [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; + + NSString *userAgent = nil; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" +#if TARGET_OS_IOS + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif TARGET_OS_WATCH + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]]; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; +#endif +#pragma clang diagnostic pop + if (userAgent) { + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { + NSMutableString *mutableUserAgent = [userAgent mutableCopy]; + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { + userAgent = mutableUserAgent; + } + } + [self setValue:userAgent forHTTPHeaderField:@"User-Agent"]; + } + + // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html + self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil]; + + self.mutableObservedChangedKeyPaths = [NSMutableSet set]; + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext]; + } + } + + return self; +} + +- (void)dealloc { + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext]; + } + } +} + +#pragma mark - + +// Workarounds for crashing behavior using Key-Value Observing with XCTest +// See https://github.com/AFNetworking/AFNetworking/issues/2523 + +- (void)setAllowsCellularAccess:(BOOL)allowsCellularAccess { + [self willChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; + _allowsCellularAccess = allowsCellularAccess; + [self didChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; +} + +- (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy { + [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; + _cachePolicy = cachePolicy; + [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; +} + +- (void)setHTTPShouldHandleCookies:(BOOL)HTTPShouldHandleCookies { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; + _HTTPShouldHandleCookies = HTTPShouldHandleCookies; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; +} + +- (void)setHTTPShouldUsePipelining:(BOOL)HTTPShouldUsePipelining { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; + _HTTPShouldUsePipelining = HTTPShouldUsePipelining; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; +} + +- (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType { + [self willChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; + _networkServiceType = networkServiceType; + [self didChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; +} + +- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval { + [self willChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; + _timeoutInterval = timeoutInterval; + [self didChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; +} + +#pragma mark - + +- (NSDictionary *)HTTPRequestHeaders { + return [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders]; +} + +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field +{ + [self.mutableHTTPRequestHeaders setValue:value forKey:field]; +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + return [self.mutableHTTPRequestHeaders valueForKey:field]; +} + +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password +{ + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password]; + [self setValue:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)] forHTTPHeaderField:@"Authorization"]; +} + +- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token { + [self setValue:[NSString stringWithFormat:@"Token token=\"%@\"", token] forHTTPHeaderField:@"Authorization"]; +} + +- (void)clearAuthorizationHeader { + [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; +} + +#pragma mark - + +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style { + self.queryStringSerializationStyle = style; + self.queryStringSerialization = nil; +} + +- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, id, NSError *__autoreleasing *))block { + self.queryStringSerialization = block; +} + +#pragma mark - + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters +{ + return [self requestWithMethod:method URLString:URLString parameters:parameters error:nil]; +} + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(URLString); + + NSURL *url = [NSURL URLWithString:URLString]; + + NSParameterAssert(url); + + NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url]; + mutableRequest.HTTPMethod = method; + + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) { + [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath]; + } + } + + mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy]; + + return mutableRequest; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block +{ + return [self multipartFormRequestWithMethod:method URLString:URLString parameters:parameters constructingBodyWithBlock:block error:nil]; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); + + NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error]; + + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding]; + + if (parameters) { + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + NSData *data = nil; + if ([pair.value isKindOfClass:[NSData class]]) { + data = pair.value; + } else if ([pair.value isEqual:[NSNull null]]) { + data = [NSData data]; + } else { + data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; + } + + if (data) { + [formData appendPartWithFormData:data name:[pair.field description]]; + } + } + } + + if (block) { + block(formData); + } + + return [formData requestByFinalizingMultipartFormData]; +} + +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler +{ + NSParameterAssert(request.HTTPBodyStream); + NSParameterAssert([fileURL isFileURL]); + + NSInputStream *inputStream = request.HTTPBodyStream; + NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO]; + __block NSError *error = nil; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputStream open]; + [outputStream open]; + + while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) { + uint8_t buffer[1024]; + + NSInteger bytesRead = [inputStream read:buffer maxLength:1024]; + if (inputStream.streamError || bytesRead < 0) { + error = inputStream.streamError; + break; + } + + NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead]; + if (outputStream.streamError || bytesWritten < 0) { + error = outputStream.streamError; + break; + } + + if (bytesRead == 0 && bytesWritten == 0) { + break; + } + } + + [outputStream close]; + [inputStream close]; + + if (handler) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler(error); + }); + } + }); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + mutableRequest.HTTPBodyStream = nil; + + return mutableRequest; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + NSString *query = nil; + if (parameters) { + if (self.queryStringSerialization) { + NSError *serializationError; + query = self.queryStringSerialization(request, parameters, &serializationError); + + if (serializationError) { + if (error) { + *error = serializationError; + } + + return nil; + } + } else { + switch (self.queryStringSerializationStyle) { + case AFHTTPRequestQueryStringDefaultStyle: + query = AFQueryStringFromParameters(parameters); + break; + } + } + } + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + if (query) { + mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]]; + } + } else { + // #2864: an empty string is a valid x-www-form-urlencoded payload + if (!query) { + query = @""; + } + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + } + [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]]; + } + + return mutableRequest; +} + +#pragma mark - NSKeyValueObserving + ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key { + if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) { + return NO; + } + + return [super automaticallyNotifiesObserversForKey:key]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(__unused id)object + change:(NSDictionary *)change + context:(void *)context +{ + if (context == AFHTTPRequestSerializerObserverContext) { + if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) { + [self.mutableObservedChangedKeyPaths removeObject:keyPath]; + } else { + [self.mutableObservedChangedKeyPaths addObject:keyPath]; + } + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy]; + self.queryStringSerializationStyle = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; + [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; + serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; + serializer.queryStringSerialization = self.queryStringSerialization; + + return serializer; +} + +@end + +#pragma mark - + +static NSString * AFCreateMultipartFormBoundary() { + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; +} + +static NSString * const kAFMultipartFormCRLF = @"\r\n"; + +static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFContentTypeForPathExtension(NSString *extension) { +#ifdef __UTTYPE__ + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } +#else +#pragma unused (extension) + return @"application/octet-stream"; +#endif +} + +NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16; +NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; + +@interface AFHTTPBodyPart : NSObject +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSDictionary *headers; +@property (nonatomic, copy) NSString *boundary; +@property (nonatomic, strong) id body; +@property (nonatomic, assign) unsigned long long bodyContentLength; +@property (nonatomic, strong) NSInputStream *inputStream; + +@property (nonatomic, assign) BOOL hasInitialBoundary; +@property (nonatomic, assign) BOOL hasFinalBoundary; + +@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (readonly, nonatomic, assign) unsigned long long contentLength; + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@interface AFMultipartBodyStream : NSInputStream +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (readonly, nonatomic, assign) unsigned long long contentLength; +@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; + +- (id)initWithStringEncoding:(NSStringEncoding)encoding; +- (void)setInitialAndFinalBoundaries; +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; +@end + +#pragma mark - + +@interface AFStreamingMultipartFormData () +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, copy) NSString *boundary; +@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; +@end + +@implementation AFStreamingMultipartFormData + +- (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding +{ + self = [super init]; + if (!self) { + return nil; + } + + self.request = urlRequest; + self.stringEncoding = encoding; + self.boundary = AFCreateMultipartFormBoundary(); + self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; + + return self; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + + NSString *fileName = [fileURL lastPathComponent]; + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + if (![fileURL isFileURL]) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error]; + if (!fileAttributes) { + return NO; + } + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = fileURL; + bodyPart.bodyContentLength = [fileAttributes[NSFileSize] unsignedLongLongValue]; + [self.bodyStream appendHTTPBodyPart:bodyPart]; + + return YES; +} + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = (unsigned long long)length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name +{ + NSParameterAssert(name); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body +{ + NSParameterAssert(body); + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = headers; + bodyPart.boundary = self.boundary; + bodyPart.bodyContentLength = [body length]; + bodyPart.body = body; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay +{ + self.bodyStream.numberOfBytesInPacket = numberOfBytes; + self.bodyStream.delay = delay; +} + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { + if ([self.bodyStream isEmpty]) { + return self.request; + } + + // Reset the initial and final boundaries to ensure correct Content-Length + [self.bodyStream setInitialAndFinalBoundaries]; + [self.request setHTTPBodyStream:self.bodyStream]; + + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; + + return self.request; +} + +@end + +#pragma mark - + +@interface NSStream () +@property (readwrite) NSStreamStatus streamStatus; +@property (readwrite, copy) NSError *streamError; +@end + +@interface AFMultipartBodyStream () +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts; +@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; +@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; +@property (readwrite, nonatomic, strong) NSOutputStream *outputStream; +@property (readwrite, nonatomic, strong) NSMutableData *buffer; +@end + +@implementation AFMultipartBodyStream +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-atomic-properties" +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100) +@synthesize delegate; +#endif +@synthesize streamStatus; +@synthesize streamError; +#pragma clang diagnostic pop + +- (id)initWithStringEncoding:(NSStringEncoding)encoding { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = encoding; + self.HTTPBodyParts = [NSMutableArray array]; + self.numberOfBytesInPacket = NSIntegerMax; + + return self; +} + +- (void)setInitialAndFinalBoundaries { + if ([self.HTTPBodyParts count] > 0) { + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + bodyPart.hasInitialBoundary = NO; + bodyPart.hasFinalBoundary = NO; + } + + [[self.HTTPBodyParts firstObject] setHasInitialBoundary:YES]; + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; + } +} + +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { + [self.HTTPBodyParts addObject:bodyPart]; +} + +- (BOOL)isEmpty { + return [self.HTTPBodyParts count] == 0; +} + +#pragma mark - NSInputStream + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + if ([self streamStatus] == NSStreamStatusClosed) { + return 0; + } + + NSInteger totalNumberOfBytesRead = 0; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) { + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { + break; + } + } else { + NSUInteger maxLength = length - (NSUInteger)totalNumberOfBytesRead; + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength]; + if (numberOfBytesRead == -1) { + self.streamError = self.currentHTTPBodyPart.inputStream.streamError; + break; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } + } + } + } +#pragma clang diagnostic pop + + return totalNumberOfBytesRead; +} + +- (BOOL)getBuffer:(__unused uint8_t **)buffer + length:(__unused NSUInteger *)len +{ + return NO; +} + +- (BOOL)hasBytesAvailable { + return [self streamStatus] == NSStreamStatusOpen; +} + +#pragma mark - NSStream + +- (void)open { + if (self.streamStatus == NSStreamStatusOpen) { + return; + } + + self.streamStatus = NSStreamStatusOpen; + + [self setInitialAndFinalBoundaries]; + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; +} + +- (void)close { + self.streamStatus = NSStreamStatusClosed; +} + +- (id)propertyForKey:(__unused NSString *)key { + return nil; +} + +- (BOOL)setProperty:(__unused id)property + forKey:(__unused NSString *)key +{ + return NO; +} + +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + length += [bodyPart contentLength]; + } + + return length; +} + +#pragma mark - Undocumented CFReadStream Bridged Methods + +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { + return NO; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + +@end + +#pragma mark - + +typedef enum { + AFEncapsulationBoundaryPhase = 1, + AFHeaderPhase = 2, + AFBodyPhase = 3, + AFFinalBoundaryPhase = 4, +} AFHTTPBodyPartReadPhase; + +@interface AFHTTPBodyPart () { + AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; + unsigned long long _phaseReadOffset; +} + +- (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@implementation AFHTTPBodyPart + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + [self transitionToNextPhase]; + + return self; +} + +- (void)dealloc { + if (_inputStream) { + [_inputStream close]; + _inputStream = nil; + } +} + +- (NSInputStream *)inputStream { + if (!_inputStream) { + if ([self.body isKindOfClass:[NSData class]]) { + _inputStream = [NSInputStream inputStreamWithData:self.body]; + } else if ([self.body isKindOfClass:[NSURL class]]) { + _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } else if ([self.body isKindOfClass:[NSInputStream class]]) { + _inputStream = self.body; + } else { + _inputStream = [NSInputStream inputStreamWithData:[NSData data]]; + } + } + + return _inputStream; +} + +- (NSString *)stringForHeaders { + NSMutableString *headerString = [NSMutableString string]; + for (NSString *field in [self.headers allKeys]) { + [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; + } + [headerString appendString:kAFMultipartFormCRLF]; + + return [NSString stringWithString:headerString]; +} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + length += [encapsulationBoundaryData length]; + + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + length += [headersData length]; + + length += _bodyContentLength; + + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + length += [closingBoundaryData length]; + + return length; +} + +- (BOOL)hasBytesAvailable { + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer + if (_phase == AFFinalBoundaryPhase) { + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (self.inputStream.streamStatus) { + case NSStreamStatusNotOpen: + case NSStreamStatusOpening: + case NSStreamStatusOpen: + case NSStreamStatusReading: + case NSStreamStatusWriting: + return YES; + case NSStreamStatusAtEnd: + case NSStreamStatusClosed: + case NSStreamStatusError: + default: + return NO; + } +#pragma clang diagnostic pop +} + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + NSInteger totalNumberOfBytesRead = 0; + + if (_phase == AFEncapsulationBoundaryPhase) { + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFHeaderPhase) { + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFBodyPhase) { + NSInteger numberOfBytesRead = 0; + + numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + if (numberOfBytesRead == -1) { + return -1; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) { + [self transitionToNextPhase]; + } + } + } + + if (_phase == AFFinalBoundaryPhase) { + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + return totalNumberOfBytesRead; +} + +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); + [data getBytes:buffer range:range]; +#pragma clang diagnostic pop + + _phaseReadOffset += range.length; + + if (((NSUInteger)_phaseReadOffset) >= [data length]) { + [self transitionToNextPhase]; + } + + return (NSInteger)range.length; +} + +- (BOOL)transitionToNextPhase { + if (![[NSThread currentThread] isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self transitionToNextPhase]; + }); + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (_phase) { + case AFEncapsulationBoundaryPhase: + _phase = AFHeaderPhase; + break; + case AFHeaderPhase: + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; + [self.inputStream open]; + _phase = AFBodyPhase; + break; + case AFBodyPhase: + [self.inputStream close]; + _phase = AFFinalBoundaryPhase; + break; + case AFFinalBoundaryPhase: + default: + _phase = AFEncapsulationBoundaryPhase; + break; + } + _phaseReadOffset = 0; +#pragma clang diagnostic pop + + return YES; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + bodyPart.boundary = self.boundary; + + return bodyPart; +} + +@end + +#pragma mark - + +@implementation AFJSONRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithWritingOptions:(NSJSONWritingOptions)0]; +} + ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions +{ + AFJSONRequestSerializer *serializer = [[self alloc] init]; + serializer.writingOptions = writingOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.writingOptions = self.writingOptions; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFPropertyListRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions +{ + AFPropertyListRequestSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.writeOptions = writeOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerializer + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.format = self.format; + serializer.writeOptions = self.writeOptions; + + return serializer; +} + +@end diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h b/InControl/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h new file mode 100644 index 0000000..1396cfb --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1,311 @@ +// AFURLResponseSerialization.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. + + For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. + */ +@protocol AFURLResponseSerialization + +/** + The response object decoded from the data associated with a specified response. + + @param response The response to be processed. + @param data The response data to be decoded. + @param error The error that occurred while attempting to decode the response data. + + @return The object decoded from the specified response data. + */ +- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response + data:(nullable NSData *)data + error:(NSError * __nullable __autoreleasing *)error; + +@end + +#pragma mark - + +/** + `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPResponseSerializer : NSObject + +- (instancetype)init; + +/** + The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +///----------------------------------------- +/// @name Configuring Response Serialization +///----------------------------------------- + +/** + The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. + + See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + */ +@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes; + +/** + The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. + */ +@property (nonatomic, copy, nullable) NSSet *acceptableContentTypes; + +/** + Validates the specified response and data. + + In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. + + @param response The response to be validated. + @param data The data associated with the response. + @param error The error that occurred while attempting to validate the response. + + @return `YES` if the response is valid, otherwise `NO`. + */ +- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response + data:(nullable NSData *)data + error:(NSError * __nullable __autoreleasing *)error; + +@end + +#pragma mark - + + +/** + `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. + + By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: + + - `application/json` + - `text/json` + - `text/javascript` + */ +@interface AFJSONResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONReadingOptions readingOptions; + +/** + Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL removesKeysWithNullValues; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param readingOptions The specified JSON reading options. + */ ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; + +@end + +#pragma mark - + +/** + `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. + + By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +/** + `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSUInteger options; + +/** + Creates and returns an XML document serializer with the specified options. + + @param mask The XML document options. + */ ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; + +@end + +#endif + +#pragma mark - + +/** + `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFPropertyListResponseSerializer` accepts the following MIME types: + + - `application/x-plist` + */ +@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." + */ +@property (nonatomic, assign) NSPropertyListReadOptions readOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param readOptions The property list reading options. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions; + +@end + +#pragma mark - + +/** + `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. + + By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: + + - `image/tiff` + - `image/jpeg` + - `image/gif` + - `image/png` + - `image/ico` + - `image/x-icon` + - `image/bmp` + - `image/x-bmp` + - `image/x-xbitmap` + - `image/x-win-bitmap` + */ +@interface AFImageResponseSerializer : AFHTTPResponseSerializer + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +/** + The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. + */ +@property (nonatomic, assign) CGFloat imageScale; + +/** + Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. + */ +@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; +#endif + +@end + +#pragma mark - + +/** + `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. + */ +@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer + +/** + The component response serializers. + */ +@property (readonly, nonatomic, copy) NSArray *responseSerializers; + +/** + Creates and returns a compound serializer comprised of the specified response serializers. + + @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. + */ ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLResponseSerializationErrorDomain` + + ### Constants + + `AFURLResponseSerializationErrorDomain` + AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` + - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLResponseErrorKey` + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + + `AFNetworkingOperationFailingURLResponseDataErrorKey` + The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey; + +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m b/InControl/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m new file mode 100644 index 0000000..f95834f --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m @@ -0,0 +1,825 @@ +// AFURLResponseSerialization.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLResponseSerialization.h" + +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#import +#endif + +NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response"; +NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response"; +NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data"; + +static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) { + if (!error) { + return underlyingError; + } + + if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) { + return error; + } + + NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy]; + mutableUserInfo[NSUnderlyingErrorKey] = underlyingError; + + return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo]; +} + +static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) { + if ([error.domain isEqualToString:domain] && error.code == code) { + return YES; + } else if (error.userInfo[NSUnderlyingErrorKey]) { + return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain); + } + + return NO; +} + +static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { + if ([JSONObject isKindOfClass:[NSArray class]]) { + NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; + for (id value in (NSArray *)JSONObject) { + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; + } else if ([JSONObject isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject]; + for (id key in [(NSDictionary *)JSONObject allKeys]) { + id value = (NSDictionary *)JSONObject[key]; + if (!value || [value isEqual:[NSNull null]]) { + [mutableDictionary removeObjectForKey:key]; + } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) { + mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions); + } + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary]; + } + + return JSONObject; +} + +@implementation AFHTTPResponseSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; + self.acceptableContentTypes = nil; + + return self; +} + +#pragma mark - + +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError * __autoreleasing *)error +{ + BOOL responseIsValid = YES; + NSError *validationError = nil; + + if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) { + if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) { + if ([data length] > 0 && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError); + } + + responseIsValid = NO; + } + + if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError); + + responseIsValid = NO; + } + } + + if (error && !responseIsValid) { + *error = validationError; + } + + return responseIsValid; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + [self validateResponse:(NSHTTPURLResponse *)response data:data error:error]; + + return data; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; + serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFJSONResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithReadingOptions:(NSJSONReadingOptions)0]; +} + ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions { + AFJSONResponseSerializer *serializer = [[self alloc] init]; + serializer.readingOptions = readingOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. + // See https://github.com/rails/rails/issues/1742 + NSStringEncoding stringEncoding = self.stringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + id responseObject = nil; + NSError *serializationError = nil; + @autoreleasepool { + NSString *responseString = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (responseString && ![responseString isEqualToString:@" "]) { + // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character + // See http://stackoverflow.com/a/12843465/157142 + data = [responseString dataUsingEncoding:NSUTF8StringEncoding]; + + if (data) { + if ([data length] > 0) { + responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError]; + } else { + return nil; + } + } else { + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"Data failed decoding as a UTF-8 string", @"AFNetworking", nil), + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Could not decode string: %@", @"AFNetworking", nil), responseString] + }; + + serializationError = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; + } + } + } + + if (self.removesKeysWithNullValues && responseObject) { + responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions); + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue]; + self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))]; + [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.readingOptions = self.readingOptions; + serializer.removesKeysWithNullValues = self.removesKeysWithNullValues; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFXMLParserResponseSerializer + ++ (instancetype)serializer { + AFXMLParserResponseSerializer *serializer = [[self alloc] init]; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + return [[NSXMLParser alloc] initWithData:data]; +} + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +@implementation AFXMLDocumentResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithXMLDocumentOptions:0]; +} + ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask { + AFXMLDocumentResponseSerializer *serializer = [[self alloc] init]; + serializer.options = mask; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + NSError *serializationError = nil; + NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError]; + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return document; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.options = self.options; + + return serializer; +} + +@end + +#endif + +#pragma mark - + +@implementation AFPropertyListResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions +{ + AFPropertyListResponseSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.readOptions = readOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + id responseObject; + NSError *serializationError = nil; + + if (data) { + responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError]; + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.format = self.format; + serializer.readOptions = self.readOptions; + + return serializer; +} + +@end + +#pragma mark - + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import + +@interface UIImage (AFNetworkingSafeImageLoading) ++ (UIImage *)af_safeImageWithData:(NSData *)data; +@end + +static NSLock* imageLock = nil; + +@implementation UIImage (AFNetworkingSafeImageLoading) + ++ (UIImage *)af_safeImageWithData:(NSData *)data { + UIImage* image = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + imageLock = [[NSLock alloc] init]; + }); + + [imageLock lock]; + image = [UIImage imageWithData:data]; + [imageLock unlock]; + return image; +} + +@end + +static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { + UIImage *image = [UIImage af_safeImageWithData:data]; + if (image.images) { + return image; + } + + return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; +} + +static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { + if (!data || [data length] == 0) { + return nil; + } + + CGImageRef imageRef = NULL; + CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); + + if ([response.MIMEType isEqualToString:@"image/png"]) { + imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) { + imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + + if (imageRef) { + CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef); + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace); + + // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale + if (imageColorSpaceModel == kCGColorSpaceModelCMYK) { + CGImageRelease(imageRef); + imageRef = NULL; + } + } + } + + CGDataProviderRelease(dataProvider); + + UIImage *image = AFImageWithDataAtScale(data, scale); + if (!imageRef) { + if (image.images || !image) { + return image; + } + + imageRef = CGImageCreateCopy([image CGImage]); + if (!imageRef) { + return nil; + } + } + + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); + + if (width * height > 1024 * 1024 || bitsPerComponent > 8) { + CGImageRelease(imageRef); + + return image; + } + + // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate + size_t bytesPerRow = 0; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + + if (colorSpaceModel == kCGColorSpaceModelRGB) { + uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" + if (alpha == kCGImageAlphaNone) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaNoneSkipFirst; + } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaPremultipliedFirst; + } +#pragma clang diagnostic pop + } + + CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); + + CGColorSpaceRelease(colorSpace); + + if (!context) { + CGImageRelease(imageRef); + + return image; + } + + CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef); + CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation]; + + CGImageRelease(inflatedImageRef); + CGImageRelease(imageRef); + + return inflatedImage; +} +#endif + + +@implementation AFImageResponseSerializer + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil]; + +#if TARGET_OS_IOS + self.imageScale = [[UIScreen mainScreen] scale]; + self.automaticallyInflatesResponseImage = YES; +#elif TARGET_OS_WATCH + self.imageScale = [[WKInterfaceDevice currentDevice] screenScale]; + self.automaticallyInflatesResponseImage = YES; +#endif + + return self; +} + +#pragma mark - AFURLResponseSerializer + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + if (self.automaticallyInflatesResponseImage) { + return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale); + } else { + return AFImageWithDataAtScale(data, self.imageScale); + } +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + // Ensure that the image is set to it's correct pixel width and height + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data]; + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; + [image addRepresentation:bitimage]; + + return image; +#endif + + return nil; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))]; +#if CGFLOAT_IS_DOUBLE + self.imageScale = [imageScale doubleValue]; +#else + self.imageScale = [imageScale floatValue]; +#endif + + self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))]; + [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + serializer.imageScale = self.imageScale; + serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage; +#endif + + return serializer; +} + +@end + +#pragma mark - + +@interface AFCompoundResponseSerializer () +@property (readwrite, nonatomic, copy) NSArray *responseSerializers; +@end + +@implementation AFCompoundResponseSerializer + ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers { + AFCompoundResponseSerializer *serializer = [[self alloc] init]; + serializer.responseSerializers = responseSerializers; + + return serializer; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + for (id serializer in self.responseSerializers) { + if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) { + continue; + } + + NSError *serializerError = nil; + id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError]; + if (responseObject) { + if (error) { + *error = AFErrorWithUnderlyingError(serializerError, *error); + } + + return responseObject; + } + } + + return [super responseObjectForResponse:response data:data error:error]; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.responseSerializers = self.responseSerializers; + + return serializer; +} + +@end diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h b/InControl/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h new file mode 100644 index 0000000..70e4ec9 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h @@ -0,0 +1,554 @@ +// AFURLSessionManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#if !TARGET_OS_WATCH +#import "AFNetworkReachabilityManager.h" +#endif + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + + ## Subclassing Notes + + This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead. + + ## NSURLSession & NSURLSessionTask Delegate Methods + + `AFURLSessionManager` implements the following delegate methods: + + ### `NSURLSessionDelegate` + + - `URLSession:didBecomeInvalidWithError:` + - `URLSession:didReceiveChallenge:completionHandler:` + - `URLSessionDidFinishEventsForBackgroundURLSession:` + + ### `NSURLSessionTaskDelegate` + + - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:` + - `URLSession:task:didReceiveChallenge:completionHandler:` + - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` + - `URLSession:task:didCompleteWithError:` + + ### `NSURLSessionDataDelegate` + + - `URLSession:dataTask:didReceiveResponse:completionHandler:` + - `URLSession:dataTask:didBecomeDownloadTask:` + - `URLSession:dataTask:didReceiveData:` + - `URLSession:dataTask:willCacheResponse:completionHandler:` + + ### `NSURLSessionDownloadDelegate` + + - `URLSession:downloadTask:didFinishDownloadingToURL:` + - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:` + - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSCoding Caveats + + - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`. + + ## NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original. + - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +NS_ASSUME_NONNULL_BEGIN + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || TARGET_OS_WATCH + +@interface AFURLSessionManager : NSObject + +/** + The managed session. + */ +@property (readonly, nonatomic, strong) NSURLSession *session; + +/** + The operation queue on which delegate callbacks are run. + */ +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; + +/** + Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) id responseSerializer; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created request operations to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +#if !TARGET_OS_WATCH +///-------------------------------------- +/// @name Monitoring Network Reachability +///-------------------------------------- + +/** + The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; +#endif + +///---------------------------- +/// @name Getting Session Tasks +///---------------------------- + +/** + The data, upload, and download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *tasks; + +/** + The data tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *dataTasks; + +/** + The upload tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *uploadTasks; + +/** + The download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *downloadTasks; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign, nullable) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_HAVE_OBJC_SUPPORT +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign, nullable) dispatch_group_t completionGroup; +#endif + +///--------------------------------- +/// @name Working Around System Bugs +///--------------------------------- + +/** + Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default. + + @bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again. + + @see https://github.com/AFNetworking/AFNetworking/issues/1675 + */ +@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a manager for a session created with the specified configuration. This is the designated initializer. + + @param configuration The configuration used to create the managed session. + + @return A manager for a newly-created session. + */ +- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +/** + Invalidates the managed session, optionally canceling pending tasks. + + @param cancelPendingTasks Whether or not to cancel pending tasks. + */ +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks; + +///------------------------- +/// @name Running Data Tasks +///------------------------- + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(nullable void (^)(NSURLResponse *response, id __nullable responseObject, NSError * __nullable error))completionHandler; + +///--------------------------- +/// @name Running Upload Tasks +///--------------------------- + +/** + Creates an `NSURLSessionUploadTask` with the specified request for a local file. + + @param request The HTTP request for the request. + @param fileURL A URL to the local file to be uploaded. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + + @see `attemptsToRecreateUploadTasksForBackgroundSessions` + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + completionHandler:(nullable void (^)(NSURLResponse *response, id __nullable responseObject, NSError * __nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body. + + @param request The HTTP request for the request. + @param bodyData A data object containing the HTTP body to be uploaded. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(nullable NSData *)bodyData + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + completionHandler:(nullable void (^)(NSURLResponse *response, id __nullable responseObject, NSError * __nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified streaming request. + + @param request The HTTP request for the request. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + completionHandler:(nullable void (^)(NSURLResponse *response, id __nullable responseObject, NSError * __nullable error))completionHandler; + +///----------------------------- +/// @name Running Download Tasks +///----------------------------- + +/** + Creates an `NSURLSessionDownloadTask` with the specified request. + + @param request The HTTP request for the request. + @param progress A progress object monitoring the current download progress. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + + @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * __nullable filePath, NSError * __nullable error))completionHandler; + +/** + Creates an `NSURLSessionDownloadTask` with the specified resume data. + + @param resumeData The data used to resume downloading. + @param progress A progress object monitoring the current download progress. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * __nullable filePath, NSError * __nullable error))completionHandler; + +///--------------------------------- +/// @name Getting Progress for Tasks +///--------------------------------- + +/** + Returns the upload progress of the specified task. + + @param uploadTask The session upload task. Must not be `nil`. + + @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask; + +/** + Returns the download progress of the specified task. + + @param downloadTask The session download task. Must not be `nil`. + + @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask; + +///----------------------------------------- +/// @name Setting Session Delegate Callbacks +///----------------------------------------- + +/** + Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`. + + @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation. + */ +- (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block; + +/** + Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __nullable __autoreleasing * __nullable credential))block; + +///-------------------------------------- +/// @name Setting Task Delegate Callbacks +///-------------------------------------- + +/** + Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`. + + @param block A block object to be executed when a task requires a new request body stream. + */ +- (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block; + +/** + Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`. + + @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response. + */ +- (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block; + +/** + Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __nullable __autoreleasing * __nullable credential))block; + +/** + Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block; + +/** + Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`. + + @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task. + */ +- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * __nullable error))block; + +///------------------------------------------- +/// @name Setting Data Task Delegate Callbacks +///------------------------------------------- + +/** + Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`. + + @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response. + */ +- (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block; + +/** + Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`. + + @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become. + */ +- (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block; + +/** + Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block; + +/** + Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`. + + @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response. + */ +- (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block; + +/** + Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`. + + @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session. + */ +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block; + +///----------------------------------------------- +/// @name Setting Download Task Delegate Callbacks +///----------------------------------------------- + +/** + Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`. + + @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error. + */ +- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block; + +/** + Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`. + + @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block; + +/** + Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. + + @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded. + */ +- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; + +@end + +#endif + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when a task begins executing. + + @deprecated Use `AFNetworkingTaskDidResumeNotification` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidStartNotification DEPRECATED_ATTRIBUTE; + +/** + Posted when a task resumes. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + + @deprecated Use `AFNetworkingTaskDidCompleteNotification` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishNotification DEPRECATED_ATTRIBUTE; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification; + +/** + Posted when a task suspends its execution. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification; + +/** + Posted when a session is invalidated. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification; + +/** + Posted when a session download task encountered an error when moving the temporary download file to a specified destination. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. + + @deprecated Use `AFNetworkingTaskDidCompleteResponseDataKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishResponseDataKey DEPRECATED_ATTRIBUTE; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. + + @deprecated Use `AFNetworkingTaskDidCompleteSerializedResponseKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishSerializedResponseKey DEPRECATED_ATTRIBUTE; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. + + @deprecated Use `AFNetworkingTaskDidCompleteResponseSerializerKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishResponseSerializerKey DEPRECATED_ATTRIBUTE; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. + + @deprecated Use `AFNetworkingTaskDidCompleteAssetPathKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishAssetPathKey DEPRECATED_ATTRIBUTE; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. + + @deprecated Use `AFNetworkingTaskDidCompleteErrorKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishErrorKey DEPRECATED_ATTRIBUTE; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m b/InControl/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m new file mode 100644 index 0000000..eb28959 --- /dev/null +++ b/InControl/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m @@ -0,0 +1,1171 @@ +// AFURLSessionManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLSessionManager.h" +#import + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +static dispatch_queue_t url_session_manager_creation_queue() { + static dispatch_queue_t af_url_session_manager_creation_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_creation_queue = dispatch_queue_create("com.alamofire.networking.session.manager.creation", DISPATCH_QUEUE_SERIAL); + }); + + return af_url_session_manager_creation_queue; +} + +static dispatch_queue_t url_session_manager_processing_queue() { + static dispatch_queue_t af_url_session_manager_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_url_session_manager_processing_queue; +} + +static dispatch_group_t url_session_manager_completion_group() { + static dispatch_group_t af_url_session_manager_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_completion_group = dispatch_group_create(); + }); + + return af_url_session_manager_completion_group; +} + +NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume"; +NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete"; +NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend"; +NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate"; +NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error"; + +NSString * const AFNetworkingTaskDidStartNotification = @"com.alamofire.networking.task.resume"; // Deprecated +NSString * const AFNetworkingTaskDidFinishNotification = @"com.alamofire.networking.task.complete"; // Deprecated + +NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; +NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; +NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; +NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error"; +NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; + +NSString * const AFNetworkingTaskDidFinishSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; // Deprecated +NSString * const AFNetworkingTaskDidFinishResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; // Deprecated +NSString * const AFNetworkingTaskDidFinishResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; // Deprecated +NSString * const AFNetworkingTaskDidFinishErrorKey = @"com.alamofire.networking.task.complete.error"; // Deprecated +NSString * const AFNetworkingTaskDidFinishAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; // Deprecated + +static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock"; + +static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3; + +static void * AFTaskStateChangedContext = &AFTaskStateChangedContext; + +typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); + +typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); +typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session); + +typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task); +typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend); +typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error); + +typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response); +typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask); +typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data); +typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse); + +typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location); +typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); +typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes); + +typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error); + +#pragma mark - + +@interface AFURLSessionManagerTaskDelegate : NSObject +@property (nonatomic, weak) AFURLSessionManager *manager; +@property (nonatomic, strong) NSMutableData *mutableData; +@property (nonatomic, strong) NSProgress *progress; +@property (nonatomic, copy) NSURL *downloadFileURL; +@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler; +@end + +@implementation AFURLSessionManagerTaskDelegate + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.mutableData = [NSMutableData data]; + + self.progress = [NSProgress progressWithTotalUnitCount:0]; + + return self; +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + task:(__unused NSURLSessionTask *)task + didSendBodyData:(__unused int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + self.progress.totalUnitCount = totalBytesExpectedToSend; + self.progress.completedUnitCount = totalBytesSent; +} + +- (void)URLSession:(__unused NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + __strong AFURLSessionManager *manager = self.manager; + + __block id responseObject = nil; + + __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer; + + //Performance Improvement from #2672 + NSData *data = nil; + if (self.mutableData) { + data = [self.mutableData copy]; + //We no longer need the reference, so nil it out to gain back some memory. + self.mutableData = nil; + } + + if (self.downloadFileURL) { + userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; + } else if (data) { + userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data; + } + + if (error) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = error; + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, error); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + } else { + dispatch_async(url_session_manager_processing_queue(), ^{ + NSError *serializationError = nil; + responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:data error:&serializationError]; + + if (self.downloadFileURL) { + responseObject = self.downloadFileURL; + } + + if (responseObject) { + userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject; + } + + if (serializationError) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError; + } + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, serializationError); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + }); + } +#pragma clang diagnostic pop +} + +#pragma mark - NSURLSessionDataTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + dataTask:(__unused NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + [self.mutableData appendData:data]; +} + +#pragma mark - NSURLSessionDownloadTaskDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + NSError *fileManagerError = nil; + self.downloadFileURL = nil; + + if (self.downloadTaskDidFinishDownloading) { + self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (self.downloadFileURL) { + [[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]; + + if (fileManagerError) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo]; + } + } + } +} + +- (void)URLSession:(__unused NSURLSession *)session + downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask + didWriteData:(__unused int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + self.progress.totalUnitCount = totalBytesExpectedToWrite; + self.progress.completedUnitCount = totalBytesWritten; +} + +- (void)URLSession:(__unused NSURLSession *)session + downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes { + self.progress.totalUnitCount = expectedTotalBytes; + self.progress.completedUnitCount = fileOffset; +} + +@end + +#pragma mark - + +/** + * A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`. + * + * See: + * - https://github.com/AFNetworking/AFNetworking/issues/1477 + * - https://github.com/AFNetworking/AFNetworking/issues/2638 + * - https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + +static inline void af_swizzleSelector(Class class, SEL originalSelector, SEL swizzledSelector) { + Method originalMethod = class_getInstanceMethod(class, originalSelector); + Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); + method_exchangeImplementations(originalMethod, swizzledMethod); +} + +static inline BOOL af_addMethod(Class class, SEL selector, Method method) { + return class_addMethod(class, selector, method_getImplementation(method), method_getTypeEncoding(method)); +} + +static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume"; +static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend"; + +@interface _AFURLSessionTaskSwizzling : NSObject + +@end + +@implementation _AFURLSessionTaskSwizzling + ++ (void)load { + /** + WARNING: Trouble Ahead + https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + + if (NSClassFromString(@"NSURLSessionTask")) { + /** + iOS 7 and iOS 8 differ in NSURLSessionTask implementation, which makes the next bit of code a bit tricky. + Many Unit Tests have been built to validate as much of this behavior has possible. + Here is what we know: + - NSURLSessionTasks are implemented with class clusters, meaning the class you request from the API isn't actually the type of class you will get back. + - Simply referencing `[NSURLSessionTask class]` will not work. You need to ask an `NSURLSession` to actually create an object, and grab the class from there. + - On iOS 7, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `__NSCFURLSessionTask`. + - On iOS 8, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `NSURLSessionTask`. + - On iOS 7, `__NSCFLocalSessionTask` and `__NSCFURLSessionTask` are the only two classes that have their own implementations of `resume` and `suspend`, and `__NSCFLocalSessionTask` DOES NOT CALL SUPER. This means both classes need to be swizzled. + - On iOS 8, `NSURLSessionTask` is the only class that implements `resume` and `suspend`. This means this is the only class that needs to be swizzled. + - Because `NSURLSessionTask` is not involved in the class hierarchy for every version of iOS, its easier to add the swizzled methods to a dummy class and manage them there. + + Some Assumptions: + - No implementations of `resume` or `suspend` call super. If this were to change in a future version of iOS, we'd need to handle it. + - No background task classes override `resume` or `suspend` + + The current solution: + 1) Grab an instance of `__NSCFLocalDataTask` by asking an instance of `NSURLSession` for a data task. + 2) Grab a pointer to the original implementation of `af_resume` + 3) Check to see if the current class has an implementation of resume. If so, continue to step 4. + 4) Grab the super class of the current class. + 5) Grab a pointer for the current class to the current implementation of `resume`. + 6) Grab a pointer for the super class to the current implementation of `resume`. + 7) If the current class implementation of `resume` is not equal to the super class implementation of `resume` AND the current implementation of `resume` is not equal to the original implementation of `af_resume`, THEN swizzle the methods + 8) Set the current class to the super class, and repeat steps 3-8 + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnonnull" + NSURLSessionDataTask *localDataTask = [[NSURLSession sessionWithConfiguration:nil] dataTaskWithURL:nil]; +#pragma clang diagnostic pop + IMP originalAFResumeIMP = method_getImplementation(class_getInstanceMethod([self class], @selector(af_resume))); + Class currentClass = [localDataTask class]; + + while (class_getInstanceMethod(currentClass, @selector(resume))) { + Class superClass = [currentClass superclass]; + IMP classResumeIMP = method_getImplementation(class_getInstanceMethod(currentClass, @selector(resume))); + IMP superclassResumeIMP = method_getImplementation(class_getInstanceMethod(superClass, @selector(resume))); + if (classResumeIMP != superclassResumeIMP && + originalAFResumeIMP != classResumeIMP) { + [self swizzleResumeAndSuspendMethodForClass:currentClass]; + } + currentClass = [currentClass superclass]; + } + + [localDataTask cancel]; + } +} + ++ (void)swizzleResumeAndSuspendMethodForClass:(Class)class { + Method afResumeMethod = class_getInstanceMethod(self, @selector(af_resume)); + Method afSuspendMethod = class_getInstanceMethod(self, @selector(af_suspend)); + + if (af_addMethod(class, @selector(af_resume), afResumeMethod)) { + af_swizzleSelector(class, @selector(resume), @selector(af_resume)); + } + + if (af_addMethod(class, @selector(af_suspend), afSuspendMethod)) { + af_swizzleSelector(class, @selector(suspend), @selector(af_suspend)); + } +} + +- (NSURLSessionTaskState)state { + NSAssert(NO, @"State method should never be called in the actual dummy class"); + return NSURLSessionTaskStateCanceling; +} + +- (void)af_resume { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_resume]; + + if (state != NSURLSessionTaskStateRunning) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self]; + } +} + +- (void)af_suspend { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_suspend]; + + if (state != NSURLSessionTaskStateSuspended) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self]; + } +} +@end + +#pragma mark - + +@interface AFURLSessionManager () +@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; +@property (readwrite, nonatomic, strong) NSURLSession *session; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier; +@property (readonly, nonatomic, copy) NSString *taskDescriptionForSessionTasks; +@property (readwrite, nonatomic, strong) NSLock *lock; +@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid; +@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession; +@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume; +@end + +@implementation AFURLSessionManager + +- (instancetype)init { + return [self initWithSessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + self = [super init]; + if (!self) { + return nil; + } + + if (!configuration) { + configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + } + + self.sessionConfiguration = configuration; + + self.operationQueue = [[NSOperationQueue alloc] init]; + self.operationQueue.maxConcurrentOperationCount = 1; + + self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue]; + + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + +#if !TARGET_OS_WATCH + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; +#endif + + self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init]; + + self.lock = [[NSLock alloc] init]; + self.lock.name = AFURLSessionManagerLockName; + + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + for (NSURLSessionDataTask *task in dataTasks) { + [self addDelegateForDataTask:task completionHandler:nil]; + } + + for (NSURLSessionUploadTask *uploadTask in uploadTasks) { + [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil]; + } + + for (NSURLSessionDownloadTask *downloadTask in downloadTasks) { + [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil]; + } + }]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:nil]; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +#pragma mark - + +- (NSString *)taskDescriptionForSessionTasks { + return [NSString stringWithFormat:@"%p", self]; +} + +- (void)taskDidResume:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task]; + }); + } + } +} + +- (void)taskDidSuspend:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task]; + }); + } + } +} + +#pragma mark - + +- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = nil; + [self.lock lock]; + delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)]; + [self.lock unlock]; + + return delegate; +} + +- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate + forTask:(NSURLSessionTask *)task +{ + NSParameterAssert(task); + NSParameterAssert(delegate); + + [self.lock lock]; + self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate; + [self.lock unlock]; +} + +- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + dataTask.taskDescription = self.taskDescriptionForSessionTasks; + [self setDelegate:delegate forTask:dataTask]; +} + +- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + int64_t totalUnitCount = uploadTask.countOfBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [uploadTask.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t)[contentLength longLongValue]; + } + } + + if (delegate.progress) { + delegate.progress.totalUnitCount = totalUnitCount; + } else { + delegate.progress = [NSProgress progressWithTotalUnitCount:totalUnitCount]; + } + + delegate.progress.pausingHandler = ^{ + [uploadTask suspend]; + }; + delegate.progress.cancellationHandler = ^{ + [uploadTask cancel]; + }; + + if (progress) { + *progress = delegate.progress; + } + + uploadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:uploadTask]; +} + +- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + if (destination) { + delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) { + return destination(location, task.response); + }; + } + + if (progress) { + *progress = delegate.progress; + } + + downloadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:downloadTask]; +} + +- (void)removeDelegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + [self.lock lock]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)]; + [self.lock unlock]; +} + +- (void)removeAllDelegates { + [self.lock lock]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeAllObjects]; + [self.lock unlock]; +} + +#pragma mark - + +- (NSArray *)tasksForKeyPath:(NSString *)keyPath { + __block NSArray *tasks = nil; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) { + tasks = dataTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) { + tasks = uploadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) { + tasks = downloadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) { + tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; + } + + dispatch_semaphore_signal(semaphore); + }]; + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + + return tasks; +} + +- (NSArray *)tasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)dataTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)uploadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)downloadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +#pragma mark - + +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks { + dispatch_async(dispatch_get_main_queue(), ^{ + if (cancelPendingTasks) { + [self.session invalidateAndCancel]; + } else { + [self.session finishTasksAndInvalidate]; + } + }); +} + +#pragma mark - + +- (void)setResponseSerializer:(id )responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionDataTask *dataTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + dataTask = [self.session dataTaskWithRequest:request]; + }); + + [self addDelegateForDataTask:dataTask completionHandler:completionHandler]; + + return dataTask; +} + +#pragma mark - + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + }); + + if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) { + for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) { + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + } + } + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData]; + }); + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithStreamedRequest:request]; + }); + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +#pragma mark - + +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + downloadTask = [self.session downloadTaskWithRequest:request]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + downloadTask = [self.session downloadTaskWithResumeData:resumeData]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +#pragma mark - + +- (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask { + return [[self delegateForTask:uploadTask] progress]; +} + +- (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask { + return [[self delegateForTask:downloadTask] progress]; +} + +#pragma mark - + +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block { + self.sessionDidBecomeInvalid = block; +} + +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.sessionDidReceiveAuthenticationChallenge = block; +} + +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block { + self.didFinishEventsForBackgroundURLSession = block; +} + +#pragma mark - + +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block { + self.taskNeedNewBodyStream = block; +} + +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block { + self.taskWillPerformHTTPRedirection = block; +} + +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.taskDidReceiveAuthenticationChallenge = block; +} + +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block { + self.taskDidSendBodyData = block; +} + +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block { + self.taskDidComplete = block; +} + +#pragma mark - + +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block { + self.dataTaskDidReceiveResponse = block; +} + +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block { + self.dataTaskDidBecomeDownloadTask = block; +} + +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block { + self.dataTaskDidReceiveData = block; +} + +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block { + self.dataTaskWillCacheResponse = block; +} + +#pragma mark - + +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block { + self.downloadTaskDidFinishDownloading = block; +} + +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block { + self.downloadTaskDidWriteData = block; +} + +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block { + self.downloadTaskDidResume = block; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue]; +} + +- (BOOL)respondsToSelector:(SEL)selector { + if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) { + return self.taskWillPerformHTTPRedirection != nil; + } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) { + return self.dataTaskDidReceiveResponse != nil; + } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) { + return self.dataTaskWillCacheResponse != nil; + } else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) { + return self.didFinishEventsForBackgroundURLSession != nil; + } + + return [[self class] instancesRespondToSelector:selector]; +} + +#pragma mark - NSURLSessionDelegate + +- (void)URLSession:(NSURLSession *)session +didBecomeInvalidWithError:(NSError *)error +{ + if (self.sessionDidBecomeInvalid) { + self.sessionDidBecomeInvalid(session, error); + } + + [self removeAllDelegates]; + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session]; +} + +- (void)URLSession:(NSURLSession *)session +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.sessionDidReceiveAuthenticationChallenge) { + disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + if (credential) { + disposition = NSURLSessionAuthChallengeUseCredential; + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +willPerformHTTPRedirection:(NSHTTPURLResponse *)response + newRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLRequest *))completionHandler +{ + NSURLRequest *redirectRequest = request; + + if (self.taskWillPerformHTTPRedirection) { + redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request); + } + + if (completionHandler) { + completionHandler(redirectRequest); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.taskDidReceiveAuthenticationChallenge) { + disposition = self.taskDidReceiveAuthenticationChallenge(session, task, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + disposition = NSURLSessionAuthChallengeUseCredential; + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler +{ + NSInputStream *inputStream = nil; + + if (self.taskNeedNewBodyStream) { + inputStream = self.taskNeedNewBodyStream(session, task); + } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + inputStream = [task.originalRequest.HTTPBodyStream copy]; + } + + if (completionHandler) { + completionHandler(inputStream); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + didSendBodyData:(int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + + int64_t totalUnitCount = totalBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t) [contentLength longLongValue]; + } + } + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + [delegate URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalUnitCount]; + + if (self.taskDidSendBodyData) { + self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + + // delegate may be nil when completing a task in the background + if (delegate) { + [delegate URLSession:session task:task didCompleteWithError:error]; + + [self removeDelegateForTask:task]; + } + + if (self.taskDidComplete) { + self.taskDidComplete(session, task, error); + } + +} + +#pragma mark - NSURLSessionDataDelegate + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didReceiveResponse:(NSURLResponse *)response + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler +{ + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; + + if (self.dataTaskDidReceiveResponse) { + disposition = self.dataTaskDidReceiveResponse(session, dataTask, response); + } + + if (completionHandler) { + completionHandler(disposition); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + if (delegate) { + [self removeDelegateForTask:dataTask]; + [self setDelegate:delegate forTask:downloadTask]; + } + + if (self.dataTaskDidBecomeDownloadTask) { + self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + [delegate URLSession:session dataTask:dataTask didReceiveData:data]; + + if (self.dataTaskDidReceiveData) { + self.dataTaskDidReceiveData(session, dataTask, data); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + willCacheResponse:(NSCachedURLResponse *)proposedResponse + completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler +{ + NSCachedURLResponse *cachedResponse = proposedResponse; + + if (self.dataTaskWillCacheResponse) { + cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse); + } + + if (completionHandler) { + completionHandler(cachedResponse); + } +} + +- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { + if (self.didFinishEventsForBackgroundURLSession) { + dispatch_async(dispatch_get_main_queue(), ^{ + self.didFinishEventsForBackgroundURLSession(session); + }); + } +} + +#pragma mark - NSURLSessionDownloadDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + if (self.downloadTaskDidFinishDownloading) { + NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (fileURL) { + delegate.downloadFileURL = fileURL; + NSError *error = nil; + [[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]; + if (error) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo]; + } + + return; + } + } + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location]; + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didWriteData:(int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + [delegate URLSession:session downloadTask:downloadTask didWriteData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite]; + + if (self.downloadTaskDidWriteData) { + self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + [delegate URLSession:session downloadTask:downloadTask didResumeAtOffset:fileOffset expectedTotalBytes:expectedTotalBytes]; + + if (self.downloadTaskDidResume) { + self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes); + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + + self = [self initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/LICENSE b/InControl/Pods/AFNetworking/LICENSE new file mode 100644 index 0000000..91f125b --- /dev/null +++ b/InControl/Pods/AFNetworking/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/InControl/Pods/AFNetworking/README.md b/InControl/Pods/AFNetworking/README.md new file mode 100644 index 0000000..f25efe0 --- /dev/null +++ b/InControl/Pods/AFNetworking/README.md @@ -0,0 +1,394 @@ +

+ AFNetworking +

+ +[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking) + +AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. + +Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. + +Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did! + +## How To Get Started + +- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps +- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki) +- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking +- Read the [AFNetworking 2.0 Migration Guide](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide) for an overview of the architectural changes from 1.0. + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). +- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + +### Installation with CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects. See the ["Getting Started" guide for more information](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking). + +#### Podfile + +```ruby +platform :ios, '7.0' +pod "AFNetworking", "~> 2.0" +``` + +## Requirements + +| AFNetworking Version | Minimum iOS Target | Minimum OS X Target | Notes | +|:--------------------:|:---------------------------:|:----------------------------:|:-------------------------------------------------------------------------:| +| 2.x | iOS 6 | OS X 10.8 | Xcode 5 is required. `NSURLSession` subspec requires iOS 7 or OS X 10.9. | +| [1.x](https://github.com/AFNetworking/AFNetworking/tree/1.x) | iOS 5 | Mac OS X 10.7 | | +| [0.10.x](https://github.com/AFNetworking/AFNetworking/tree/0.10.x) | iOS 4 | Mac OS X 10.6 | | + +(OS X projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)). + +> Programming in Swift? Try [Alamofire](https://github.com/Alamofire/Alamofire) for a more conventional set of APIs. + +## Architecture + +### NSURLConnection + +- `AFURLConnectionOperation` +- `AFHTTPRequestOperation` +- `AFHTTPRequestOperationManager` + +### NSURLSession _(iOS 7 / Mac OS X 10.9)_ + +- `AFURLSessionManager` +- `AFHTTPSessionManager` + +### Serialization + +* `` + - `AFHTTPRequestSerializer` + - `AFJSONRequestSerializer` + - `AFPropertyListRequestSerializer` +* `` + - `AFHTTPResponseSerializer` + - `AFJSONResponseSerializer` + - `AFXMLParserResponseSerializer` + - `AFXMLDocumentResponseSerializer` _(Mac OS X)_ + - `AFPropertyListResponseSerializer` + - `AFImageResponseSerializer` + - `AFCompoundResponseSerializer` + +### Additional Functionality + +- `AFSecurityPolicy` +- `AFNetworkReachabilityManager` + +## Usage + +### HTTP Request Operation Manager + +`AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management. + +#### `GET` Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +[manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +#### `POST` URL-Form-Encoded Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +NSDictionary *parameters = @{@"foo": @"bar"}; +[manager POST:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +#### `POST` Multi-Part Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +NSDictionary *parameters = @{@"foo": @"bar"}; +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +[manager POST:@"http://example.com/resources.json" parameters:parameters constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:filePath name:@"image" error:nil]; +} success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"Success: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +--- + +### AFURLSessionManager + +`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + +#### Creating a Download Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { + NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; + return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; +} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) { + NSLog(@"File downloaded to: %@", filePath); +}]; +[downloadTask resume]; +``` + +#### Creating an Upload Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"Success: %@ %@", response, responseObject); + } +}]; +[uploadTask resume]; +``` + +#### Creating an Upload Task for a Multi-Part Request, with Progress + +```objective-c +NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil]; + } error:nil]; + +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; +NSProgress *progress = nil; + +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; + +[uploadTask resume]; +``` + +#### Creating a Data Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; +[dataTask resume]; +``` + +--- + +### Request Serialization + +Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body. + +```objective-c +NSString *URLString = @"http://example.com"; +NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]}; +``` + +#### Query String Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil]; +``` + + GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### URL Form Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; +``` + + POST http://example.com/ + Content-Type: application/x-www-form-urlencoded + + foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### JSON Parameter Encoding + +```objective-c +[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; +``` + + POST http://example.com/ + Content-Type: application/json + + {"foo": "bar", "baz": [1,2,3]} + +--- + +### Network Reachability Manager + +`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + +* Do not use Reachability to determine if the original request should be sent. + * You should try to send it. +* You can use Reachability to determine when a request should be automatically retried. + * Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something. +* Network reachability is a useful tool for determining why a request might have failed. + * After a network request has failed, telling the user they're offline is better than giving them a more technical but accurate error, such as "request timed out." + +See also [WWDC 2012 session 706, "Networking Best Practices."](https://developer.apple.com/videos/wwdc/2012/#706). + +#### Shared Network Reachability + +```objective-c +[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status)); +}]; + +[[AFNetworkReachabilityManager sharedManager] startMonitoring]; +``` + +#### HTTP Manager Reachability + +```objective-c +NSURL *baseURL = [NSURL URLWithString:@"http://example.com/"]; +AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL]; + +NSOperationQueue *operationQueue = manager.operationQueue; +[manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusReachableViaWWAN: + case AFNetworkReachabilityStatusReachableViaWiFi: + [operationQueue setSuspended:NO]; + break; + case AFNetworkReachabilityStatusNotReachable: + default: + [operationQueue setSuspended:YES]; + break; + } +}]; + +[manager.reachabilityManager startMonitoring]; +``` + +--- + +### Security Policy + +`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + +Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. + +#### Allowing Invalid SSL Certificates + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production +``` + +--- + +### AFHTTPRequestOperation + +`AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. + +Although `AFHTTPRequestOperationManager` is usually the best way to go about making requests, `AFHTTPRequestOperation` can be used by itself. + +#### `GET` with `AFHTTPRequestOperation` + +```objective-c +NSURL *URL = [NSURL URLWithString:@"http://example.com/resources/123.json"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; +AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request]; +op.responseSerializer = [AFJSONResponseSerializer serializer]; +[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +[[NSOperationQueue mainQueue] addOperation:op]; +``` + +#### Batch of Operations + +```objective-c +NSMutableArray *mutableOperations = [NSMutableArray array]; +for (NSURL *fileURL in filesToUpload) { + NSURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:fileURL name:@"images[]" error:nil]; + }]; + + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + + [mutableOperations addObject:operation]; +} + +NSArray *operations = [AFURLConnectionOperation batchOfRequestOperations:@[...] progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) { + NSLog(@"%lu of %lu complete", numberOfFinishedOperations, totalNumberOfOperations); +} completionBlock:^(NSArray *operations) { + NSLog(@"All operations in batch complete"); +}]; +[[NSOperationQueue mainQueue] addOperations:operations waitUntilFinished:NO]; +``` + +## Unit Tests + +AFNetworking includes a suite of unit tests within the Tests subdirectory. In order to run the unit tests, you must install the testing dependencies via [CocoaPods](http://cocoapods.org/): + + $ cd Tests + $ pod install + +Once testing dependencies are installed, you can execute the test suite via the 'iOS Tests' and 'OS X Tests' schemes within Xcode. + +### Running Tests from the Command Line + +Tests can also be run from the command line or within a continuous integration environment. The [`xcpretty`](https://github.com/mneorr/xcpretty) utility needs to be installed before running the tests from the command line: + + $ gem install xcpretty + +Once `xcpretty` is installed, you can execute the suite via `rake test`. + +## Credits + +AFNetworking is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org). + +AFNetworking was originally created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](http://en.wikipedia.org/wiki/Gowalla). + +AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/). + +And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/contributors). + +### Security Disclosure + +If you believe you have identified a security vulnerability with AFNetworking, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker. + +## License + +AFNetworking is released under the MIT license. See LICENSE for details. diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 100644 index 0000000..3c7649b --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1,80 @@ +// AFNetworkActivityIndicatorManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. + + You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: + + [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; + + By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. + + See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: + http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 + */ +NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") +@interface AFNetworkActivityIndicatorManager : NSObject + +/** + A Boolean value indicating whether the manager is enabled. + + If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. + */ +@property (nonatomic, assign, getter = isEnabled) BOOL enabled; + +/** + A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. + */ +@property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; + +/** + Returns the shared network activity indicator manager object for the system. + + @return The systemwide network activity indicator manager. + */ ++ (instancetype)sharedManager; + +/** + Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. + */ +- (void)incrementActivityCount; + +/** + Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. + */ +- (void)decrementActivityCount; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m b/InControl/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m new file mode 100644 index 0000000..cf13180 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m @@ -0,0 +1,170 @@ +// AFNetworkActivityIndicatorManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkActivityIndicatorManager.h" + +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) + +#import "AFHTTPRequestOperation.h" + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 +#import "AFURLSessionManager.h" +#endif + +static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; + +static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { + if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) { + return [(AFURLConnectionOperation *)[notification object] request]; + } + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 + if ([[notification object] respondsToSelector:@selector(originalRequest)]) { + return [(NSURLSessionTask *)[notification object] originalRequest]; + } +#endif + + return nil; +} + +@interface AFNetworkActivityIndicatorManager () +@property (readwrite, nonatomic, assign) NSInteger activityCount; +@property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; +@property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; + +- (void)updateNetworkActivityIndicatorVisibility; +- (void)updateNetworkActivityIndicatorVisibilityDelayed; +@end + +@implementation AFNetworkActivityIndicatorManager +@dynamic networkActivityIndicatorVisible; + ++ (instancetype)sharedManager { + static AFNetworkActivityIndicatorManager *_sharedManager = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _sharedManager = [[self alloc] init]; + }); + + return _sharedManager; +} + ++ (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { + return [NSSet setWithObject:@"activityCount"]; +} + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; +#endif + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [_activityIndicatorVisibilityTimer invalidate]; +} + +- (void)updateNetworkActivityIndicatorVisibilityDelayed { + if (self.enabled) { + // Delay hiding of activity indicator for a short interval, to avoid flickering + if (![self isNetworkActivityIndicatorVisible]) { + [self.activityIndicatorVisibilityTimer invalidate]; + self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; + } else { + [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; + } + } +} + +- (BOOL)isNetworkActivityIndicatorVisible { + return self.activityCount > 0; +} + +- (void)updateNetworkActivityIndicatorVisibility { + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; +} + +- (void)setActivityCount:(NSInteger)activityCount { + @synchronized(self) { + _activityCount = activityCount; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); +} + +- (void)incrementActivityCount { + [self willChangeValueForKey:@"activityCount"]; + @synchronized(self) { + _activityCount++; + } + [self didChangeValueForKey:@"activityCount"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); +} + +- (void)decrementActivityCount { + [self willChangeValueForKey:@"activityCount"]; + @synchronized(self) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + _activityCount = MAX(_activityCount - 1, 0); +#pragma clang diagnostic pop + } + [self didChangeValueForKey:@"activityCount"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); +} + +- (void)networkRequestDidStart:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self incrementActivityCount]; + } +} + +- (void)networkRequestDidFinish:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self decrementActivityCount]; + } +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 100644 index 0000000..0c8f9b5 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1,63 @@ +// UIActivityIndicatorView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +@class AFURLConnectionOperation; + +/** + This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task. + */ +@interface UIActivityIndicatorView (AFNetworking) + +///---------------------------------- +/// @name Animating for Session Tasks +///---------------------------------- + +/** + Binds the animating state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; +#endif + +///--------------------------------------- +/// @name Animating for Request Operations +///--------------------------------------- + +/** + Binds the animating state to the execution state of the specified operation. + + @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setAnimatingWithStateOfOperation:(nullable AFURLConnectionOperation *)operation; + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m new file mode 100644 index 0000000..dd362b0 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m @@ -0,0 +1,171 @@ +// UIActivityIndicatorView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIActivityIndicatorView+AFNetworking.h" +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFHTTPRequestOperation.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +#import "AFURLSessionManager.h" +#endif + +@interface AFActivityIndicatorViewNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; +#endif +- (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation; + +@end + +@implementation UIActivityIndicatorView (AFNetworking) + +- (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { + AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; +} +#endif + +- (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { + [[self af_notificationObserver] setAnimatingWithStateOfOperation:operation]; +} + +@end + +@implementation AFActivityIndicatorViewNotificationObserver + +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView +{ + self = [super init]; + if (self) { + _activityIndicatorView = activityIndicatorView; + } + return self; +} + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { + if (task.state != NSURLSessionTaskStateCompleted) { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (task.state == NSURLSessionTaskStateRunning) { + [self.activityIndicatorView startAnimating]; + } else { + [self.activityIndicatorView stopAnimating]; + } +#pragma clang diagnostic pop + + [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; + } + } +} +#endif + +#pragma mark - + +- (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; + + if (operation) { + if (![operation isFinished]) { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if ([operation isExecuting]) { + [self.activityIndicatorView startAnimating]; + } else { + [self.activityIndicatorView stopAnimating]; + } +#pragma clang diagnostic pop + + [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation]; + } + } +} + +#pragma mark - + +- (void)af_startAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.activityIndicatorView startAnimating]; +#pragma clang diagnostic pop + }); +} + +- (void)af_stopAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.activityIndicatorView stopAnimating]; +#pragma clang diagnostic pop + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +#endif + + [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h new file mode 100644 index 0000000..97f5622 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h @@ -0,0 +1,99 @@ +// UIAlertView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFURLConnectionOperation; + +/** + This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error. + */ +@interface UIAlertView (AFNetworking) + +///------------------------------------- +/// @name Showing Alert for Session Task +///------------------------------------- + +/** + Shows an alert view with the error of the specified session task, if any. + + @param task The session task. + @param delegate The alert view delegate. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 ++ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task + delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); +#endif + +/** + Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. + + @param task The session task. + @param delegate The alert view delegate. + @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. + @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 ++ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task + delegate:(nullable id)delegate + cancelButtonTitle:(nullable NSString *)cancelButtonTitle + otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); +#endif + +///------------------------------------------ +/// @name Showing Alert for Request Operation +///------------------------------------------ + +/** + Shows an alert view with the error of the specified request operation, if any. + + @param operation The request operation. + @param delegate The alert view delegate. + */ ++ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation + delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); + +/** + Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. + + @param operation The request operation. + @param delegate The alert view delegate. + @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. + @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. + */ ++ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation + delegate:(nullable id)delegate + cancelButtonTitle:(nullable NSString *)cancelButtonTitle + otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m new file mode 100644 index 0000000..0d1e9e7 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m @@ -0,0 +1,141 @@ +// UIAlertView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIAlertView+AFNetworking.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFURLConnectionOperation.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +#import "AFURLSessionManager.h" +#endif + +static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) { + if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) { + *title = error.localizedDescription; + + if (error.localizedRecoverySuggestion) { + *message = error.localizedRecoverySuggestion; + } else { + *message = error.localizedFailureReason; + } + } else if (error.localizedDescription) { + *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); + *message = error.localizedDescription; + } else { + *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); + *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code]; + } +} + +@implementation UIAlertView (AFNetworking) + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 ++ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task + delegate:(id)delegate +{ + [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; +} + ++ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task + delegate:(id)delegate + cancelButtonTitle:(NSString *)cancelButtonTitle + otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION +{ + NSMutableArray *mutableOtherTitles = [NSMutableArray array]; + va_list otherButtonTitleList; + va_start(otherButtonTitleList, otherButtonTitles); + { + for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { + [mutableOtherTitles addObject:otherButtonTitle]; + } + } + va_end(otherButtonTitleList); + + __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { + NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey]; + if (error) { + NSString *title, *message; + AFGetAlertViewTitleAndMessageFromError(error, &title, &message); + + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; + for (NSString *otherButtonTitle in mutableOtherTitles) { + [alertView addButtonWithTitle:otherButtonTitle]; + } + [alertView setTitle:title]; + [alertView setMessage:message]; + [alertView show]; + } + + [[NSNotificationCenter defaultCenter] removeObserver:observer]; + }]; +} +#endif + +#pragma mark - + ++ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation + delegate:(id)delegate +{ + [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; +} + ++ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation + delegate:(id)delegate + cancelButtonTitle:(NSString *)cancelButtonTitle + otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION +{ + NSMutableArray *mutableOtherTitles = [NSMutableArray array]; + va_list otherButtonTitleList; + va_start(otherButtonTitleList, otherButtonTitles); + { + for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { + [mutableOtherTitles addObject:otherButtonTitle]; + } + } + va_end(otherButtonTitleList); + + __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { + + if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) { + NSError *error = [(AFURLConnectionOperation *)notification.object error]; + if (error) { + NSString *title, *message; + AFGetAlertViewTitleAndMessageFromError(error, &title, &message); + + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; + for (NSString *otherButtonTitle in mutableOtherTitles) { + [alertView addButtonWithTitle:otherButtonTitle]; + } + [alertView setTitle:title]; + [alertView setMessage:message]; + [alertView show]; + } + } + + [[NSNotificationCenter defaultCenter] removeObserver:observer]; + }]; +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h new file mode 100644 index 0000000..7289bdb --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1,186 @@ +// UIButton+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol AFURLResponseSerialization, AFImageCache; + +/** + This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL. + + @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported. + */ +@interface UIButton (AFNetworking) + +///---------------------------- +/// @name Accessing Image Cache +///---------------------------- + +/** + The image cache used to improve image loading performance on scroll views. By default, `UIButton` will use the `sharedImageCache` of `UIImageView`. + */ ++ (id )sharedImageCache; + +/** + Set the cache used for image loading. + + @param imageCache The image cache. + */ ++ (void)setSharedImageCache:(__nullable id )imageCache; + +///------------------------------------ +/// @name Accessing Response Serializer +///------------------------------------ + +/** + The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. + + @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer + */ +@property (nonatomic, strong) id imageResponseSerializer; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the image request. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. + @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(nullable void (^)(NSError *error))failure; + + +///------------------------------- +/// @name Setting Background Image +///------------------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled. + + If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the background image request. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + @param state The control state. + @param url The URL used for the background image request. + @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. + @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(nullable void (^)(NSError *error))failure; + + +///------------------------------ +/// @name Canceling Image Loading +///------------------------------ + +/** + Cancels any executing image operation for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelImageRequestOperationForState:(UIControlState)state; + +/** + Cancels any executing background image operation for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelBackgroundImageRequestOperationForState:(UIControlState)state; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m new file mode 100644 index 0000000..e5c36a5 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m @@ -0,0 +1,293 @@ +// UIButton+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIButton+AFNetworking.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFURLResponseSerialization.h" +#import "AFHTTPRequestOperation.h" + +#import "UIImageView+AFNetworking.h" + +@interface UIButton (_AFNetworking) +@end + +@implementation UIButton (_AFNetworking) + ++ (NSOperationQueue *)af_sharedImageRequestOperationQueue { + static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init]; + _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; + }); + + return _af_sharedImageRequestOperationQueue; +} + +#pragma mark - + +static char AFImageRequestOperationNormal; +static char AFImageRequestOperationHighlighted; +static char AFImageRequestOperationSelected; +static char AFImageRequestOperationDisabled; + +static const char * af_imageRequestOperationKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFImageRequestOperationHighlighted; + case UIControlStateSelected: + return &AFImageRequestOperationSelected; + case UIControlStateDisabled: + return &AFImageRequestOperationDisabled; + case UIControlStateNormal: + default: + return &AFImageRequestOperationNormal; + } +} + +- (AFHTTPRequestOperation *)af_imageRequestOperationForState:(UIControlState)state { + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, af_imageRequestOperationKeyForState(state)); +} + +- (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_imageRequestOperationKeyForState(state), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +static char AFBackgroundImageRequestOperationNormal; +static char AFBackgroundImageRequestOperationHighlighted; +static char AFBackgroundImageRequestOperationSelected; +static char AFBackgroundImageRequestOperationDisabled; + +static const char * af_backgroundImageRequestOperationKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFBackgroundImageRequestOperationHighlighted; + case UIControlStateSelected: + return &AFBackgroundImageRequestOperationSelected; + case UIControlStateDisabled: + return &AFBackgroundImageRequestOperationDisabled; + case UIControlStateNormal: + default: + return &AFBackgroundImageRequestOperationNormal; + } +} + +- (AFHTTPRequestOperation *)af_backgroundImageRequestOperationForState:(UIControlState)state { + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, af_backgroundImageRequestOperationKeyForState(state)); +} + +- (void)af_setBackgroundImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_backgroundImageRequestOperationKeyForState(state), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIButton (AFNetworking) + ++ (id )sharedImageCache { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sharedImageCache)) ?: [UIImageView sharedImageCache]; +#pragma clang diagnostic pop +} + ++ (void)setSharedImageCache:(__nullable id )imageCache { + objc_setAssociatedObject(self, @selector(sharedImageCache), imageCache, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (id )imageResponseSerializer { + static id _af_defaultImageResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(imageResponseSerializer)) ?: _af_defaultImageResponseSerializer; +#pragma clang diagnostic pop +} + +- (void)setImageResponseSerializer:(id )serializer { + objc_setAssociatedObject(self, @selector(imageResponseSerializer), serializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(void (^)(NSError *error))failure +{ + [self cancelImageRequestOperationForState:state]; + + UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setImage:cachedImage forState:state]; + } + + [self af_setImageRequestOperation:nil forState:state]; + } else { + if (placeholderImage) { + [self setImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + AFHTTPRequestOperation *imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + imageRequestOperation.responseSerializer = self.imageResponseSerializer; + [imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[urlRequest URL] isEqual:[operation.request URL]]) { + if (success) { + success(operation.request, operation.response, responseObject); + } else if (responseObject) { + [strongSelf setImage:responseObject forState:state]; + } + } + [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if ([[urlRequest URL] isEqual:[operation.request URL]]) { + if (failure) { + failure(error); + } + } + }]; + + [self af_setImageRequestOperation:imageRequestOperation forState:state]; + [[[self class] af_sharedImageRequestOperationQueue] addOperation:imageRequestOperation]; + } +} + +#pragma mark - + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setBackgroundImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(void (^)(NSError *error))failure +{ + [self cancelBackgroundImageRequestOperationForState:state]; + + UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setBackgroundImage:cachedImage forState:state]; + } + + [self af_setBackgroundImageRequestOperation:nil forState:state]; + } else { + if (placeholderImage) { + [self setBackgroundImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + AFHTTPRequestOperation *backgroundImageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + backgroundImageRequestOperation.responseSerializer = self.imageResponseSerializer; + [backgroundImageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[urlRequest URL] isEqual:[operation.request URL]]) { + if (success) { + success(operation.request, operation.response, responseObject); + } else if (responseObject) { + [strongSelf setBackgroundImage:responseObject forState:state]; + } + } + [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if ([[urlRequest URL] isEqual:[operation.request URL]]) { + if (failure) { + failure(error); + } + } + }]; + + [self af_setBackgroundImageRequestOperation:backgroundImageRequestOperation forState:state]; + [[[self class] af_sharedImageRequestOperationQueue] addOperation:backgroundImageRequestOperation]; + } +} + +#pragma mark - + +- (void)cancelImageRequestOperationForState:(UIControlState)state { + [[self af_imageRequestOperationForState:state] cancel]; + [self af_setImageRequestOperation:nil forState:state]; +} + +- (void)cancelBackgroundImageRequestOperationForState:(UIControlState)state { + [[self af_backgroundImageRequestOperationForState:state] cancel]; + [self af_setBackgroundImageRequestOperation:nil forState:state]; +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h new file mode 100644 index 0000000..3292920 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1,35 @@ +// +// UIImage+AFNetworking.h +// +// +// Created by Paulo Ferreira on 08/07/15. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +@interface UIImage (AFNetworking) + ++ (UIImage*) safeImageWithData:(NSData*)data; + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h new file mode 100644 index 0000000..bf61915 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1,146 @@ +// UIImageView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol AFURLResponseSerialization, AFImageCache; + +/** + This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. + */ +@interface UIImageView (AFNetworking) + +///---------------------------- +/// @name Accessing Image Cache +///---------------------------- + +/** + The image cache used to improve image loading performance on scroll views. By default, this is an `NSCache` subclass conforming to the `AFImageCache` protocol, which listens for notification warnings and evicts objects accordingly. +*/ ++ (id )sharedImageCache; + +/** + Set the cache used for image loading. + + @param imageCache The image cache. + */ ++ (void)setSharedImageCache:(__nullable id )imageCache; + +///------------------------------------ +/// @name Accessing Response Serializer +///------------------------------------ + +/** + The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. + + @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer + */ +@property (nonatomic, strong) id imageResponseSerializer; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + + @param url The URL used for the image request. + */ +- (void)setImageWithURL:(NSURL *)url; + +/** + Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` + + @param url The URL used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. + */ +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. + + If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. + + If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. + + @param urlRequest The URL request used for the image request. + @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. + @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the response parameter will be `nil`. + @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. + */ +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, NSError *error))failure; + +/** + Cancels any executing image operation for the receiver, if one exists. + */ +- (void)cancelImageRequestOperation; + +@end + +#pragma mark - + +/** + The `AFImageCache` protocol is adopted by an object used to cache images loaded by the AFNetworking category on `UIImageView`. + */ +@protocol AFImageCache + +/** + Returns a cached image for the specified request, if available. + + @param request The image request. + + @return The cached image. + */ +- (nullable UIImage *)cachedImageForRequest:(NSURLRequest *)request; + +/** + Caches a particular image for the specified request. + + @param image The image to cache. + @param request The request to be used as a cache key. + */ +- (void)cacheImage:(UIImage *)image + forRequest:(NSURLRequest *)request; +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m new file mode 100644 index 0000000..2efc160 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m @@ -0,0 +1,215 @@ +// UIImageView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIImageView+AFNetworking.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFHTTPRequestOperation.h" + +@interface AFImageCache : NSCache +@end + +#pragma mark - + +@interface UIImageView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation; +@end + +@implementation UIImageView (_AFNetworking) + ++ (NSOperationQueue *)af_sharedImageRequestOperationQueue { + static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init]; + _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; + }); + + return _af_sharedImageRequestOperationQueue; +} + +- (AFHTTPRequestOperation *)af_imageRequestOperation { + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_imageRequestOperation)); +} + +- (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation { + objc_setAssociatedObject(self, @selector(af_imageRequestOperation), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIImageView (AFNetworking) +@dynamic imageResponseSerializer; + ++ (id )sharedImageCache { + static AFImageCache *_af_defaultImageCache = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _af_defaultImageCache = [[AFImageCache alloc] init]; + + [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * __unused notification) { + [_af_defaultImageCache removeAllObjects]; + }]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sharedImageCache)) ?: _af_defaultImageCache; +#pragma clang diagnostic pop +} + ++ (void)setSharedImageCache:(__nullable id )imageCache { + objc_setAssociatedObject(self, @selector(sharedImageCache), imageCache, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (id )imageResponseSerializer { + static id _af_defaultImageResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(imageResponseSerializer)) ?: _af_defaultImageResponseSerializer; +#pragma clang diagnostic pop +} + +- (void)setImageResponseSerializer:(id )serializer { + objc_setAssociatedObject(self, @selector(imageResponseSerializer), serializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageWithURL:(NSURL *)url { + [self setImageWithURL:url placeholderImage:nil]; +} + +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, NSError *error))failure +{ + [self cancelImageRequestOperation]; + + UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + self.image = cachedImage; + } + + self.af_imageRequestOperation = nil; + } else { + if (placeholderImage) { + self.image = placeholderImage; + } + + __weak __typeof(self)weakSelf = self; + self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + self.af_imageRequestOperation.responseSerializer = self.imageResponseSerializer; + [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { + if (success) { + success(urlRequest, operation.response, responseObject); + } else if (responseObject) { + strongSelf.image = responseObject; + } + + if (operation == strongSelf.af_imageRequestOperation){ + strongSelf.af_imageRequestOperation = nil; + } + } + + [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { + if (failure) { + failure(urlRequest, operation.response, error); + } + + if (operation == strongSelf.af_imageRequestOperation){ + strongSelf.af_imageRequestOperation = nil; + } + } + }]; + + [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation]; + } +} + +- (void)cancelImageRequestOperation { + [self.af_imageRequestOperation cancel]; + self.af_imageRequestOperation = nil; +} + +@end + +#pragma mark - + +static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) { + return [[request URL] absoluteString]; +} + +@implementation AFImageCache + +- (UIImage *)cachedImageForRequest:(NSURLRequest *)request { + switch ([request cachePolicy]) { + case NSURLRequestReloadIgnoringCacheData: + case NSURLRequestReloadIgnoringLocalAndRemoteCacheData: + return nil; + default: + break; + } + + return [self objectForKey:AFImageCacheKeyFromURLRequest(request)]; +} + +- (void)cacheImage:(UIImage *)image + forRequest:(NSURLRequest *)request +{ + if (image && request) { + [self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)]; + } +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h new file mode 100644 index 0000000..49850ed --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1,39 @@ +// UIKit+AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if TARGET_OS_IOS +#import + +#ifndef _UIKIT_AFNETWORKING_ + #define _UIKIT_AFNETWORKING_ + + #import "AFNetworkActivityIndicatorManager.h" + + #import "UIActivityIndicatorView+AFNetworking.h" + #import "UIAlertView+AFNetworking.h" + #import "UIButton+AFNetworking.h" + #import "UIImageView+AFNetworking.h" + #import "UIProgressView+AFNetworking.h" + #import "UIRefreshControl+AFNetworking.h" + #import "UIWebView+AFNetworking.h" +#endif /* _UIKIT_AFNETWORKING_ */ +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h new file mode 100644 index 0000000..5c00d6d --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1,91 @@ +// UIProgressView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFURLConnectionOperation; + +/** + This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task or request operation. + */ +@interface UIProgressView (AFNetworking) + +///------------------------------------ +/// @name Setting Session Task Progress +///------------------------------------ + +/** + Binds the progress to the upload progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated; +#endif + +/** + Binds the progress to the download progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated; +#endif + +///------------------------------------ +/// @name Setting Session Task Progress +///------------------------------------ + +/** + Binds the progress to the upload progress of the specified request operation. + + @param operation The request operation. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation + animated:(BOOL)animated; + +/** + Binds the progress to the download progress of the specified request operation. + + @param operation The request operation. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation + animated:(BOOL)animated; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m new file mode 100644 index 0000000..ad2c280 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m @@ -0,0 +1,182 @@ +// UIProgressView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIProgressView+AFNetworking.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFURLConnectionOperation.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +#import "AFURLSessionManager.h" +#endif + +static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; +static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; + +@interface AFURLConnectionOperation (_UIProgressView) +@property (readwrite, nonatomic, copy) void (^uploadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +@property (readwrite, nonatomic, assign, setter = af_setUploadProgressAnimated:) BOOL af_uploadProgressAnimated; + +@property (readwrite, nonatomic, copy) void (^downloadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +@property (readwrite, nonatomic, assign, setter = af_setDownloadProgressAnimated:) BOOL af_downloadProgressAnimated; +@end + +@implementation AFURLConnectionOperation (_UIProgressView) +@dynamic uploadProgress; // Implemented in AFURLConnectionOperation +@dynamic af_uploadProgressAnimated; + +@dynamic downloadProgress; // Implemented in AFURLConnectionOperation +@dynamic af_downloadProgressAnimated; +@end + +#pragma mark - + +@implementation UIProgressView (AFNetworking) + +- (BOOL)af_uploadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; +} + +- (void)af_setUploadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (BOOL)af_downloadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; +} + +- (void)af_setDownloadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated +{ + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + + [self af_setUploadProgressAnimated:animated]; +} + +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated +{ + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + + [self af_setDownloadProgressAnimated:animated]; +} +#endif + +#pragma mark - + +- (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation + animated:(BOOL)animated +{ + __weak __typeof(self)weakSelf = self; + void (^original)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) = [operation.uploadProgress copy]; + [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { + if (original) { + original(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + if (totalBytesExpectedToWrite > 0) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf setProgress:(totalBytesWritten / (totalBytesExpectedToWrite * 1.0f)) animated:animated]; + } + }); + }]; +} + +- (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation + animated:(BOOL)animated +{ + __weak __typeof(self)weakSelf = self; + void (^original)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) = [operation.downloadProgress copy]; + [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { + if (original) { + original(bytesRead, totalBytesRead, totalBytesExpectedToRead); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + if (totalBytesExpectedToRead > 0) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf setProgress:(totalBytesRead / (totalBytesExpectedToRead * 1.0f)) animated:animated]; + } + }); + }]; +} + +#pragma mark - NSKeyValueObserving + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(__unused NSDictionary *)change + context:(void *)context +{ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 + if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { + if ([object countOfBytesExpectedToSend] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { + if ([object countOfBytesExpectedToReceive] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { + if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { + @try { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; + + if (context == AFTaskCountOfBytesSentContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; + } + + if (context == AFTaskCountOfBytesReceivedContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; + } + } + @catch (NSException * __unused exception) {} + } + } + } +#endif +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h new file mode 100644 index 0000000..a65e390 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1,68 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFURLConnectionOperation; + +/** + This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a request operation or session task. + */ +@interface UIRefreshControl (AFNetworking) + +///----------------------------------- +/// @name Refreshing for Session Tasks +///----------------------------------- + +/** + Binds the refreshing state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; +#endif + +///---------------------------------------- +/// @name Refreshing for Request Operations +///---------------------------------------- + +/** + Binds the refreshing state to the execution state of the specified operation. + + @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m new file mode 100644 index 0000000..4c19245 --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m @@ -0,0 +1,166 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIRefreshControl+AFNetworking.h" +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFHTTPRequestOperation.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +#import "AFURLSessionManager.h" +#endif + +@interface AFRefreshControlNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; +#endif +- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; + +@end + +@implementation UIRefreshControl (AFNetworking) + +- (AFRefreshControlNotificationObserver *)af_notificationObserver { + AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; +} +#endif + +- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { + [[self af_notificationObserver] setRefreshingWithStateOfOperation:operation]; +} + +@end + +@implementation AFRefreshControlNotificationObserver + +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl +{ + self = [super init]; + if (self) { + _refreshControl = refreshControl; + } + return self; +} + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (task.state == NSURLSessionTaskStateRunning) { + [self.refreshControl beginRefreshing]; + + [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; + } else { + [self.refreshControl endRefreshing]; + } +#pragma clang diagnostic pop + } +} +#endif + +- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; + + if (operation) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (![operation isFinished]) { + if ([operation isExecuting]) { + [self.refreshControl beginRefreshing]; + } else { + [self.refreshControl endRefreshing]; + } + + [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation]; + } +#pragma clang diagnostic pop + } +} + +#pragma mark - + +- (void)af_beginRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.refreshControl beginRefreshing]; +#pragma clang diagnostic pop + }); +} + +- (void)af_endRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.refreshControl endRefreshing]; +#pragma clang diagnostic pop + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +#endif + + [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; +} + +@end + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h new file mode 100644 index 0000000..5d61d6a --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1,86 @@ +// UIWebView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFHTTPRequestSerializer, AFHTTPResponseSerializer; +@protocol AFURLRequestSerialization, AFURLResponseSerialization; + +/** + This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. + + @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. + */ +@interface UIWebView (AFNetworking) + +/** + The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + Asynchronously loads the specified request. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. + @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)loadRequest:(NSURLRequest *)request + progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress + success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(nullable void (^)(NSError *error))failure; + +/** + Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. + @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. + @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. + @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. + @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. + */ +- (void)loadRequest:(NSURLRequest *)request + MIMEType:(nullable NSString *)MIMEType + textEncodingName:(nullable NSString *)textEncodingName + progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress + success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(nullable void (^)(NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m new file mode 100644 index 0000000..93eacaa --- /dev/null +++ b/InControl/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m @@ -0,0 +1,159 @@ +// UIWebView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIWebView+AFNetworking.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFHTTPRequestOperation.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" + +@interface UIWebView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation; +@end + +@implementation UIWebView (_AFNetworking) + +- (AFHTTPRequestOperation *)af_HTTPRequestOperation { + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation)); +} + +- (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation { + objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIWebView (AFNetworking) + +- (AFHTTPRequestSerializer *)requestSerializer { + static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer; +#pragma clang diagnostic pop +} + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (AFHTTPResponseSerializer *)responseSerializer { + static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; +#pragma clang diagnostic pop +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)loadRequest:(NSURLRequest *)request + progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress + success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(void (^)(NSError *error))failure +{ + [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (success) { + string = success(response, string); + } + + return [string dataUsingEncoding:stringEncoding]; + } failure:failure]; +} + +- (void)loadRequest:(NSURLRequest *)request + MIMEType:(NSString *)MIMEType + textEncodingName:(NSString *)textEncodingName + progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress + success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(void (^)(NSError *error))failure +{ + NSParameterAssert(request); + + if (self.af_HTTPRequestOperation) { + [self.af_HTTPRequestOperation cancel]; + } + + request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil]; + + self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer; + + __weak __typeof(self)weakSelf = self; + [self.af_HTTPRequestOperation setDownloadProgressBlock:progress]; + [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) { + NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + __strong __typeof(weakSelf) strongSelf = weakSelf; + [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]]; + + if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { + [strongSelf.delegate webViewDidFinishLoad:strongSelf]; + } + +#pragma clang diagnostic pop + } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) { + if (failure) { + failure(error); + } + }]; + + [self.af_HTTPRequestOperation start]; + + if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { + [self.delegate webViewDidStartLoad:self]; + } +} + +@end + +#endif diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperation.h b/InControl/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperation.h new file mode 120000 index 0000000..ac762c8 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperationManager.h b/InControl/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperationManager.h new file mode 120000 index 0000000..9dcc623 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h b/InControl/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h new file mode 120000 index 0000000..56feb9f --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h b/InControl/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 120000 index 0000000..67519d9 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h b/InControl/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h new file mode 120000 index 0000000..68fc774 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/AFNetworking.h new file mode 120000 index 0000000..a5a38da --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h b/InControl/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h new file mode 120000 index 0000000..fd1322d --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFSecurityPolicy.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFURLConnectionOperation.h b/InControl/Pods/Headers/Private/AFNetworking/AFURLConnectionOperation.h new file mode 120000 index 0000000..d9b35fb --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h b/InControl/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h new file mode 120000 index 0000000..ca8209b --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h b/InControl/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h new file mode 120000 index 0000000..e36a765 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h b/InControl/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h new file mode 120000 index 0000000..835101d --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLSessionManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 120000 index 0000000..c534ebf --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIAlertView+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIAlertView+AFNetworking.h new file mode 120000 index 0000000..f992813 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIAlertView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h new file mode 120000 index 0000000..8f2e221 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h new file mode 120000 index 0000000..74f6649 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h new file mode 120000 index 0000000..a95d673 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h new file mode 120000 index 0000000..95017cc --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h new file mode 120000 index 0000000..730b167 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h new file mode 120000 index 0000000..8efd826 --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h b/InControl/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h new file mode 120000 index 0000000..c8df6ef --- /dev/null +++ b/InControl/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/NSData+ImageContentType.h b/InControl/Pods/Headers/Private/SDWebImage/NSData+ImageContentType.h new file mode 120000 index 0000000..8457498 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/NSData+ImageContentType.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/NSData+ImageContentType.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/SDImageCache.h b/InControl/Pods/Headers/Private/SDWebImage/SDImageCache.h new file mode 120000 index 0000000..0040b06 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/SDImageCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCache.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/SDWebImageCompat.h b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageCompat.h new file mode 120000 index 0000000..6ca2478 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageCompat.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageCompat.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h new file mode 120000 index 0000000..a2f3a68 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDecoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDecoder.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDownloader.h b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDownloader.h new file mode 120000 index 0000000..303b03b --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDownloader.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloader.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderOperation.h b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderOperation.h new file mode 120000 index 0000000..99441c4 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageDownloaderOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/SDWebImageManager.h b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageManager.h new file mode 120000 index 0000000..1b81848 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/SDWebImageOperation.h b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageOperation.h new file mode 120000 index 0000000..20e5b89 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/SDWebImageOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/SDWebImagePrefetcher.h b/InControl/Pods/Headers/Private/SDWebImage/SDWebImagePrefetcher.h new file mode 120000 index 0000000..50585c6 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/SDWebImagePrefetcher.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/UIButton+WebCache.h b/InControl/Pods/Headers/Private/SDWebImage/UIButton+WebCache.h new file mode 120000 index 0000000..19d2d8e --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/UIButton+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIButton+WebCache.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/UIImage+GIF.h b/InControl/Pods/Headers/Private/SDWebImage/UIImage+GIF.h new file mode 120000 index 0000000..14d5aad --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/UIImage+GIF.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+GIF.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/UIImage+MultiFormat.h b/InControl/Pods/Headers/Private/SDWebImage/UIImage+MultiFormat.h new file mode 120000 index 0000000..1fb9650 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/UIImage+MultiFormat.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/UIImageView+HighlightedWebCache.h b/InControl/Pods/Headers/Private/SDWebImage/UIImageView+HighlightedWebCache.h new file mode 120000 index 0000000..fd4dea4 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/UIImageView+HighlightedWebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/UIImageView+WebCache.h b/InControl/Pods/Headers/Private/SDWebImage/UIImageView+WebCache.h new file mode 120000 index 0000000..0c53a47 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/UIImageView+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImageView+WebCache.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/SDWebImage/UIView+WebCacheOperation.h b/InControl/Pods/Headers/Private/SDWebImage/UIView+WebCacheOperation.h new file mode 120000 index 0000000..f9890c4 --- /dev/null +++ b/InControl/Pods/Headers/Private/SDWebImage/UIView+WebCacheOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeClient.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeClient.h new file mode 120000 index 0000000..2bd4493 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeClient.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeClient.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeError.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeError.h new file mode 120000 index 0000000..4c62521 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeError.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeError.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeKit.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeKit.h new file mode 120000 index 0000000..d16f6f8 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeKit.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeKit.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeLogger.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeLogger.h new file mode 120000 index 0000000..0d47450 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeLogger.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeLogger.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeOperation.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeOperation.h new file mode 120000 index 0000000..e8d6b95 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeOperation.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubePlayerScript.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubePlayerScript.h new file mode 120000 index 0000000..caeaae4 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubePlayerScript.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubePlayerScript.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideo+Private.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideo+Private.h new file mode 120000 index 0000000..e834431 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideo+Private.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo+Private.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideo.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideo.h new file mode 120000 index 0000000..ee13de8 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideo.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoOperation.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoOperation.h new file mode 120000 index 0000000..ac0730e --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoOperation.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h new file mode 120000 index 0000000..0ac3205 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoWebpage.h b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoWebpage.h new file mode 120000 index 0000000..4c0f3d2 --- /dev/null +++ b/InControl/Pods/Headers/Private/XCDYouTubeKit/XCDYouTubeVideoWebpage.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoWebpage.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h b/InControl/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h new file mode 120000 index 0000000..ac762c8 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h b/InControl/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h new file mode 120000 index 0000000..9dcc623 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h b/InControl/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h new file mode 120000 index 0000000..56feb9f --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h b/InControl/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 120000 index 0000000..67519d9 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h b/InControl/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h new file mode 120000 index 0000000..68fc774 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/AFNetworking.h new file mode 120000 index 0000000..a5a38da --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h b/InControl/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h new file mode 120000 index 0000000..fd1322d --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFSecurityPolicy.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h b/InControl/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h new file mode 120000 index 0000000..d9b35fb --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h b/InControl/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h new file mode 120000 index 0000000..ca8209b --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h b/InControl/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h new file mode 120000 index 0000000..e36a765 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h b/InControl/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h new file mode 120000 index 0000000..835101d --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLSessionManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 120000 index 0000000..c534ebf --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h new file mode 120000 index 0000000..f992813 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h new file mode 120000 index 0000000..8f2e221 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h new file mode 120000 index 0000000..74f6649 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h new file mode 120000 index 0000000..a95d673 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h new file mode 120000 index 0000000..95017cc --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h new file mode 120000 index 0000000..730b167 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h new file mode 120000 index 0000000..8efd826 --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h b/InControl/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h new file mode 120000 index 0000000..c8df6ef --- /dev/null +++ b/InControl/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/NSData+ImageContentType.h b/InControl/Pods/Headers/Public/SDWebImage/NSData+ImageContentType.h new file mode 120000 index 0000000..8457498 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/NSData+ImageContentType.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/NSData+ImageContentType.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/SDImageCache.h b/InControl/Pods/Headers/Public/SDWebImage/SDImageCache.h new file mode 120000 index 0000000..0040b06 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/SDImageCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDImageCache.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/SDWebImageCompat.h b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageCompat.h new file mode 120000 index 0000000..6ca2478 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageCompat.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageCompat.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h new file mode 120000 index 0000000..a2f3a68 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDecoder.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDecoder.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDownloader.h b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDownloader.h new file mode 120000 index 0000000..303b03b --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDownloader.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloader.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderOperation.h b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderOperation.h new file mode 120000 index 0000000..99441c4 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageDownloaderOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/SDWebImageManager.h b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageManager.h new file mode 120000 index 0000000..1b81848 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageManager.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageManager.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/SDWebImageOperation.h b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageOperation.h new file mode 120000 index 0000000..20e5b89 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/SDWebImageOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImageOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/SDWebImagePrefetcher.h b/InControl/Pods/Headers/Public/SDWebImage/SDWebImagePrefetcher.h new file mode 120000 index 0000000..50585c6 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/SDWebImagePrefetcher.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/SDWebImagePrefetcher.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/UIButton+WebCache.h b/InControl/Pods/Headers/Public/SDWebImage/UIButton+WebCache.h new file mode 120000 index 0000000..19d2d8e --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/UIButton+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIButton+WebCache.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/UIImage+GIF.h b/InControl/Pods/Headers/Public/SDWebImage/UIImage+GIF.h new file mode 120000 index 0000000..14d5aad --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/UIImage+GIF.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+GIF.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/UIImage+MultiFormat.h b/InControl/Pods/Headers/Public/SDWebImage/UIImage+MultiFormat.h new file mode 120000 index 0000000..1fb9650 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/UIImage+MultiFormat.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImage+MultiFormat.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/UIImageView+HighlightedWebCache.h b/InControl/Pods/Headers/Public/SDWebImage/UIImageView+HighlightedWebCache.h new file mode 120000 index 0000000..fd4dea4 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/UIImageView+HighlightedWebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/UIImageView+WebCache.h b/InControl/Pods/Headers/Public/SDWebImage/UIImageView+WebCache.h new file mode 120000 index 0000000..0c53a47 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/UIImageView+WebCache.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIImageView+WebCache.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/SDWebImage/UIView+WebCacheOperation.h b/InControl/Pods/Headers/Public/SDWebImage/UIView+WebCacheOperation.h new file mode 120000 index 0000000..f9890c4 --- /dev/null +++ b/InControl/Pods/Headers/Public/SDWebImage/UIView+WebCacheOperation.h @@ -0,0 +1 @@ +../../../SDWebImage/SDWebImage/UIView+WebCacheOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeClient.h b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeClient.h new file mode 120000 index 0000000..2bd4493 --- /dev/null +++ b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeClient.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeClient.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeError.h b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeError.h new file mode 120000 index 0000000..4c62521 --- /dev/null +++ b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeError.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeError.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeKit.h b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeKit.h new file mode 120000 index 0000000..d16f6f8 --- /dev/null +++ b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeKit.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeKit.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeOperation.h b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeOperation.h new file mode 120000 index 0000000..e8d6b95 --- /dev/null +++ b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeOperation.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideo.h b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideo.h new file mode 120000 index 0000000..ee13de8 --- /dev/null +++ b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideo.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideoOperation.h b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideoOperation.h new file mode 120000 index 0000000..ac0730e --- /dev/null +++ b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideoOperation.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoOperation.h \ No newline at end of file diff --git a/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h new file mode 120000 index 0000000..0ac3205 --- /dev/null +++ b/InControl/Pods/Headers/Public/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h @@ -0,0 +1 @@ +../../../XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h \ No newline at end of file diff --git a/InControl/Pods/Manifest.lock b/InControl/Pods/Manifest.lock new file mode 100644 index 0000000..b143bba --- /dev/null +++ b/InControl/Pods/Manifest.lock @@ -0,0 +1,38 @@ +PODS: + - AFNetworking (2.6.1): + - AFNetworking/NSURLConnection (= 2.6.1) + - AFNetworking/NSURLSession (= 2.6.1) + - AFNetworking/Reachability (= 2.6.1) + - AFNetworking/Security (= 2.6.1) + - AFNetworking/Serialization (= 2.6.1) + - AFNetworking/UIKit (= 2.6.1) + - AFNetworking/NSURLConnection (2.6.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/NSURLSession (2.6.1): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (2.6.1) + - AFNetworking/Security (2.6.1) + - AFNetworking/Serialization (2.6.1) + - AFNetworking/UIKit (2.6.1): + - AFNetworking/NSURLConnection + - AFNetworking/NSURLSession + - SDWebImage (3.7.3): + - SDWebImage/Core (= 3.7.3) + - SDWebImage/Core (3.7.3) + - XCDYouTubeKit (2.3.2) + +DEPENDENCIES: + - AFNetworking + - SDWebImage (~> 3.7) + - XCDYouTubeKit (~> 2.3.2) + +SPEC CHECKSUMS: + AFNetworking: 8e4e60500beb8bec644cf575beee72990a76d399 + SDWebImage: 1d2b1a1efda1ade1b00b6f8498865f8ddedc8a84 + XCDYouTubeKit: 6aff378bcbbf06d058f2c2d2df655c376970ee03 + +COCOAPODS: 0.38.2 diff --git a/InControl/Pods/Pods.xcodeproj/project.pbxproj b/InControl/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b3ca7c5 --- /dev/null +++ b/InControl/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,1092 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0063035CBD6ED665459DC5492A9F569C /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 67B6B7161F19BA2299B68CA6844F5C69 /* UIRefreshControl+AFNetworking.m */; }; + 01328AA013819912C612290A9A406BAC /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47DF5D8D6944F1ACA44A523B8C148029 /* Security.framework */; }; + 0943A4196177D34CF59C88E4AA77B576 /* SDWebImageDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = F6810D818545BACFD21ACAB72D23DC72 /* SDWebImageDecoder.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 0CBFA0FDE2C98DEB97B2B0DC291F6F3F /* UIImageView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = E1EFD1D330A4BC70F1C4C2ED395E2258 /* UIImageView+WebCache.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 12517D9F3856A49A93D1787AFA5C4630 /* UIProgressView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = B9025D909BF342D33C86F20C90EA2398 /* UIProgressView+AFNetworking.h */; }; + 1782ED6933FA862CFB3BD05F58613D73 /* XCDYouTubeOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0EDE26E597E25F9631F189E5631E2B17 /* XCDYouTubeOperation.h */; }; + 18894FC9A166263E6CB1FC6EE6AD8EFF /* SDWebImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 83F8CEA8D6C3D34590016ED7FF78B90C /* SDWebImageDownloader.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 1C3124F19BEE180A37EEAF36BC1AF26F /* XCDYouTubePlayerScript.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C85E869E4F57CB8ADC0A24A740D22EA /* XCDYouTubePlayerScript.m */; }; + 1C99212449E2C72928DCE93AF5AA7BE0 /* UIButton+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 1628A38DD51B0C6F6D63C7124CC8C295 /* UIButton+AFNetworking.h */; }; + 1F79E176E3262391BC8966B18469FF96 /* AFHTTPRequestOperationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = EBF5121728FF8B041A720D9207486E26 /* AFHTTPRequestOperationManager.h */; }; + 2358EE556EF067512DADC50B59A15D25 /* SDWebImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4C8A6792D4A925F9D3ABA38CB9537E /* SDWebImageManager.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 235F87FD2352766E90369A1510850E59 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8BA794419065B7129DE68FC4EC3F0A55 /* MediaPlayer.framework */; }; + 258B3D5281088A79284B41EDA8A512AA /* UIRefreshControl+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = F92C891B1E23061FF815B81F22A11245 /* UIRefreshControl+AFNetworking.h */; }; + 26A0D0CCAC2BDDEDE60F0C90AE697689 /* XCDYouTubeVideoOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 495BD02CEF42DA612B1377DEA8D7389F /* XCDYouTubeVideoOperation.h */; }; + 26B21B244340BA5A2F45F3B43F1D4926 /* UIButton+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 5099BC8D81DEDA973F9FF97BE55354BB /* UIButton+WebCache.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 2AD7EA509CC47FEFF5D925D75B7F9EBC /* XCDYouTubeError.h in Headers */ = {isa = PBXBuildFile; fileRef = 3662001F4FE18E3AB5E0AF369DD0EB76 /* XCDYouTubeError.h */; }; + 2C6AEC70A3E09CC7BD16C30B5B941981 /* SDWebImageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5ECFB2161C220584CD4F649E8EAE3896 /* SDWebImageManager.h */; }; + 2EAC876DBB9BB16545BA11689372ACC9 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 659F5A127369CC9DA7908827C44178D6 /* AFNetworkActivityIndicatorManager.m */; }; + 2F8C0E60FBD05D7D835B1991584CFCA8 /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 850217919734055C7BCE0BAA08C4BD1B /* AFURLSessionManager.m */; }; + 3536FDA7F5765CDF7A6C33D2EDE2A672 /* AFNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 033FAAAD23A8D92709CA271DE0D97912 /* AFNetworkReachabilityManager.h */; }; + 36C6345B2B5E2F3A801A3A145BD60436 /* UIKit+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = ADA9DC6082F3261ED43F05CB1C41E402 /* UIKit+AFNetworking.h */; }; + 37A315C532DA1A156F9676951702EFB9 /* SDWebImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 565D0DE3F083F3D803EE8CA97CDAECC5 /* SDWebImageDownloader.h */; }; + 391E7B8C3A4AA5BAAF36E586E9018386 /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 86913B74F8593B62EC17406235018794 /* AFURLRequestSerialization.m */; }; + 3A491D480AFBDCC8E0F858131DE379FE /* Pods-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = BFB10C74A86BFF8CA2C6102839E52244 /* Pods-dummy.m */; }; + 3F01C8EE4AEB3E8342F5CFDDABB300F7 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B71F4FA70F4034A3D04456A75BEB85D7 /* CoreGraphics.framework */; }; + 4139F9763483A01C9C8791866D78B8C4 /* XCDYouTubeLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = 74B46899918D97D5394BA3FA77452C6B /* XCDYouTubeLogger.h */; }; + 42FEE0EB22679829C5CE15F54281CCA1 /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 43311C2E8D51AEC6EBCCCA7024D436F7 /* UIWebView+AFNetworking.m */; }; + 43CACD8C0808E34F8BCC73CA938D2114 /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = F08759B40715644C468F2E3095E0C023 /* AFURLResponseSerialization.m */; }; + 4580D52D1E8872259AF8FFD758DB6EA8 /* UIWebView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 208995E7BBED998DA24CA14658BAF066 /* UIWebView+AFNetworking.h */; }; + 46C6D0143AB94CDD866FB320B9DB3C14 /* NSData+ImageContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 76C518201A486FCF7036C9F9DDBD593D /* NSData+ImageContentType.h */; }; + 4734109F2D367B8C35E80E32A313CC7F /* AFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C92631271FBDF28153916F34A0A409D1 /* AFNetworkActivityIndicatorManager.h */; }; + 4992E5B504AC1CAF6998740B561C1A51 /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 8997B92E4BCA0243DEA4BAF75B8594C4 /* AFSecurityPolicy.m */; }; + 4C74FC131C34E7E097EE03778F4D6D9B /* AFURLConnectionOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = A81EAC18FFDECB40B9CAB697BDF0076B /* AFURLConnectionOperation.h */; }; + 50151E9ABC4AC6EFCD9764698E392A3D /* UIImageView+HighlightedWebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = E7B5566E66AC64253CA228C460AE2931 /* UIImageView+HighlightedWebCache.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 505651BE6DF50CBA5C6BE87452D20BCF /* UIImageView+HighlightedWebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = D8DD99E890B5B9C7A22168DCDFF7F2F2 /* UIImageView+HighlightedWebCache.h */; }; + 51306C5F7CC18E40446B672A1E3B0D5B /* UIActivityIndicatorView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = E6470450210652C7CD4F7985E2C315C4 /* UIActivityIndicatorView+AFNetworking.h */; }; + 52C180F240E4635F5066C6D0845CDD71 /* UIAlertView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 8EFF054AD0EF6F3FF81B45F3CA9B050B /* UIAlertView+AFNetworking.h */; }; + 57CD1002C97823C3E412C51524506586 /* XCDYouTubeVideoWebpage.m in Sources */ = {isa = PBXBuildFile; fileRef = 44D2632106D2372ACF68681EEF16FFA9 /* XCDYouTubeVideoWebpage.m */; }; + 57F53664A4FD0CA75C489E228984D5F4 /* AFHTTPRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = C3E67A18E4D19A5AE752D5EA8E82DAFB /* AFHTTPRequestOperation.h */; }; + 57FDB0D84B88BA790448FB0099B256FB /* UIImage+MultiFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 6437C050025F1A8C69647B6744A18170 /* UIImage+MultiFormat.h */; }; + 638CE291702035270A1F9FFE8CF54554 /* XCDYouTubeVideoPlayerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 456014121030477CE61DDCEA604C062E /* XCDYouTubeVideoPlayerViewController.m */; }; + 646A6FC808A0B280B80AD4949D8357F8 /* UIView+WebCacheOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 44E19C4AEA9338236A9FD2DDA753E214 /* UIView+WebCacheOperation.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 683D4409569BB94EA3E3CA4B20630763 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6DD298F4EF2F68C4B172982286D20D49 /* ImageIO.framework */; }; + 691CA4DD2B876615A1153AA24C17B73C /* XCDYouTubeKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 6063ECC863548C75B57A5153C90D5465 /* XCDYouTubeKit.h */; }; + 69B51E512631A0F42F9719DBB2ED9733 /* XCDYouTubeVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = 7303F5A6A9389C4FB43D174EAAE9497D /* XCDYouTubeVideo.m */; }; + 6D1C4F3635D78B69396CD980A7BA144C /* XCDYouTubeClient.h in Headers */ = {isa = PBXBuildFile; fileRef = B7A003BD528D5F09E7A476F89A66D6BA /* XCDYouTubeClient.h */; }; + 71589AF745F9F127EA9465F8A8E68D21 /* UIProgressView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FB81B2D1EE23B7D795BE33F6EEEE34A /* UIProgressView+AFNetworking.m */; }; + 71C6735895C53FAA184F927BFD5E6E39 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEF7D8CF54A66B69467E7795CE61A411 /* Foundation.framework */; }; + 751C7CA61D9FD97DF80431FC9050736F /* UIButton+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 442BD5A86D7383D426EA6C87AB86FA93 /* UIButton+WebCache.h */; }; + 75D7CEA58A5F72C5F13499A11A573EEA /* SDWebImage-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 36868875BC2FD7CD9ACA53E772A68147 /* SDWebImage-dummy.m */; }; + 7A9527EEC26A04DEF22CA178446B0FA2 /* UIActivityIndicatorView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = C3C5A1FF07CFCCFDC1BE70389A61C93B /* UIActivityIndicatorView+AFNetworking.m */; }; + 7F47EBDA28826BDBD28A502091E9D9FD /* SDWebImagePrefetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D283561CA0E408531C1CA0651571381 /* SDWebImagePrefetcher.h */; }; + 80141404AC646C8046AB980757AE844C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEF7D8CF54A66B69467E7795CE61A411 /* Foundation.framework */; }; + 88E73B996D8355E9622B66AD1BCCB168 /* NSData+ImageContentType.m in Sources */ = {isa = PBXBuildFile; fileRef = 085ECBDDE362422A1BFD1DBE30FDB4F4 /* NSData+ImageContentType.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 898D8603930620AE3DE89A892967A505 /* SDImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 663FC8B8350D10A667A2FAF5EF29708C /* SDImageCache.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 8A086F75A3B32BC759C27E3124286FED /* AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 0E9E480025D4C33F8D243AD107724A8C /* AFNetworking.h */; }; + 90144EA34E633F7A8746D9C8BF0FF942 /* SDWebImageDownloaderOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 15D66C1B89B8779333C904B6E1F0FE50 /* SDWebImageDownloaderOperation.h */; }; + 950ABFF117D4904EB79AEC10B1596147 /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = C1BDD501CF02CD98CB7AFA28F4F519B1 /* UIImageView+AFNetworking.h */; }; + 950D0293EC76B1A5D92B769BF883B0CC /* XCDYouTubeKit-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = E1826D8FB5C72D7CD41EA9AE4A8AF61D /* XCDYouTubeKit-dummy.m */; }; + 9672896D96887659013683AB7FA81C44 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A65BFCCC514F06C337A733D7BD1A1860 /* JavaScriptCore.framework */; }; + 99692010A12A178877360A02AE80661A /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A638A952C567518FCA9FB3D4A6528129 /* MobileCoreServices.framework */; }; + 99A1CA366C854E79B73B28537C261B3E /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4AF8F72337B1BEC5EA26804B6B1DFEBC /* AFURLConnectionOperation.m */; }; + 9D214F4471B9CF33C581AF3424F947FF /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 2A0035986E8B445DED5E5371FA7942E9 /* AFHTTPRequestOperation.m */; }; + A07C86215245AF2DED432ECC39AABF71 /* UIImage+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 93145249C65A7154B2D41C3A2FAD4B1C /* UIImage+AFNetworking.h */; }; + A2222CEDD905A2D387F4A9C3895A093B /* UIImage+GIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 0C8BE0864137B3554F8C368D6F6EA646 /* UIImage+GIF.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + A60494050338755742BAE9B69676E688 /* XCDYouTubeVideoOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = EC0E9132FD5F4A88E272E24B9EBDB787 /* XCDYouTubeVideoOperation.m */; }; + A6EC3E1CCB6DC24720F3D5902677421E /* SDWebImageCompat.h in Headers */ = {isa = PBXBuildFile; fileRef = 3CC3A4489FFEE078645C51D22848F697 /* SDWebImageCompat.h */; }; + A773D58B6468B559F2DAB70F8C57F985 /* SDWebImagePrefetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 21426DB0E26F4458B2B8E531ED929344 /* SDWebImagePrefetcher.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + A7CFDC84797D4A641A483C05FF0CA8DA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEF7D8CF54A66B69467E7795CE61A411 /* Foundation.framework */; }; + AD22FBED3B2F3B5E300F4631FF325B0D /* SDImageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 20C7708C9D92468D5D2DD3A56794B5F4 /* SDImageCache.h */; }; + AEC69CAF659CC66788D8079AEEEB11E8 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 025A31460C01942290EBBD77B5E7D543 /* SystemConfiguration.framework */; }; + B09B41B7089B05F15F27AE248B394A65 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DC7DD48EC31463470E3A5719073510E /* UIImageView+AFNetworking.m */; }; + B108EF8640D45C3EC1F32CD7AC6DE75E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BEF7D8CF54A66B69467E7795CE61A411 /* Foundation.framework */; }; + B95852FDB20D65F7DB162F52DDB7154E /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 698DB0FC844E62CE7059C27CA80D0B6B /* AFHTTPSessionManager.m */; }; + B9B24F1882156B9384823BC873391481 /* UIView+WebCacheOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 605FCA5E9AB5C444FED020AAB684D140 /* UIView+WebCacheOperation.h */; }; + BEBF0DFB52BBFCB1214E42AAEB4D013C /* XCDYouTubeVideo+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CF98032FC97BD99EE9B41CFC2CB2CD92 /* XCDYouTubeVideo+Private.h */; }; + BF2B55F76E0D53B0F2732C250C151653 /* AFSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 59B338CB1BA6A763999B024FCE7E2BE1 /* AFSecurityPolicy.h */; }; + BF5A2091A282C6FB3587167946003088 /* XCDYouTubeClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 86665858B5D53790CE6988A6919921B4 /* XCDYouTubeClient.m */; }; + C1185E296305793C5FC452BA59752A99 /* SDWebImageDownloaderOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = B3D5ADC47369DCB41D20305EB6B00EFA /* SDWebImageDownloaderOperation.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + C32516863188EAD0CB8D27A796372599 /* UIImage+GIF.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E1763D689FFF87A52680D3FDBBCCA2F /* UIImage+GIF.h */; }; + CB4738FD436949ACAB04ED55DB819BFF /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BA155138CF9C73D16DEACC04CB48EFAA /* AFNetworkReachabilityManager.m */; }; + CDF19CB02942104E898EBB5E8190AEE0 /* AFHTTPRequestOperationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D0641A29F64D3B818FE3B17135DF660 /* AFHTTPRequestOperationManager.m */; }; + CF8333B5FEC0C76FD7155FE88D951248 /* SDWebImageDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = FF3208FF08E5445EB9E5049F4C5D94F3 /* SDWebImageDecoder.h */; }; + D1E46A63831F38087723325F0A4E1050 /* XCDYouTubeLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = DB3C95D3CCAA12F8968C7547801CC4F9 /* XCDYouTubeLogger.m */; }; + D29B0B171DE9A7BD0AD7FC0F72D391C5 /* XCDYouTubeVideoWebpage.h in Headers */ = {isa = PBXBuildFile; fileRef = D41ADC19858D8BF63FE333A689D5BEA0 /* XCDYouTubeVideoWebpage.h */; }; + D36E6B131A9178CC5C0C1573133E5C87 /* AFURLSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = FA4ADB2F1903308FB9F522B87E8A150D /* AFURLSessionManager.h */; }; + D5C2DD6BE81D0671F423CF42BC7C6D58 /* AFHTTPSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 49B2674E21EE5A2189EFEB0F4FAA5092 /* AFHTTPSessionManager.h */; }; + D84D7D7679877C22E782E1153B519286 /* AFURLResponseSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 60E3999F06C7A7257F85304454D8991F /* AFURLResponseSerialization.h */; }; + DA4D396B55B39383C074853765A8E7BF /* UIAlertView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 094645754DD4C4ACDFF71DEEC2AD26FA /* UIAlertView+AFNetworking.m */; }; + E042F3EE15E5D06B958372257805F086 /* SDWebImageOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 1693790C9228360FA63950C2D796CFA5 /* SDWebImageOperation.h */; }; + E141EB53EA4082275DFCEBFC8BA19BFF /* XCDYouTubeVideoPlayerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 04D19F5F744CE24D4E0E089217C0E836 /* XCDYouTubeVideoPlayerViewController.h */; }; + EE63AB2E181788377C3A6F2155228006 /* AFNetworking-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = FF6CD65DB11AC6D444AEDFD4CEACC6B4 /* AFNetworking-dummy.m */; }; + EEC70F07E66D6E0AB32E3E8337165EFD /* UIImage+MultiFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BFEE3E0C36A901C0D63CDBB8F8D490A /* UIImage+MultiFormat.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + EEF705540E2BF07C06BBE1024A69AB43 /* UIButton+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C9C6AEF707E686F0416B514E54F2FD /* UIButton+AFNetworking.m */; }; + EF2E5E9490743E84AEAD0DDCD300CF54 /* UIImageView+WebCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 572E9757319756864DBF2880DCA92575 /* UIImageView+WebCache.h */; }; + F4FDFA5A83BE4F0B473F228F6AC2C726 /* SDWebImageCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = FE98519651ECB3ECA5C602AD82864FE1 /* SDWebImageCompat.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + F673876251A6693992762FFC288F79A1 /* AFURLRequestSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = D3960B29589158FCDCAE5DE8F1803598 /* AFURLRequestSerialization.h */; }; + FA1BDC1F7F654891F8286CEBFA6CED93 /* XCDYouTubeVideo.h in Headers */ = {isa = PBXBuildFile; fileRef = 25C99BFEB58FC4FEC53BFA13D436901A /* XCDYouTubeVideo.h */; }; + FABA52A788D575882565FF511A68C903 /* XCDYouTubePlayerScript.h in Headers */ = {isa = PBXBuildFile; fileRef = BE5BA2D27A1B686442BBD5B269697B48 /* XCDYouTubePlayerScript.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 7D57390C2CE680AD890CC854DE6E80CB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1CCA33898E587AE27FE4D7B3EF115639; + remoteInfo = XCDYouTubeKit; + }; + D4DBF341F9A734C15F3D1AE420F44550 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5352D432641F0656C90741034E32F31E; + remoteInfo = SDWebImage; + }; + E5B3EFB4DA0A12C300C185D49262504E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 54CFA08301FA955823AEB4E9EDDE4A34; + remoteInfo = AFNetworking; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 025A31460C01942290EBBD77B5E7D543 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + 033FAAAD23A8D92709CA271DE0D97912 /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkReachabilityManager.h; path = AFNetworking/AFNetworkReachabilityManager.h; sourceTree = ""; }; + 04D19F5F744CE24D4E0E089217C0E836 /* XCDYouTubeVideoPlayerViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeVideoPlayerViewController.h; path = XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h; sourceTree = ""; }; + 05065E97A49D5CBB370B956AED60236A /* XCDYouTubeKit-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "XCDYouTubeKit-prefix.pch"; sourceTree = ""; }; + 085ECBDDE362422A1BFD1DBE30FDB4F4 /* NSData+ImageContentType.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSData+ImageContentType.m"; path = "SDWebImage/NSData+ImageContentType.m"; sourceTree = ""; }; + 094645754DD4C4ACDFF71DEEC2AD26FA /* UIAlertView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIAlertView+AFNetworking.m"; path = "UIKit+AFNetworking/UIAlertView+AFNetworking.m"; sourceTree = ""; }; + 0C8BE0864137B3554F8C368D6F6EA646 /* UIImage+GIF.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+GIF.m"; path = "SDWebImage/UIImage+GIF.m"; sourceTree = ""; }; + 0E9E480025D4C33F8D243AD107724A8C /* AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworking.h; path = AFNetworking/AFNetworking.h; sourceTree = ""; }; + 0EDE26E597E25F9631F189E5631E2B17 /* XCDYouTubeOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeOperation.h; path = XCDYouTubeKit/XCDYouTubeOperation.h; sourceTree = ""; }; + 15A529C27057E4A57D259CBC6E6CE49C /* Pods-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-acknowledgements.markdown"; sourceTree = ""; }; + 15D66C1B89B8779333C904B6E1F0FE50 /* SDWebImageDownloaderOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloaderOperation.h; path = SDWebImage/SDWebImageDownloaderOperation.h; sourceTree = ""; }; + 1628A38DD51B0C6F6D63C7124CC8C295 /* UIButton+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+AFNetworking.h"; path = "UIKit+AFNetworking/UIButton+AFNetworking.h"; sourceTree = ""; }; + 1693790C9228360FA63950C2D796CFA5 /* SDWebImageOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageOperation.h; path = SDWebImage/SDWebImageOperation.h; sourceTree = ""; }; + 1FB81B2D1EE23B7D795BE33F6EEEE34A /* UIProgressView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIProgressView+AFNetworking.m"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.m"; sourceTree = ""; }; + 208995E7BBED998DA24CA14658BAF066 /* UIWebView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIWebView+AFNetworking.h"; path = "UIKit+AFNetworking/UIWebView+AFNetworking.h"; sourceTree = ""; }; + 20C7708C9D92468D5D2DD3A56794B5F4 /* SDImageCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDImageCache.h; path = SDWebImage/SDImageCache.h; sourceTree = ""; }; + 21426DB0E26F4458B2B8E531ED929344 /* SDWebImagePrefetcher.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImagePrefetcher.m; path = SDWebImage/SDWebImagePrefetcher.m; sourceTree = ""; }; + 25C99BFEB58FC4FEC53BFA13D436901A /* XCDYouTubeVideo.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeVideo.h; path = XCDYouTubeKit/XCDYouTubeVideo.h; sourceTree = ""; }; + 2A0035986E8B445DED5E5371FA7942E9 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPRequestOperation.m; path = AFNetworking/AFHTTPRequestOperation.m; sourceTree = ""; }; + 2CDDAE4E961A5E333CF17184AB090FA8 /* SDWebImage.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SDWebImage.xcconfig; sourceTree = ""; }; + 2D283561CA0E408531C1CA0651571381 /* SDWebImagePrefetcher.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImagePrefetcher.h; path = SDWebImage/SDWebImagePrefetcher.h; sourceTree = ""; }; + 3662001F4FE18E3AB5E0AF369DD0EB76 /* XCDYouTubeError.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeError.h; path = XCDYouTubeKit/XCDYouTubeError.h; sourceTree = ""; }; + 36868875BC2FD7CD9ACA53E772A68147 /* SDWebImage-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SDWebImage-dummy.m"; sourceTree = ""; }; + 3ADD2856B96B7B5A74D080110A0E39D0 /* SDWebImage-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SDWebImage-prefix.pch"; sourceTree = ""; }; + 3CC3A4489FFEE078645C51D22848F697 /* SDWebImageCompat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageCompat.h; path = SDWebImage/SDWebImageCompat.h; sourceTree = ""; }; + 3DC7DD48EC31463470E3A5719073510E /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+AFNetworking.m"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.m"; sourceTree = ""; }; + 3F60E15898F6DC263BA1752EC0B0CBDC /* AFNetworking-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "AFNetworking-prefix.pch"; sourceTree = ""; }; + 43311C2E8D51AEC6EBCCCA7024D436F7 /* UIWebView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIWebView+AFNetworking.m"; path = "UIKit+AFNetworking/UIWebView+AFNetworking.m"; sourceTree = ""; }; + 43CCA9F7C031DE0021697D63CA1AAC2C /* libAFNetworking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAFNetworking.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 442BD5A86D7383D426EA6C87AB86FA93 /* UIButton+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+WebCache.h"; path = "SDWebImage/UIButton+WebCache.h"; sourceTree = ""; }; + 44D2632106D2372ACF68681EEF16FFA9 /* XCDYouTubeVideoWebpage.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = XCDYouTubeVideoWebpage.m; path = XCDYouTubeKit/XCDYouTubeVideoWebpage.m; sourceTree = ""; }; + 44E19C4AEA9338236A9FD2DDA753E214 /* UIView+WebCacheOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIView+WebCacheOperation.m"; path = "SDWebImage/UIView+WebCacheOperation.m"; sourceTree = ""; }; + 456014121030477CE61DDCEA604C062E /* XCDYouTubeVideoPlayerViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = XCDYouTubeVideoPlayerViewController.m; path = XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m; sourceTree = ""; }; + 47DF5D8D6944F1ACA44A523B8C148029 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; + 495BD02CEF42DA612B1377DEA8D7389F /* XCDYouTubeVideoOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeVideoOperation.h; path = XCDYouTubeKit/XCDYouTubeVideoOperation.h; sourceTree = ""; }; + 49B2674E21EE5A2189EFEB0F4FAA5092 /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPSessionManager.h; path = AFNetworking/AFHTTPSessionManager.h; sourceTree = ""; }; + 4AF8F72337B1BEC5EA26804B6B1DFEBC /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLConnectionOperation.m; path = AFNetworking/AFURLConnectionOperation.m; sourceTree = ""; }; + 4C4C8A6792D4A925F9D3ABA38CB9537E /* SDWebImageManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageManager.m; path = SDWebImage/SDWebImageManager.m; sourceTree = ""; }; + 5099BC8D81DEDA973F9FF97BE55354BB /* UIButton+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+WebCache.m"; path = "SDWebImage/UIButton+WebCache.m"; sourceTree = ""; }; + 524D66ED47344AC3EEFB458084AFEFC9 /* libXCDYouTubeKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libXCDYouTubeKit.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 55C9C6AEF707E686F0416B514E54F2FD /* UIButton+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+AFNetworking.m"; path = "UIKit+AFNetworking/UIButton+AFNetworking.m"; sourceTree = ""; }; + 565D0DE3F083F3D803EE8CA97CDAECC5 /* SDWebImageDownloader.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDownloader.h; path = SDWebImage/SDWebImageDownloader.h; sourceTree = ""; }; + 572E9757319756864DBF2880DCA92575 /* UIImageView+WebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+WebCache.h"; path = "SDWebImage/UIImageView+WebCache.h"; sourceTree = ""; }; + 59B338CB1BA6A763999B024FCE7E2BE1 /* AFSecurityPolicy.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFSecurityPolicy.h; path = AFNetworking/AFSecurityPolicy.h; sourceTree = ""; }; + 5D0641A29F64D3B818FE3B17135DF660 /* AFHTTPRequestOperationManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPRequestOperationManager.m; path = AFNetworking/AFHTTPRequestOperationManager.m; sourceTree = ""; }; + 5ECFB2161C220584CD4F649E8EAE3896 /* SDWebImageManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageManager.h; path = SDWebImage/SDWebImageManager.h; sourceTree = ""; }; + 5EECFC680988B8A6BE2CFE59CEE8F5B2 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.release.xcconfig; sourceTree = ""; }; + 605FCA5E9AB5C444FED020AAB684D140 /* UIView+WebCacheOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIView+WebCacheOperation.h"; path = "SDWebImage/UIView+WebCacheOperation.h"; sourceTree = ""; }; + 6063ECC863548C75B57A5153C90D5465 /* XCDYouTubeKit.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeKit.h; path = XCDYouTubeKit/XCDYouTubeKit.h; sourceTree = ""; }; + 60E3999F06C7A7257F85304454D8991F /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLResponseSerialization.h; path = AFNetworking/AFURLResponseSerialization.h; sourceTree = ""; }; + 641AE05DD55E5E6AC1590CD7B4A18F97 /* Pods-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-resources.sh"; sourceTree = ""; }; + 6437C050025F1A8C69647B6744A18170 /* UIImage+MultiFormat.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+MultiFormat.h"; path = "SDWebImage/UIImage+MultiFormat.h"; sourceTree = ""; }; + 659F5A127369CC9DA7908827C44178D6 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkActivityIndicatorManager.m; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m"; sourceTree = ""; }; + 663FC8B8350D10A667A2FAF5EF29708C /* SDImageCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDImageCache.m; path = SDWebImage/SDImageCache.m; sourceTree = ""; }; + 67B6B7161F19BA2299B68CA6844F5C69 /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIRefreshControl+AFNetworking.m"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.m"; sourceTree = ""; }; + 698DB0FC844E62CE7059C27CA80D0B6B /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPSessionManager.m; path = AFNetworking/AFHTTPSessionManager.m; sourceTree = ""; }; + 6DD298F4EF2F68C4B172982286D20D49 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/ImageIO.framework; sourceTree = DEVELOPER_DIR; }; + 7278616F2AEA6750CBC7CBAE05844A5C /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 7303F5A6A9389C4FB43D174EAAE9497D /* XCDYouTubeVideo.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = XCDYouTubeVideo.m; path = XCDYouTubeKit/XCDYouTubeVideo.m; sourceTree = ""; }; + 74B46899918D97D5394BA3FA77452C6B /* XCDYouTubeLogger.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeLogger.h; path = XCDYouTubeKit/XCDYouTubeLogger.h; sourceTree = ""; }; + 76C518201A486FCF7036C9F9DDBD593D /* NSData+ImageContentType.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSData+ImageContentType.h"; path = "SDWebImage/NSData+ImageContentType.h"; sourceTree = ""; }; + 7BFEE3E0C36A901C0D63CDBB8F8D490A /* UIImage+MultiFormat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImage+MultiFormat.m"; path = "SDWebImage/UIImage+MultiFormat.m"; sourceTree = ""; }; + 7E1763D689FFF87A52680D3FDBBCCA2F /* UIImage+GIF.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+GIF.h"; path = "SDWebImage/UIImage+GIF.h"; sourceTree = ""; }; + 7EC22DF34FD47C18E175FDE02C39EE17 /* AFNetworking.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = AFNetworking.xcconfig; sourceTree = ""; }; + 83F8CEA8D6C3D34590016ED7FF78B90C /* SDWebImageDownloader.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloader.m; path = SDWebImage/SDWebImageDownloader.m; sourceTree = ""; }; + 850217919734055C7BCE0BAA08C4BD1B /* AFURLSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLSessionManager.m; path = AFNetworking/AFURLSessionManager.m; sourceTree = ""; }; + 86665858B5D53790CE6988A6919921B4 /* XCDYouTubeClient.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = XCDYouTubeClient.m; path = XCDYouTubeKit/XCDYouTubeClient.m; sourceTree = ""; }; + 86913B74F8593B62EC17406235018794 /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLRequestSerialization.m; path = AFNetworking/AFURLRequestSerialization.m; sourceTree = ""; }; + 8997B92E4BCA0243DEA4BAF75B8594C4 /* AFSecurityPolicy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFSecurityPolicy.m; path = AFNetworking/AFSecurityPolicy.m; sourceTree = ""; }; + 8BA794419065B7129DE68FC4EC3F0A55 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; + 8C85E869E4F57CB8ADC0A24A740D22EA /* XCDYouTubePlayerScript.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = XCDYouTubePlayerScript.m; path = XCDYouTubeKit/XCDYouTubePlayerScript.m; sourceTree = ""; }; + 8EFF054AD0EF6F3FF81B45F3CA9B050B /* UIAlertView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIAlertView+AFNetworking.h"; path = "UIKit+AFNetworking/UIAlertView+AFNetworking.h"; sourceTree = ""; }; + 93145249C65A7154B2D41C3A2FAD4B1C /* UIImage+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+AFNetworking.h"; path = "UIKit+AFNetworking/UIImage+AFNetworking.h"; sourceTree = ""; }; + A4E3C75131DB73B535BA7338F6201845 /* libSDWebImage.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDWebImage.a; sourceTree = BUILT_PRODUCTS_DIR; }; + A638A952C567518FCA9FB3D4A6528129 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; }; + A65BFCCC514F06C337A733D7BD1A1860 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; + A81EAC18FFDECB40B9CAB697BDF0076B /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLConnectionOperation.h; path = AFNetworking/AFURLConnectionOperation.h; sourceTree = ""; }; + ADA9DC6082F3261ED43F05CB1C41E402 /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIKit+AFNetworking.h"; path = "UIKit+AFNetworking/UIKit+AFNetworking.h"; sourceTree = ""; }; + B1986C06F8E76769B03C18C08D61B25D /* XCDYouTubeKit.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = XCDYouTubeKit.xcconfig; sourceTree = ""; }; + B3D5ADC47369DCB41D20305EB6B00EFA /* SDWebImageDownloaderOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDownloaderOperation.m; path = SDWebImage/SDWebImageDownloaderOperation.m; sourceTree = ""; }; + B71F4FA70F4034A3D04456A75BEB85D7 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; + B7A003BD528D5F09E7A476F89A66D6BA /* XCDYouTubeClient.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeClient.h; path = XCDYouTubeKit/XCDYouTubeClient.h; sourceTree = ""; }; + B9025D909BF342D33C86F20C90EA2398 /* UIProgressView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIProgressView+AFNetworking.h"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.h"; sourceTree = ""; }; + BA155138CF9C73D16DEACC04CB48EFAA /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkReachabilityManager.m; path = AFNetworking/AFNetworkReachabilityManager.m; sourceTree = ""; }; + BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + BE5BA2D27A1B686442BBD5B269697B48 /* XCDYouTubePlayerScript.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubePlayerScript.h; path = XCDYouTubeKit/XCDYouTubePlayerScript.h; sourceTree = ""; }; + BEF7D8CF54A66B69467E7795CE61A411 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + BF59BC15D23E1E1912C8F334E7236813 /* Pods-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-acknowledgements.plist"; sourceTree = ""; }; + BFB10C74A86BFF8CA2C6102839E52244 /* Pods-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-dummy.m"; sourceTree = ""; }; + C1BDD501CF02CD98CB7AFA28F4F519B1 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.h"; sourceTree = ""; }; + C3C5A1FF07CFCCFDC1BE70389A61C93B /* UIActivityIndicatorView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIActivityIndicatorView+AFNetworking.m"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m"; sourceTree = ""; }; + C3E67A18E4D19A5AE752D5EA8E82DAFB /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPRequestOperation.h; path = AFNetworking/AFHTTPRequestOperation.h; sourceTree = ""; }; + C58B51F77BE10734467D76C287F636F4 /* AFNetworking-Private.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "AFNetworking-Private.xcconfig"; sourceTree = ""; }; + C92631271FBDF28153916F34A0A409D1 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h"; sourceTree = ""; }; + CF98032FC97BD99EE9B41CFC2CB2CD92 /* XCDYouTubeVideo+Private.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "XCDYouTubeVideo+Private.h"; path = "XCDYouTubeKit/XCDYouTubeVideo+Private.h"; sourceTree = ""; }; + D3960B29589158FCDCAE5DE8F1803598 /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLRequestSerialization.h; path = AFNetworking/AFURLRequestSerialization.h; sourceTree = ""; }; + D41ADC19858D8BF63FE333A689D5BEA0 /* XCDYouTubeVideoWebpage.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = XCDYouTubeVideoWebpage.h; path = XCDYouTubeKit/XCDYouTubeVideoWebpage.h; sourceTree = ""; }; + D8DD99E890B5B9C7A22168DCDFF7F2F2 /* UIImageView+HighlightedWebCache.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+HighlightedWebCache.h"; path = "SDWebImage/UIImageView+HighlightedWebCache.h"; sourceTree = ""; }; + DB3C95D3CCAA12F8968C7547801CC4F9 /* XCDYouTubeLogger.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = XCDYouTubeLogger.m; path = XCDYouTubeKit/XCDYouTubeLogger.m; sourceTree = ""; }; + E1826D8FB5C72D7CD41EA9AE4A8AF61D /* XCDYouTubeKit-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "XCDYouTubeKit-dummy.m"; sourceTree = ""; }; + E1EFD1D330A4BC70F1C4C2ED395E2258 /* UIImageView+WebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+WebCache.m"; path = "SDWebImage/UIImageView+WebCache.m"; sourceTree = ""; }; + E6470450210652C7CD4F7985E2C315C4 /* UIActivityIndicatorView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIActivityIndicatorView+AFNetworking.h"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h"; sourceTree = ""; }; + E7B5566E66AC64253CA228C460AE2931 /* UIImageView+HighlightedWebCache.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+HighlightedWebCache.m"; path = "SDWebImage/UIImageView+HighlightedWebCache.m"; sourceTree = ""; }; + E86C5371913DA49FAF36BFF7E04BA5A0 /* XCDYouTubeKit-Private.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "XCDYouTubeKit-Private.xcconfig"; sourceTree = ""; }; + EBAF4251A01BDDBE51238DA73A6A4061 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.debug.xcconfig; sourceTree = ""; }; + EBF5121728FF8B041A720D9207486E26 /* AFHTTPRequestOperationManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPRequestOperationManager.h; path = AFNetworking/AFHTTPRequestOperationManager.h; sourceTree = ""; }; + EC0E9132FD5F4A88E272E24B9EBDB787 /* XCDYouTubeVideoOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = XCDYouTubeVideoOperation.m; path = XCDYouTubeKit/XCDYouTubeVideoOperation.m; sourceTree = ""; }; + F08759B40715644C468F2E3095E0C023 /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLResponseSerialization.m; path = AFNetworking/AFURLResponseSerialization.m; sourceTree = ""; }; + F6810D818545BACFD21ACAB72D23DC72 /* SDWebImageDecoder.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageDecoder.m; path = SDWebImage/SDWebImageDecoder.m; sourceTree = ""; }; + F92C891B1E23061FF815B81F22A11245 /* UIRefreshControl+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIRefreshControl+AFNetworking.h"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.h"; sourceTree = ""; }; + FA4ADB2F1903308FB9F522B87E8A150D /* AFURLSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLSessionManager.h; path = AFNetworking/AFURLSessionManager.h; sourceTree = ""; }; + FC04C72731885B5A33A0AFF5C41DFAF2 /* SDWebImage-Private.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "SDWebImage-Private.xcconfig"; sourceTree = ""; }; + FE98519651ECB3ECA5C602AD82864FE1 /* SDWebImageCompat.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SDWebImageCompat.m; path = SDWebImage/SDWebImageCompat.m; sourceTree = ""; }; + FF3208FF08E5445EB9E5049F4C5D94F3 /* SDWebImageDecoder.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SDWebImageDecoder.h; path = SDWebImage/SDWebImageDecoder.h; sourceTree = ""; }; + FF6CD65DB11AC6D444AEDFD4CEACC6B4 /* AFNetworking-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "AFNetworking-dummy.m"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4C02B3291EE85469028AD8922C1BAD45 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 80141404AC646C8046AB980757AE844C /* Foundation.framework in Frameworks */, + 9672896D96887659013683AB7FA81C44 /* JavaScriptCore.framework in Frameworks */, + 235F87FD2352766E90369A1510850E59 /* MediaPlayer.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 6483CA59DE76B7505AC83F07E09B7794 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + B108EF8640D45C3EC1F32CD7AC6DE75E /* Foundation.framework in Frameworks */, + 683D4409569BB94EA3E3CA4B20630763 /* ImageIO.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 74A9A09BEB5A2E921FEB8B5CE1DFE835 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A7CFDC84797D4A641A483C05FF0CA8DA /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B36BC1D3AD71AC46C60B550D68DD5E1A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3F01C8EE4AEB3E8342F5CFDDABB300F7 /* CoreGraphics.framework in Frameworks */, + 71C6735895C53FAA184F927BFD5E6E39 /* Foundation.framework in Frameworks */, + 99692010A12A178877360A02AE80661A /* MobileCoreServices.framework in Frameworks */, + 01328AA013819912C612290A9A406BAC /* Security.framework in Frameworks */, + AEC69CAF659CC66788D8079AEEEB11E8 /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 00AA78BBD80ED2C840CB78CB478A22E8 /* Core */ = { + isa = PBXGroup; + children = ( + 76C518201A486FCF7036C9F9DDBD593D /* NSData+ImageContentType.h */, + 085ECBDDE362422A1BFD1DBE30FDB4F4 /* NSData+ImageContentType.m */, + 20C7708C9D92468D5D2DD3A56794B5F4 /* SDImageCache.h */, + 663FC8B8350D10A667A2FAF5EF29708C /* SDImageCache.m */, + 3CC3A4489FFEE078645C51D22848F697 /* SDWebImageCompat.h */, + FE98519651ECB3ECA5C602AD82864FE1 /* SDWebImageCompat.m */, + FF3208FF08E5445EB9E5049F4C5D94F3 /* SDWebImageDecoder.h */, + F6810D818545BACFD21ACAB72D23DC72 /* SDWebImageDecoder.m */, + 565D0DE3F083F3D803EE8CA97CDAECC5 /* SDWebImageDownloader.h */, + 83F8CEA8D6C3D34590016ED7FF78B90C /* SDWebImageDownloader.m */, + 15D66C1B89B8779333C904B6E1F0FE50 /* SDWebImageDownloaderOperation.h */, + B3D5ADC47369DCB41D20305EB6B00EFA /* SDWebImageDownloaderOperation.m */, + 5ECFB2161C220584CD4F649E8EAE3896 /* SDWebImageManager.h */, + 4C4C8A6792D4A925F9D3ABA38CB9537E /* SDWebImageManager.m */, + 1693790C9228360FA63950C2D796CFA5 /* SDWebImageOperation.h */, + 2D283561CA0E408531C1CA0651571381 /* SDWebImagePrefetcher.h */, + 21426DB0E26F4458B2B8E531ED929344 /* SDWebImagePrefetcher.m */, + 442BD5A86D7383D426EA6C87AB86FA93 /* UIButton+WebCache.h */, + 5099BC8D81DEDA973F9FF97BE55354BB /* UIButton+WebCache.m */, + 7E1763D689FFF87A52680D3FDBBCCA2F /* UIImage+GIF.h */, + 0C8BE0864137B3554F8C368D6F6EA646 /* UIImage+GIF.m */, + 6437C050025F1A8C69647B6744A18170 /* UIImage+MultiFormat.h */, + 7BFEE3E0C36A901C0D63CDBB8F8D490A /* UIImage+MultiFormat.m */, + D8DD99E890B5B9C7A22168DCDFF7F2F2 /* UIImageView+HighlightedWebCache.h */, + E7B5566E66AC64253CA228C460AE2931 /* UIImageView+HighlightedWebCache.m */, + 572E9757319756864DBF2880DCA92575 /* UIImageView+WebCache.h */, + E1EFD1D330A4BC70F1C4C2ED395E2258 /* UIImageView+WebCache.m */, + 605FCA5E9AB5C444FED020AAB684D140 /* UIView+WebCacheOperation.h */, + 44E19C4AEA9338236A9FD2DDA753E214 /* UIView+WebCacheOperation.m */, + ); + name = Core; + sourceTree = ""; + }; + 0120EF4132E4FECC5D08B947F4E3CACF /* iOS */ = { + isa = PBXGroup; + children = ( + B71F4FA70F4034A3D04456A75BEB85D7 /* CoreGraphics.framework */, + BEF7D8CF54A66B69467E7795CE61A411 /* Foundation.framework */, + 6DD298F4EF2F68C4B172982286D20D49 /* ImageIO.framework */, + A65BFCCC514F06C337A733D7BD1A1860 /* JavaScriptCore.framework */, + 8BA794419065B7129DE68FC4EC3F0A55 /* MediaPlayer.framework */, + A638A952C567518FCA9FB3D4A6528129 /* MobileCoreServices.framework */, + 47DF5D8D6944F1ACA44A523B8C148029 /* Security.framework */, + 025A31460C01942290EBBD77B5E7D543 /* SystemConfiguration.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 02716431CD905D6B87BC6917F2A99231 /* XCDYouTubeKit */ = { + isa = PBXGroup; + children = ( + B7A003BD528D5F09E7A476F89A66D6BA /* XCDYouTubeClient.h */, + 86665858B5D53790CE6988A6919921B4 /* XCDYouTubeClient.m */, + 3662001F4FE18E3AB5E0AF369DD0EB76 /* XCDYouTubeError.h */, + 6063ECC863548C75B57A5153C90D5465 /* XCDYouTubeKit.h */, + 74B46899918D97D5394BA3FA77452C6B /* XCDYouTubeLogger.h */, + DB3C95D3CCAA12F8968C7547801CC4F9 /* XCDYouTubeLogger.m */, + 0EDE26E597E25F9631F189E5631E2B17 /* XCDYouTubeOperation.h */, + BE5BA2D27A1B686442BBD5B269697B48 /* XCDYouTubePlayerScript.h */, + 8C85E869E4F57CB8ADC0A24A740D22EA /* XCDYouTubePlayerScript.m */, + 25C99BFEB58FC4FEC53BFA13D436901A /* XCDYouTubeVideo.h */, + 7303F5A6A9389C4FB43D174EAAE9497D /* XCDYouTubeVideo.m */, + CF98032FC97BD99EE9B41CFC2CB2CD92 /* XCDYouTubeVideo+Private.h */, + 495BD02CEF42DA612B1377DEA8D7389F /* XCDYouTubeVideoOperation.h */, + EC0E9132FD5F4A88E272E24B9EBDB787 /* XCDYouTubeVideoOperation.m */, + 04D19F5F744CE24D4E0E089217C0E836 /* XCDYouTubeVideoPlayerViewController.h */, + 456014121030477CE61DDCEA604C062E /* XCDYouTubeVideoPlayerViewController.m */, + D41ADC19858D8BF63FE333A689D5BEA0 /* XCDYouTubeVideoWebpage.h */, + 44D2632106D2372ACF68681EEF16FFA9 /* XCDYouTubeVideoWebpage.m */, + 7B2A5237331849A8AE8AEC7892EDB47D /* Support Files */, + ); + path = XCDYouTubeKit; + sourceTree = ""; + }; + 2A45910CA1C8639E083DA2CD7EEAE94B /* Reachability */ = { + isa = PBXGroup; + children = ( + 033FAAAD23A8D92709CA271DE0D97912 /* AFNetworkReachabilityManager.h */, + BA155138CF9C73D16DEACC04CB48EFAA /* AFNetworkReachabilityManager.m */, + ); + name = Reachability; + sourceTree = ""; + }; + 458910E2CE3483EF34E0E7E6A2880C66 /* Serialization */ = { + isa = PBXGroup; + children = ( + D3960B29589158FCDCAE5DE8F1803598 /* AFURLRequestSerialization.h */, + 86913B74F8593B62EC17406235018794 /* AFURLRequestSerialization.m */, + 60E3999F06C7A7257F85304454D8991F /* AFURLResponseSerialization.h */, + F08759B40715644C468F2E3095E0C023 /* AFURLResponseSerialization.m */, + ); + name = Serialization; + sourceTree = ""; + }; + 471E49294E0E2A7FE8B7B2E1C0C56A96 /* Support Files */ = { + isa = PBXGroup; + children = ( + 2CDDAE4E961A5E333CF17184AB090FA8 /* SDWebImage.xcconfig */, + FC04C72731885B5A33A0AFF5C41DFAF2 /* SDWebImage-Private.xcconfig */, + 36868875BC2FD7CD9ACA53E772A68147 /* SDWebImage-dummy.m */, + 3ADD2856B96B7B5A74D080110A0E39D0 /* SDWebImage-prefix.pch */, + ); + name = "Support Files"; + path = "../Target Support Files/SDWebImage"; + sourceTree = ""; + }; + 4DF48AE84B392A7192E3CD52B8998ECD /* Pods */ = { + isa = PBXGroup; + children = ( + 7B12DE2608A60417F4EA0881CFEDC0AE /* AFNetworking */, + FBDEBD9EE327C83F2F3B9B6614021FA4 /* SDWebImage */, + 02716431CD905D6B87BC6917F2A99231 /* XCDYouTubeKit */, + ); + name = Pods; + sourceTree = ""; + }; + 665CA42DA7C2E3F897866F64B82F75F9 /* NSURLConnection */ = { + isa = PBXGroup; + children = ( + C3E67A18E4D19A5AE752D5EA8E82DAFB /* AFHTTPRequestOperation.h */, + 2A0035986E8B445DED5E5371FA7942E9 /* AFHTTPRequestOperation.m */, + EBF5121728FF8B041A720D9207486E26 /* AFHTTPRequestOperationManager.h */, + 5D0641A29F64D3B818FE3B17135DF660 /* AFHTTPRequestOperationManager.m */, + A81EAC18FFDECB40B9CAB697BDF0076B /* AFURLConnectionOperation.h */, + 4AF8F72337B1BEC5EA26804B6B1DFEBC /* AFURLConnectionOperation.m */, + ); + name = NSURLConnection; + sourceTree = ""; + }; + 785553737B06AFC3DA711DDEB7D56194 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0120EF4132E4FECC5D08B947F4E3CACF /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 7A9AEE36DF2353962DBD79558BDC150F /* Security */ = { + isa = PBXGroup; + children = ( + 59B338CB1BA6A763999B024FCE7E2BE1 /* AFSecurityPolicy.h */, + 8997B92E4BCA0243DEA4BAF75B8594C4 /* AFSecurityPolicy.m */, + ); + name = Security; + sourceTree = ""; + }; + 7B12DE2608A60417F4EA0881CFEDC0AE /* AFNetworking */ = { + isa = PBXGroup; + children = ( + 0E9E480025D4C33F8D243AD107724A8C /* AFNetworking.h */, + 665CA42DA7C2E3F897866F64B82F75F9 /* NSURLConnection */, + C0C6E16B8397E3C94795274B9EF7D44E /* NSURLSession */, + 2A45910CA1C8639E083DA2CD7EEAE94B /* Reachability */, + 7A9AEE36DF2353962DBD79558BDC150F /* Security */, + 458910E2CE3483EF34E0E7E6A2880C66 /* Serialization */, + FFE0C4795558F2A79C994DE311A37FE1 /* Support Files */, + FD781F61447799EF6FAF6E5EEFAAA19A /* UIKit */, + ); + path = AFNetworking; + sourceTree = ""; + }; + 7B2A5237331849A8AE8AEC7892EDB47D /* Support Files */ = { + isa = PBXGroup; + children = ( + B1986C06F8E76769B03C18C08D61B25D /* XCDYouTubeKit.xcconfig */, + E86C5371913DA49FAF36BFF7E04BA5A0 /* XCDYouTubeKit-Private.xcconfig */, + E1826D8FB5C72D7CD41EA9AE4A8AF61D /* XCDYouTubeKit-dummy.m */, + 05065E97A49D5CBB370B956AED60236A /* XCDYouTubeKit-prefix.pch */, + ); + name = "Support Files"; + path = "../Target Support Files/XCDYouTubeKit"; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */, + 785553737B06AFC3DA711DDEB7D56194 /* Frameworks */, + 4DF48AE84B392A7192E3CD52B8998ECD /* Pods */, + CCA510CFBEA2D207524CDA0D73C3B561 /* Products */, + D2411A5FE7F7A004607BED49990C37F4 /* Targets Support Files */, + ); + sourceTree = ""; + }; + 952EEBFAF8F7E620423C9F156F25A506 /* Pods */ = { + isa = PBXGroup; + children = ( + 15A529C27057E4A57D259CBC6E6CE49C /* Pods-acknowledgements.markdown */, + BF59BC15D23E1E1912C8F334E7236813 /* Pods-acknowledgements.plist */, + BFB10C74A86BFF8CA2C6102839E52244 /* Pods-dummy.m */, + 641AE05DD55E5E6AC1590CD7B4A18F97 /* Pods-resources.sh */, + EBAF4251A01BDDBE51238DA73A6A4061 /* Pods.debug.xcconfig */, + 5EECFC680988B8A6BE2CFE59CEE8F5B2 /* Pods.release.xcconfig */, + ); + name = Pods; + path = "Target Support Files/Pods"; + sourceTree = ""; + }; + C0C6E16B8397E3C94795274B9EF7D44E /* NSURLSession */ = { + isa = PBXGroup; + children = ( + 49B2674E21EE5A2189EFEB0F4FAA5092 /* AFHTTPSessionManager.h */, + 698DB0FC844E62CE7059C27CA80D0B6B /* AFHTTPSessionManager.m */, + FA4ADB2F1903308FB9F522B87E8A150D /* AFURLSessionManager.h */, + 850217919734055C7BCE0BAA08C4BD1B /* AFURLSessionManager.m */, + ); + name = NSURLSession; + sourceTree = ""; + }; + CCA510CFBEA2D207524CDA0D73C3B561 /* Products */ = { + isa = PBXGroup; + children = ( + 43CCA9F7C031DE0021697D63CA1AAC2C /* libAFNetworking.a */, + 7278616F2AEA6750CBC7CBAE05844A5C /* libPods.a */, + A4E3C75131DB73B535BA7338F6201845 /* libSDWebImage.a */, + 524D66ED47344AC3EEFB458084AFEFC9 /* libXCDYouTubeKit.a */, + ); + name = Products; + sourceTree = ""; + }; + D2411A5FE7F7A004607BED49990C37F4 /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + 952EEBFAF8F7E620423C9F156F25A506 /* Pods */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + FBDEBD9EE327C83F2F3B9B6614021FA4 /* SDWebImage */ = { + isa = PBXGroup; + children = ( + 00AA78BBD80ED2C840CB78CB478A22E8 /* Core */, + 471E49294E0E2A7FE8B7B2E1C0C56A96 /* Support Files */, + ); + path = SDWebImage; + sourceTree = ""; + }; + FD781F61447799EF6FAF6E5EEFAAA19A /* UIKit */ = { + isa = PBXGroup; + children = ( + C92631271FBDF28153916F34A0A409D1 /* AFNetworkActivityIndicatorManager.h */, + 659F5A127369CC9DA7908827C44178D6 /* AFNetworkActivityIndicatorManager.m */, + E6470450210652C7CD4F7985E2C315C4 /* UIActivityIndicatorView+AFNetworking.h */, + C3C5A1FF07CFCCFDC1BE70389A61C93B /* UIActivityIndicatorView+AFNetworking.m */, + 8EFF054AD0EF6F3FF81B45F3CA9B050B /* UIAlertView+AFNetworking.h */, + 094645754DD4C4ACDFF71DEEC2AD26FA /* UIAlertView+AFNetworking.m */, + 1628A38DD51B0C6F6D63C7124CC8C295 /* UIButton+AFNetworking.h */, + 55C9C6AEF707E686F0416B514E54F2FD /* UIButton+AFNetworking.m */, + 93145249C65A7154B2D41C3A2FAD4B1C /* UIImage+AFNetworking.h */, + C1BDD501CF02CD98CB7AFA28F4F519B1 /* UIImageView+AFNetworking.h */, + 3DC7DD48EC31463470E3A5719073510E /* UIImageView+AFNetworking.m */, + ADA9DC6082F3261ED43F05CB1C41E402 /* UIKit+AFNetworking.h */, + B9025D909BF342D33C86F20C90EA2398 /* UIProgressView+AFNetworking.h */, + 1FB81B2D1EE23B7D795BE33F6EEEE34A /* UIProgressView+AFNetworking.m */, + F92C891B1E23061FF815B81F22A11245 /* UIRefreshControl+AFNetworking.h */, + 67B6B7161F19BA2299B68CA6844F5C69 /* UIRefreshControl+AFNetworking.m */, + 208995E7BBED998DA24CA14658BAF066 /* UIWebView+AFNetworking.h */, + 43311C2E8D51AEC6EBCCCA7024D436F7 /* UIWebView+AFNetworking.m */, + ); + name = UIKit; + sourceTree = ""; + }; + FFE0C4795558F2A79C994DE311A37FE1 /* Support Files */ = { + isa = PBXGroup; + children = ( + 7EC22DF34FD47C18E175FDE02C39EE17 /* AFNetworking.xcconfig */, + C58B51F77BE10734467D76C287F636F4 /* AFNetworking-Private.xcconfig */, + FF6CD65DB11AC6D444AEDFD4CEACC6B4 /* AFNetworking-dummy.m */, + 3F60E15898F6DC263BA1752EC0B0CBDC /* AFNetworking-prefix.pch */, + ); + name = "Support Files"; + path = "../Target Support Files/AFNetworking"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 70E692A35509AA009F46AAA3DCB430E9 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 46C6D0143AB94CDD866FB320B9DB3C14 /* NSData+ImageContentType.h in Headers */, + AD22FBED3B2F3B5E300F4631FF325B0D /* SDImageCache.h in Headers */, + A6EC3E1CCB6DC24720F3D5902677421E /* SDWebImageCompat.h in Headers */, + CF8333B5FEC0C76FD7155FE88D951248 /* SDWebImageDecoder.h in Headers */, + 37A315C532DA1A156F9676951702EFB9 /* SDWebImageDownloader.h in Headers */, + 90144EA34E633F7A8746D9C8BF0FF942 /* SDWebImageDownloaderOperation.h in Headers */, + 2C6AEC70A3E09CC7BD16C30B5B941981 /* SDWebImageManager.h in Headers */, + E042F3EE15E5D06B958372257805F086 /* SDWebImageOperation.h in Headers */, + 7F47EBDA28826BDBD28A502091E9D9FD /* SDWebImagePrefetcher.h in Headers */, + 751C7CA61D9FD97DF80431FC9050736F /* UIButton+WebCache.h in Headers */, + C32516863188EAD0CB8D27A796372599 /* UIImage+GIF.h in Headers */, + 57FDB0D84B88BA790448FB0099B256FB /* UIImage+MultiFormat.h in Headers */, + 505651BE6DF50CBA5C6BE87452D20BCF /* UIImageView+HighlightedWebCache.h in Headers */, + EF2E5E9490743E84AEAD0DDCD300CF54 /* UIImageView+WebCache.h in Headers */, + B9B24F1882156B9384823BC873391481 /* UIView+WebCacheOperation.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8B1FA33BE7A7ABFB3F1B33FF6D0752F2 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 57F53664A4FD0CA75C489E228984D5F4 /* AFHTTPRequestOperation.h in Headers */, + 1F79E176E3262391BC8966B18469FF96 /* AFHTTPRequestOperationManager.h in Headers */, + D5C2DD6BE81D0671F423CF42BC7C6D58 /* AFHTTPSessionManager.h in Headers */, + 4734109F2D367B8C35E80E32A313CC7F /* AFNetworkActivityIndicatorManager.h in Headers */, + 3536FDA7F5765CDF7A6C33D2EDE2A672 /* AFNetworkReachabilityManager.h in Headers */, + 8A086F75A3B32BC759C27E3124286FED /* AFNetworking.h in Headers */, + BF2B55F76E0D53B0F2732C250C151653 /* AFSecurityPolicy.h in Headers */, + 4C74FC131C34E7E097EE03778F4D6D9B /* AFURLConnectionOperation.h in Headers */, + F673876251A6693992762FFC288F79A1 /* AFURLRequestSerialization.h in Headers */, + D84D7D7679877C22E782E1153B519286 /* AFURLResponseSerialization.h in Headers */, + D36E6B131A9178CC5C0C1573133E5C87 /* AFURLSessionManager.h in Headers */, + 51306C5F7CC18E40446B672A1E3B0D5B /* UIActivityIndicatorView+AFNetworking.h in Headers */, + 52C180F240E4635F5066C6D0845CDD71 /* UIAlertView+AFNetworking.h in Headers */, + 1C99212449E2C72928DCE93AF5AA7BE0 /* UIButton+AFNetworking.h in Headers */, + A07C86215245AF2DED432ECC39AABF71 /* UIImage+AFNetworking.h in Headers */, + 950ABFF117D4904EB79AEC10B1596147 /* UIImageView+AFNetworking.h in Headers */, + 36C6345B2B5E2F3A801A3A145BD60436 /* UIKit+AFNetworking.h in Headers */, + 12517D9F3856A49A93D1787AFA5C4630 /* UIProgressView+AFNetworking.h in Headers */, + 258B3D5281088A79284B41EDA8A512AA /* UIRefreshControl+AFNetworking.h in Headers */, + 4580D52D1E8872259AF8FFD758DB6EA8 /* UIWebView+AFNetworking.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F3C5855D2CF7A5355244417194A0D5B5 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 6D1C4F3635D78B69396CD980A7BA144C /* XCDYouTubeClient.h in Headers */, + 2AD7EA509CC47FEFF5D925D75B7F9EBC /* XCDYouTubeError.h in Headers */, + 691CA4DD2B876615A1153AA24C17B73C /* XCDYouTubeKit.h in Headers */, + 4139F9763483A01C9C8791866D78B8C4 /* XCDYouTubeLogger.h in Headers */, + 1782ED6933FA862CFB3BD05F58613D73 /* XCDYouTubeOperation.h in Headers */, + FABA52A788D575882565FF511A68C903 /* XCDYouTubePlayerScript.h in Headers */, + BEBF0DFB52BBFCB1214E42AAEB4D013C /* XCDYouTubeVideo+Private.h in Headers */, + FA1BDC1F7F654891F8286CEBFA6CED93 /* XCDYouTubeVideo.h in Headers */, + 26A0D0CCAC2BDDEDE60F0C90AE697689 /* XCDYouTubeVideoOperation.h in Headers */, + E141EB53EA4082275DFCEBFC8BA19BFF /* XCDYouTubeVideoPlayerViewController.h in Headers */, + D29B0B171DE9A7BD0AD7FC0F72D391C5 /* XCDYouTubeVideoWebpage.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 1CCA33898E587AE27FE4D7B3EF115639 /* XCDYouTubeKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = 790CEF25E7273463EB0AC86B53A282E2 /* Build configuration list for PBXNativeTarget "XCDYouTubeKit" */; + buildPhases = ( + 8DF89B96075B7A3792DCAADA6D37CCFE /* Sources */, + 4C02B3291EE85469028AD8922C1BAD45 /* Frameworks */, + F3C5855D2CF7A5355244417194A0D5B5 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = XCDYouTubeKit; + productName = XCDYouTubeKit; + productReference = 524D66ED47344AC3EEFB458084AFEFC9 /* libXCDYouTubeKit.a */; + productType = "com.apple.product-type.library.static"; + }; + 3DBD189EE2C742C66E524266F7E90672 /* Pods */ = { + isa = PBXNativeTarget; + buildConfigurationList = C7C28CB2C678DF04DD6C087A75C86453 /* Build configuration list for PBXNativeTarget "Pods" */; + buildPhases = ( + 3970EE742D6A5609BB05D97A20C64C88 /* Sources */, + 74A9A09BEB5A2E921FEB8B5CE1DFE835 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 08E718B31AC056C2B7D7A75DB0929E7D /* PBXTargetDependency */, + 5E9B791320EBE0B325ABBCE1629ED5C9 /* PBXTargetDependency */, + FC89728FAE7B2CCD1A129194155817B4 /* PBXTargetDependency */, + ); + name = Pods; + productName = Pods; + productReference = 7278616F2AEA6750CBC7CBAE05844A5C /* libPods.a */; + productType = "com.apple.product-type.library.static"; + }; + 5352D432641F0656C90741034E32F31E /* SDWebImage */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1C450805480F718FD16967298BD9381E /* Build configuration list for PBXNativeTarget "SDWebImage" */; + buildPhases = ( + ED4867DE87E22E526FE5CFF638C86F4D /* Sources */, + 6483CA59DE76B7505AC83F07E09B7794 /* Frameworks */, + 70E692A35509AA009F46AAA3DCB430E9 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SDWebImage; + productName = SDWebImage; + productReference = A4E3C75131DB73B535BA7338F6201845 /* libSDWebImage.a */; + productType = "com.apple.product-type.library.static"; + }; + 54CFA08301FA955823AEB4E9EDDE4A34 /* AFNetworking */ = { + isa = PBXNativeTarget; + buildConfigurationList = 465B7A6FD7241FE35F81E7FB74CC3BDB /* Build configuration list for PBXNativeTarget "AFNetworking" */; + buildPhases = ( + 7E41BD6D24DFEF47698734C84E9BFF6D /* Sources */, + B36BC1D3AD71AC46C60B550D68DD5E1A /* Frameworks */, + 8B1FA33BE7A7ABFB3F1B33FF6D0752F2 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AFNetworking; + productName = AFNetworking; + productReference = 43CCA9F7C031DE0021697D63CA1AAC2C /* libAFNetworking.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = CCA510CFBEA2D207524CDA0D73C3B561 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 54CFA08301FA955823AEB4E9EDDE4A34 /* AFNetworking */, + 3DBD189EE2C742C66E524266F7E90672 /* Pods */, + 5352D432641F0656C90741034E32F31E /* SDWebImage */, + 1CCA33898E587AE27FE4D7B3EF115639 /* XCDYouTubeKit */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 3970EE742D6A5609BB05D97A20C64C88 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3A491D480AFBDCC8E0F858131DE379FE /* Pods-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 7E41BD6D24DFEF47698734C84E9BFF6D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9D214F4471B9CF33C581AF3424F947FF /* AFHTTPRequestOperation.m in Sources */, + CDF19CB02942104E898EBB5E8190AEE0 /* AFHTTPRequestOperationManager.m in Sources */, + B95852FDB20D65F7DB162F52DDB7154E /* AFHTTPSessionManager.m in Sources */, + 2EAC876DBB9BB16545BA11689372ACC9 /* AFNetworkActivityIndicatorManager.m in Sources */, + CB4738FD436949ACAB04ED55DB819BFF /* AFNetworkReachabilityManager.m in Sources */, + EE63AB2E181788377C3A6F2155228006 /* AFNetworking-dummy.m in Sources */, + 4992E5B504AC1CAF6998740B561C1A51 /* AFSecurityPolicy.m in Sources */, + 99A1CA366C854E79B73B28537C261B3E /* AFURLConnectionOperation.m in Sources */, + 391E7B8C3A4AA5BAAF36E586E9018386 /* AFURLRequestSerialization.m in Sources */, + 43CACD8C0808E34F8BCC73CA938D2114 /* AFURLResponseSerialization.m in Sources */, + 2F8C0E60FBD05D7D835B1991584CFCA8 /* AFURLSessionManager.m in Sources */, + 7A9527EEC26A04DEF22CA178446B0FA2 /* UIActivityIndicatorView+AFNetworking.m in Sources */, + DA4D396B55B39383C074853765A8E7BF /* UIAlertView+AFNetworking.m in Sources */, + EEF705540E2BF07C06BBE1024A69AB43 /* UIButton+AFNetworking.m in Sources */, + B09B41B7089B05F15F27AE248B394A65 /* UIImageView+AFNetworking.m in Sources */, + 71589AF745F9F127EA9465F8A8E68D21 /* UIProgressView+AFNetworking.m in Sources */, + 0063035CBD6ED665459DC5492A9F569C /* UIRefreshControl+AFNetworking.m in Sources */, + 42FEE0EB22679829C5CE15F54281CCA1 /* UIWebView+AFNetworking.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8DF89B96075B7A3792DCAADA6D37CCFE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BF5A2091A282C6FB3587167946003088 /* XCDYouTubeClient.m in Sources */, + 950D0293EC76B1A5D92B769BF883B0CC /* XCDYouTubeKit-dummy.m in Sources */, + D1E46A63831F38087723325F0A4E1050 /* XCDYouTubeLogger.m in Sources */, + 1C3124F19BEE180A37EEAF36BC1AF26F /* XCDYouTubePlayerScript.m in Sources */, + 69B51E512631A0F42F9719DBB2ED9733 /* XCDYouTubeVideo.m in Sources */, + A60494050338755742BAE9B69676E688 /* XCDYouTubeVideoOperation.m in Sources */, + 638CE291702035270A1F9FFE8CF54554 /* XCDYouTubeVideoPlayerViewController.m in Sources */, + 57CD1002C97823C3E412C51524506586 /* XCDYouTubeVideoWebpage.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + ED4867DE87E22E526FE5CFF638C86F4D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 88E73B996D8355E9622B66AD1BCCB168 /* NSData+ImageContentType.m in Sources */, + 898D8603930620AE3DE89A892967A505 /* SDImageCache.m in Sources */, + 75D7CEA58A5F72C5F13499A11A573EEA /* SDWebImage-dummy.m in Sources */, + F4FDFA5A83BE4F0B473F228F6AC2C726 /* SDWebImageCompat.m in Sources */, + 0943A4196177D34CF59C88E4AA77B576 /* SDWebImageDecoder.m in Sources */, + 18894FC9A166263E6CB1FC6EE6AD8EFF /* SDWebImageDownloader.m in Sources */, + C1185E296305793C5FC452BA59752A99 /* SDWebImageDownloaderOperation.m in Sources */, + 2358EE556EF067512DADC50B59A15D25 /* SDWebImageManager.m in Sources */, + A773D58B6468B559F2DAB70F8C57F985 /* SDWebImagePrefetcher.m in Sources */, + 26B21B244340BA5A2F45F3B43F1D4926 /* UIButton+WebCache.m in Sources */, + A2222CEDD905A2D387F4A9C3895A093B /* UIImage+GIF.m in Sources */, + EEC70F07E66D6E0AB32E3E8337165EFD /* UIImage+MultiFormat.m in Sources */, + 50151E9ABC4AC6EFCD9764698E392A3D /* UIImageView+HighlightedWebCache.m in Sources */, + 0CBFA0FDE2C98DEB97B2B0DC291F6F3F /* UIImageView+WebCache.m in Sources */, + 646A6FC808A0B280B80AD4949D8357F8 /* UIView+WebCacheOperation.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 08E718B31AC056C2B7D7A75DB0929E7D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = AFNetworking; + target = 54CFA08301FA955823AEB4E9EDDE4A34 /* AFNetworking */; + targetProxy = E5B3EFB4DA0A12C300C185D49262504E /* PBXContainerItemProxy */; + }; + 5E9B791320EBE0B325ABBCE1629ED5C9 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SDWebImage; + target = 5352D432641F0656C90741034E32F31E /* SDWebImage */; + targetProxy = D4DBF341F9A734C15F3D1AE420F44550 /* PBXContainerItemProxy */; + }; + FC89728FAE7B2CCD1A129194155817B4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = XCDYouTubeKit; + target = 1CCA33898E587AE27FE4D7B3EF115639 /* XCDYouTubeKit */; + targetProxy = 7D57390C2CE680AD890CC854DE6E80CB /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 14FB610AE633D709FE86136700E6C34F /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FC04C72731885B5A33A0AFF5C41DFAF2 /* SDWebImage-Private.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/SDWebImage/SDWebImage-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 3EB83639CF60CD5142C41D2BFA4E470E /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C58B51F77BE10734467D76C287F636F4 /* AFNetworking-Private.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/AFNetworking/AFNetworking-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 5CE5176205D06FF3FFE3DDDA9291E44B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + ONLY_ACTIVE_ARCH = YES; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + 70460B3E895DBF3ACACDD9A4B381A523 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5EECFC680988B8A6BE2CFE59CEE8F5B2 /* Pods.release.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 74857149DC1E0D599B8A01A78349A926 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = "RELEASE=1"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 8AAADEED682EE38CE46AD9832FFDB5ED /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = EBAF4251A01BDDBE51238DA73A6A4061 /* Pods.debug.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 8CBCF469CD29F5BB2876FD92357062BD /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E86C5371913DA49FAF36BFF7E04BA5A0 /* XCDYouTubeKit-Private.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/XCDYouTubeKit/XCDYouTubeKit-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + C7A726310DA2E37F196D54D1AB71C0A2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C58B51F77BE10734467D76C287F636F4 /* AFNetworking-Private.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/AFNetworking/AFNetworking-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + E4A954A1A213FA2B456BDCD749613DA3 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FC04C72731885B5A33A0AFF5C41DFAF2 /* SDWebImage-Private.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/SDWebImage/SDWebImage-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + E54C53DF62871CEE3F692F8EAEC21F80 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E86C5371913DA49FAF36BFF7E04BA5A0 /* XCDYouTubeKit-Private.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/XCDYouTubeKit/XCDYouTubeKit-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1C450805480F718FD16967298BD9381E /* Build configuration list for PBXNativeTarget "SDWebImage" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E4A954A1A213FA2B456BDCD749613DA3 /* Debug */, + 14FB610AE633D709FE86136700E6C34F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 5CE5176205D06FF3FFE3DDDA9291E44B /* Debug */, + 74857149DC1E0D599B8A01A78349A926 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 465B7A6FD7241FE35F81E7FB74CC3BDB /* Build configuration list for PBXNativeTarget "AFNetworking" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3EB83639CF60CD5142C41D2BFA4E470E /* Debug */, + C7A726310DA2E37F196D54D1AB71C0A2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 790CEF25E7273463EB0AC86B53A282E2 /* Build configuration list for PBXNativeTarget "XCDYouTubeKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E54C53DF62871CEE3F692F8EAEC21F80 /* Debug */, + 8CBCF469CD29F5BB2876FD92357062BD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C7C28CB2C678DF04DD6C087A75C86453 /* Build configuration list for PBXNativeTarget "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 8AAADEED682EE38CE46AD9832FFDB5ED /* Debug */, + 70460B3E895DBF3ACACDD9A4B381A523 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/InControl/Pods/SDWebImage/LICENSE b/InControl/Pods/SDWebImage/LICENSE new file mode 100644 index 0000000..ae783e1 --- /dev/null +++ b/InControl/Pods/SDWebImage/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2009 Olivier Poitrey + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/InControl/Pods/SDWebImage/README.md b/InControl/Pods/SDWebImage/README.md new file mode 100644 index 0000000..bc47123 --- /dev/null +++ b/InControl/Pods/SDWebImage/README.md @@ -0,0 +1,315 @@ +Web Image +========= +[![Build Status](http://img.shields.io/travis/rs/SDWebImage/master.svg?style=flat)](https://travis-ci.org/rs/SDWebImage) +[![Pod Version](http://img.shields.io/cocoapods/v/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) +[![Pod Platform](http://img.shields.io/cocoapods/p/SDWebImage.svg?style=flat)](http://cocoadocs.org/docsets/SDWebImage/) +[![Pod License](http://img.shields.io/cocoapods/l/SDWebImage.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0.html) +[![Dependency Status](https://www.versioneye.com/objective-c/sdwebimage/3.3/badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/3.3) +[![Reference Status](https://www.versioneye.com/objective-c/sdwebimage/reference_badge.svg?style=flat)](https://www.versioneye.com/objective-c/sdwebimage/references) +[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/rs/SDWebImage) + +This library provides a category for UIImageView with support for remote images coming from the web. + +It provides: + +- An UIImageView category adding web image and cache management to the Cocoa Touch framework +- An asynchronous image downloader +- An asynchronous memory + disk image caching with automatic cache expiration handling +- Animated GIF support +- WebP format support +- A background image decompression +- A guarantee that the same URL won't be downloaded several times +- A guarantee that bogus URLs won't be retried again and again +- A guarantee that main thread will never be blocked +- Performances! +- Use GCD and ARC +- Arm64 support + +NOTE: The version 3.0 of SDWebImage isn't fully backward compatible with 2.0 and requires iOS 5.1.1 +minimum deployement version. If you need iOS < 5.0 support, please use the last [2.0 version](https://github.com/rs/SDWebImage/tree/2.0-compat). + +[How is SDWebImage better than X?](https://github.com/rs/SDWebImage/wiki/How-is-SDWebImage-better-than-X%3F) + +Who Use It +---------- + +Find out [who uses SDWebImage](https://github.com/rs/SDWebImage/wiki/Who-Uses-SDWebImage) and add your app to the list. + +How To Use +---------- + +API documentation is available at [CocoaDocs - SDWebImage](http://cocoadocs.org/docsets/SDWebImage/) + +### Using UIImageView+WebCache category with UITableView + +Just #import the UIImageView+WebCache.h header, and call the sd_setImageWithURL:placeholderImage: +method from the tableView:cellForRowAtIndexPath: UITableViewDataSource method. Everything will be +handled for you, from async downloads to caching management. + +```objective-c +#import + +... + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *MyIdentifier = @"MyIdentifier"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; + + if (cell == nil) + { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault + reuseIdentifier:MyIdentifier] autorelease]; + } + + // Here we use the new provided sd_setImageWithURL: method to load the web image + [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] + placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; + + cell.textLabel.text = @"My Text"; + return cell; +} +``` + +### Using blocks + +With blocks, you can be notified about the image download progress and whenever the image retrival +has completed with success or not: + +```objective-c +// Here we use the new provided sd_setImageWithURL: method to load the web image +[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] + placeholderImage:[UIImage imageNamed:@"placeholder.png"] + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {... completion code here ...}]; +``` + +Note: neither your success nor failure block will be call if your image request is canceled before completion. + +### Using SDWebImageManager + +The SDWebImageManager is the class behind the UIImageView+WebCache category. It ties the +asynchronous downloader with the image cache store. You can use this class directly to benefit +from web image downloading with caching in another context than a UIView (ie: with Cocoa). + +Here is a simple example of how to use SDWebImageManager: + +```objective-c +SDWebImageManager *manager = [SDWebImageManager sharedManager]; +[manager downloadImageWithURL:imageURL + options:0 + progress:^(NSInteger receivedSize, NSInteger expectedSize) { + // progression tracking code + } + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (image) { + // do something with image + } + }]; +``` + +### Using Asynchronous Image Downloader Independently + +It's also possible to use the async image downloader independently: + +```objective-c +[SDWebImageDownloader.sharedDownloader downloadImageWithURL:imageURL + options:0 + progress:^(NSInteger receivedSize, NSInteger expectedSize) + { + // progression tracking code + } + completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) + { + if (image && finished) + { + // do something with image + } + }]; +``` + +### Using Asynchronous Image Caching Independently + +It is also possible to use the async based image cache store independently. SDImageCache +maintains a memory cache and an optional disk cache. Disk cache write operations are performed +asynchronous so it doesn't add unnecessary latency to the UI. + +The SDImageCache class provides a singleton instance for convenience but you can create your own +instance if you want to create separated cache namespace. + +To lookup the cache, you use the `queryDiskCacheForKey:done:` method. If the method returns nil, it means the cache +doesn't currently own the image. You are thus responsible for generating and caching it. The cache +key is an application unique identifier for the image to cache. It is generally the absolute URL of +the image. + +```objective-c +SDImageCache *imageCache = [[SDImageCache alloc] initWithNamespace:@"myNamespace"]; +[imageCache queryDiskCacheForKey:myCacheKey done:^(UIImage *image) +{ + // image is not nil if image was found +}]; +``` + +By default SDImageCache will lookup the disk cache if an image can't be found in the memory cache. +You can prevent this from happening by calling the alternative method `imageFromMemoryCacheForKey:`. + +To store an image into the cache, you use the storeImage:forKey: method: + +```objective-c +[[SDImageCache sharedImageCache] storeImage:myImage forKey:myCacheKey]; +``` + +By default, the image will be stored in memory cache as well as on disk cache (asynchronously). If +you want only the memory cache, use the alternative method storeImage:forKey:toDisk: with a negative +third argument. + +### Using cache key filter + +Sometime, you may not want to use the image URL as cache key because part of the URL is dynamic +(i.e.: for access control purpose). SDWebImageManager provides a way to set a cache key filter that +takes the NSURL as input, and output a cache key NSString. + +The following example sets a filter in the application delegate that will remove any query-string from +the URL before to use it as a cache key: + +```objective-c +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + SDWebImageManager.sharedManager.cacheKeyFilter = ^(NSURL *url) { + url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; + return [url absoluteString]; + }; + + // Your app init code... + return YES; +} +``` + + +Common Problems +--------------- + +### Using dynamic image size with UITableViewCell + +UITableView determines the size of the image by the first image set for a cell. If your remote images +don't have the same size as your placeholder image, you may experience strange anamorphic scaling issue. +The following article gives a way to workaround this issue: + +[http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/](http://www.wrichards.com/blog/2011/11/sdwebimage-fixed-width-cell-images/) + + +### Handle image refresh + +SDWebImage does very aggressive caching by default. It ignores all kind of caching control header returned by the HTTP server and cache the returned images with no time restriction. It implies your images URLs are static URLs pointing to images that never change. If the pointed image happen to change, some parts of the URL should change accordingly. + +If you don't control the image server you're using, you may not be able to change the URL when its content is updated. This is the case for Facebook avatar URLs for instance. In such case, you may use the `SDWebImageRefreshCached` flag. This will slightly degrade the performance but will respect the HTTP caching control headers: + +``` objective-c +[imageView sd_setImageWithURL:[NSURL URLWithString:@"https://graph.facebook.com/olivier.poitrey/picture"] + placeholderImage:[UIImage imageNamed:@"avatar-placeholder.png"] + options:SDWebImageRefreshCached]; +``` + +### Add a progress indicator + +See this category: https://github.com/JJSaccolo/UIActivityIndicator-for-SDWebImage + +Installation +------------ + +There are three ways to use SDWebImage in your project: +- using Cocoapods +- copying all the files into your project +- importing the project as a static library + +### Installation with CocoaPods + +[CocoaPods](http://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the [Get Started](http://cocoapods.org/#get_started) section for more details. + +#### Podfile +``` +platform :ios, '6.1' +pod 'SDWebImage', '~>3.7' +``` + +### Installation with Carthage (iOS 8+) + +[Carthage](https://github.com/Carthage/Carthage) is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and ins less invasive than CocoaPods. + +To install with carthage, follow the instruction on [Carthage](https://github.com/Carthage/Carthage) + +#### Cartfile +``` +github "rs/SDWebImage" +``` + +#### Usage +Swift + +``` +import WebImage + +``` + +Objective-C + +``` +@import WebImage; +``` + +### Installation by cloning the repository + +In order to gain access to all the files from the repository, you should clone it. +``` +git clone --recursive https://github.com/rs/SDWebImage.git +``` + +### Add the SDWebImage project to your project + +- Download and unzip the last version of the framework from the [download page](https://github.com/rs/SDWebImage/releases) +- Right-click on the project navigator and select "Add Files to "Your Project": +- In the dialog, select SDWebImage.framework: +- Check the "Copy items into destination group's folder (if needed)" checkbox + +### Add dependencies + +- In you application project app’s target settings, find the "Build Phases" section and open the "Link Binary With Libraries" block: +- Click the "+" button again and select the "ImageIO.framework", this is needed by the progressive download feature: + +### Add Linker Flag + +Open the "Build Settings" tab, in the "Linking" section, locate the "Other Linker Flags" setting and add the "-ObjC" flag: + +![Other Linker Flags](http://dl.dropbox.com/u/123346/SDWebImage/10_other_linker_flags.jpg) + +Alternatively, if this causes compilation problems with frameworks that extend optional libraries, such as Parse, RestKit or opencv2, instead of the -ObjC flag use: +``` +-force_load SDWebImage.framework/Versions/Current/SDWebImage +``` + +If you're using Cocoa Pods and have any frameworks that extend optional libraries, such as Parsen RestKit or opencv2, instead of the -ObjC flag use: +``` +-force_load $(TARGET_BUILD_DIR)/libPods.a +``` + +### Import headers in your source files + +In the source files where you need to use the library, import the header file: + +```objective-c +#import +``` + +### Build Project + +At this point your workspace should build without error. If you are having problem, post to the Issue and the +community can help you solve it. + +Future Enhancements +------------------- + +- LRU memory cache cleanup instead of reset on memory warning + +## Licenses + +All source code is licensed under the [MIT License](https://raw.github.com/rs/SDWebImage/master/LICENSE). diff --git a/InControl/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h b/InControl/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h new file mode 100644 index 0000000..69c76dc --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.h @@ -0,0 +1,26 @@ +// +// Created by Fabrice Aneche on 06/01/14. +// Copyright (c) 2014 Dailymotion. All rights reserved. +// + +#import + +@interface NSData (ImageContentType) + +/** + * Compute the content type for an image data + * + * @param data the input data + * + * @return the content type as string (i.e. image/jpeg, image/gif) + */ ++ (NSString *)sd_contentTypeForImageData:(NSData *)data; + +@end + + +@interface NSData (ImageContentTypeDeprecated) + ++ (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m b/InControl/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m new file mode 100644 index 0000000..0941cfa --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/NSData+ImageContentType.m @@ -0,0 +1,49 @@ +// +// Created by Fabrice Aneche on 06/01/14. +// Copyright (c) 2014 Dailymotion. All rights reserved. +// + +#import "NSData+ImageContentType.h" + + +@implementation NSData (ImageContentType) + ++ (NSString *)sd_contentTypeForImageData:(NSData *)data { + uint8_t c; + [data getBytes:&c length:1]; + switch (c) { + case 0xFF: + return @"image/jpeg"; + case 0x89: + return @"image/png"; + case 0x47: + return @"image/gif"; + case 0x49: + case 0x4D: + return @"image/tiff"; + case 0x52: + // R as RIFF for WEBP + if ([data length] < 12) { + return nil; + } + + NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; + if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { + return @"image/webp"; + } + + return nil; + } + return nil; +} + +@end + + +@implementation NSData (ImageContentTypeDeprecated) + ++ (NSString *)contentTypeForImageData:(NSData *)data { + return [self sd_contentTypeForImageData:data]; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDImageCache.h b/InControl/Pods/SDWebImage/SDWebImage/SDImageCache.h new file mode 100644 index 0000000..8e08aa1 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDImageCache.h @@ -0,0 +1,262 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +typedef NS_ENUM(NSInteger, SDImageCacheType) { + /** + * The image wasn't available the SDWebImage caches, but was downloaded from the web. + */ + SDImageCacheTypeNone, + /** + * The image was obtained from the disk cache. + */ + SDImageCacheTypeDisk, + /** + * The image was obtained from the memory cache. + */ + SDImageCacheTypeMemory +}; + +typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType); + +typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache); + +typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); + +/** + * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed + * asynchronous so it doesn’t add unnecessary latency to the UI. + */ +@interface SDImageCache : NSObject + +/** + * Decompressing images that are downloaded and cached can improve peformance but can consume lot of memory. + * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. + */ +@property (assign, nonatomic) BOOL shouldDecompressImages; + +/** + * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. + */ +@property (assign, nonatomic) NSUInteger maxMemoryCost; + +/** + * The maximum number of objects the cache should hold. + */ +@property (assign, nonatomic) NSUInteger maxMemoryCountLimit; + +/** + * The maximum length of time to keep an image in the cache, in seconds + */ +@property (assign, nonatomic) NSInteger maxCacheAge; + +/** + * The maximum size of the cache, in bytes. + */ +@property (assign, nonatomic) NSUInteger maxCacheSize; + +/** + * Returns global shared cache instance + * + * @return SDImageCache global instance + */ ++ (SDImageCache *)sharedImageCache; + +/** + * Init a new cache store with a specific namespace + * + * @param ns The namespace to use for this cache store + */ +- (id)initWithNamespace:(NSString *)ns; + +/** + * Init a new cache store with a specific namespace and directory + * + * @param ns The namespace to use for this cache store + * @param directory Directory to cache disk images in + */ +- (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory; + +-(NSString *)makeDiskCachePath:(NSString*)fullNamespace; + +/** + * Add a read-only cache path to search for images pre-cached by SDImageCache + * Useful if you want to bundle pre-loaded images with your app + * + * @param path The path to use for this read-only cache path + */ +- (void)addReadOnlyCachePath:(NSString *)path; + +/** + * Store an image into memory and disk cache at the given key. + * + * @param image The image to store + * @param key The unique image cache key, usually it's image absolute URL + */ +- (void)storeImage:(UIImage *)image forKey:(NSString *)key; + +/** + * Store an image into memory and optionally disk cache at the given key. + * + * @param image The image to store + * @param key The unique image cache key, usually it's image absolute URL + * @param toDisk Store the image to disk cache if YES + */ +- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk; + +/** + * Store an image into memory and optionally disk cache at the given key. + * + * @param image The image to store + * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage + * @param imageData The image data as returned by the server, this representation will be used for disk storage + * instead of converting the given image object into a storable/compressed image format in order + * to save quality and CPU + * @param key The unique image cache key, usually it's image absolute URL + * @param toDisk Store the image to disk cache if YES + */ +- (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk; + +/** + * Query the disk cache asynchronously. + * + * @param key The unique key used to store the wanted image + */ +- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock; + +/** + * Query the memory cache synchronously. + * + * @param key The unique key used to store the wanted image + */ +- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key; + +/** + * Query the disk cache synchronously after checking the memory cache. + * + * @param key The unique key used to store the wanted image + */ +- (UIImage *)imageFromDiskCacheForKey:(NSString *)key; + +/** + * Remove the image from memory and disk cache synchronously + * + * @param key The unique image cache key + */ +- (void)removeImageForKey:(NSString *)key; + + +/** + * Remove the image from memory and disk cache asynchronously + * + * @param key The unique image cache key + * @param completion An block that should be executed after the image has been removed (optional) + */ +- (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion; + +/** + * Remove the image from memory and optionally disk cache asynchronously + * + * @param key The unique image cache key + * @param fromDisk Also remove cache entry from disk if YES + */ +- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk; + +/** + * Remove the image from memory and optionally disk cache asynchronously + * + * @param key The unique image cache key + * @param fromDisk Also remove cache entry from disk if YES + * @param completion An block that should be executed after the image has been removed (optional) + */ +- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion; + +/** + * Clear all memory cached images + */ +- (void)clearMemory; + +/** + * Clear all disk cached images. Non-blocking method - returns immediately. + * @param completion An block that should be executed after cache expiration completes (optional) + */ +- (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion; + +/** + * Clear all disk cached images + * @see clearDiskOnCompletion: + */ +- (void)clearDisk; + +/** + * Remove all expired cached image from disk. Non-blocking method - returns immediately. + * @param completionBlock An block that should be executed after cache expiration completes (optional) + */ +- (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock; + +/** + * Remove all expired cached image from disk + * @see cleanDiskWithCompletionBlock: + */ +- (void)cleanDisk; + +/** + * Get the size used by the disk cache + */ +- (NSUInteger)getSize; + +/** + * Get the number of images in the disk cache + */ +- (NSUInteger)getDiskCount; + +/** + * Asynchronously calculate the disk cache's size. + */ +- (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock; + +/** + * Async check if image exists in disk cache already (does not load the image) + * + * @param key the key describing the url + * @param completionBlock the block to be executed when the check is done. + * @note the completion block will be always executed on the main queue + */ +- (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; + +/** + * Check if image exists in disk cache already (does not load the image) + * + * @param key the key describing the url + * + * @return YES if an image exists for the given key + */ +- (BOOL)diskImageExistsWithKey:(NSString *)key; + +/** + * Get the cache path for a certain key (needs the cache path root folder) + * + * @param key the key (can be obtained from url using cacheKeyForURL) + * @param path the cach path root folder + * + * @return the cache path + */ +- (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path; + +/** + * Get the default cache path for a certain key + * + * @param key the key (can be obtained from url using cacheKeyForURL) + * + * @return the default cache path + */ +- (NSString *)defaultCachePathForKey:(NSString *)key; + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDImageCache.m b/InControl/Pods/SDWebImage/SDWebImage/SDImageCache.m new file mode 100644 index 0000000..2202602 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDImageCache.m @@ -0,0 +1,601 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDImageCache.h" +#import "SDWebImageDecoder.h" +#import "UIImage+MultiFormat.h" +#import + +// See https://github.com/rs/SDWebImage/pull/1141 for discussion +@interface AutoPurgeCache : NSCache +@end + +@implementation AutoPurgeCache + +- (id)init +{ + self = [super init]; + if (self) { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeAllObjects) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; + } + return self; +} + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; + +} + +@end + +static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week +// PNG signature bytes and data (below) +static unsigned char kPNGSignatureBytes[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; +static NSData *kPNGSignatureData = nil; + +BOOL ImageDataHasPNGPreffix(NSData *data); + +BOOL ImageDataHasPNGPreffix(NSData *data) { + NSUInteger pngSignatureLength = [kPNGSignatureData length]; + if ([data length] >= pngSignatureLength) { + if ([[data subdataWithRange:NSMakeRange(0, pngSignatureLength)] isEqualToData:kPNGSignatureData]) { + return YES; + } + } + + return NO; +} + +FOUNDATION_STATIC_INLINE NSUInteger SDCacheCostForImage(UIImage *image) { + return image.size.height * image.size.width * image.scale * image.scale; +} + +@interface SDImageCache () + +@property (strong, nonatomic) NSCache *memCache; +@property (strong, nonatomic) NSString *diskCachePath; +@property (strong, nonatomic) NSMutableArray *customPaths; +@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t ioQueue; + +@end + + +@implementation SDImageCache { + NSFileManager *_fileManager; +} + ++ (SDImageCache *)sharedImageCache { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (id)init { + return [self initWithNamespace:@"default"]; +} + +- (id)initWithNamespace:(NSString *)ns { + NSString *path = [self makeDiskCachePath:ns]; + return [self initWithNamespace:ns diskCacheDirectory:path]; +} + +- (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory { + if ((self = [super init])) { + NSString *fullNamespace = [@"com.hackemist.SDWebImageCache." stringByAppendingString:ns]; + + // initialise PNG signature data + kPNGSignatureData = [NSData dataWithBytes:kPNGSignatureBytes length:8]; + + // Create IO serial queue + _ioQueue = dispatch_queue_create("com.hackemist.SDWebImageCache", DISPATCH_QUEUE_SERIAL); + + // Init default values + _maxCacheAge = kDefaultCacheMaxCacheAge; + + // Init the memory cache + _memCache = [[AutoPurgeCache alloc] init]; + _memCache.name = fullNamespace; + + // Init the disk cache + if (directory != nil) { + _diskCachePath = [directory stringByAppendingPathComponent:fullNamespace]; + } else { + NSString *path = [self makeDiskCachePath:ns]; + _diskCachePath = path; + } + + // Set decompression to YES + _shouldDecompressImages = YES; + + dispatch_sync(_ioQueue, ^{ + _fileManager = [NSFileManager new]; + }); + +#if TARGET_OS_IPHONE + // Subscribe to app events + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(clearMemory) + name:UIApplicationDidReceiveMemoryWarningNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(cleanDisk) + name:UIApplicationWillTerminateNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(backgroundCleanDisk) + name:UIApplicationDidEnterBackgroundNotification + object:nil]; +#endif + } + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + SDDispatchQueueRelease(_ioQueue); +} + +- (void)addReadOnlyCachePath:(NSString *)path { + if (!self.customPaths) { + self.customPaths = [NSMutableArray new]; + } + + if (![self.customPaths containsObject:path]) { + [self.customPaths addObject:path]; + } +} + +- (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path { + NSString *filename = [self cachedFileNameForKey:key]; + return [path stringByAppendingPathComponent:filename]; +} + +- (NSString *)defaultCachePathForKey:(NSString *)key { + return [self cachePathForKey:key inPath:self.diskCachePath]; +} + +#pragma mark SDImageCache (private) + +- (NSString *)cachedFileNameForKey:(NSString *)key { + const char *str = [key UTF8String]; + if (str == NULL) { + str = ""; + } + unsigned char r[CC_MD5_DIGEST_LENGTH]; + CC_MD5(str, (CC_LONG)strlen(str), r); + NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15]]; + + return filename; +} + +#pragma mark ImageCache + +// Init the disk cache +-(NSString *)makeDiskCachePath:(NSString*)fullNamespace{ + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + return [paths[0] stringByAppendingPathComponent:fullNamespace]; +} + +- (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk { + if (!image || !key) { + return; + } + + NSUInteger cost = SDCacheCostForImage(image); + [self.memCache setObject:image forKey:key cost:cost]; + + if (toDisk) { + dispatch_async(self.ioQueue, ^{ + NSData *data = imageData; + + if (image && (recalculate || !data)) { +#if TARGET_OS_IPHONE + // We need to determine if the image is a PNG or a JPEG + // PNGs are easier to detect because they have a unique signature (http://www.w3.org/TR/PNG-Structure.html) + // The first eight bytes of a PNG file always contain the following (decimal) values: + // 137 80 78 71 13 10 26 10 + + // If the imageData is nil (i.e. if trying to save a UIImage directly or the image was transformed on download) + // and the image has an alpha channel, we will consider it PNG to avoid losing the transparency + int alphaInfo = CGImageGetAlphaInfo(image.CGImage); + BOOL hasAlpha = !(alphaInfo == kCGImageAlphaNone || + alphaInfo == kCGImageAlphaNoneSkipFirst || + alphaInfo == kCGImageAlphaNoneSkipLast); + BOOL imageIsPng = hasAlpha; + + // But if we have an image data, we will look at the preffix + if ([imageData length] >= [kPNGSignatureData length]) { + imageIsPng = ImageDataHasPNGPreffix(imageData); + } + + if (imageIsPng) { + data = UIImagePNGRepresentation(image); + } + else { + data = UIImageJPEGRepresentation(image, (CGFloat)1.0); + } +#else + data = [NSBitmapImageRep representationOfImageRepsInArray:image.representations usingType: NSJPEGFileType properties:nil]; +#endif + } + + if (data) { + if (![_fileManager fileExistsAtPath:_diskCachePath]) { + [_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL]; + } + + [_fileManager createFileAtPath:[self defaultCachePathForKey:key] contents:data attributes:nil]; + } + }); + } +} + +- (void)storeImage:(UIImage *)image forKey:(NSString *)key { + [self storeImage:image recalculateFromImage:YES imageData:nil forKey:key toDisk:YES]; +} + +- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk { + [self storeImage:image recalculateFromImage:YES imageData:nil forKey:key toDisk:toDisk]; +} + +- (BOOL)diskImageExistsWithKey:(NSString *)key { + BOOL exists = NO; + + // this is an exception to access the filemanager on another queue than ioQueue, but we are using the shared instance + // from apple docs on NSFileManager: The methods of the shared NSFileManager object can be called from multiple threads safely. + exists = [[NSFileManager defaultManager] fileExistsAtPath:[self defaultCachePathForKey:key]]; + + return exists; +} + +- (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { + dispatch_async(_ioQueue, ^{ + BOOL exists = [_fileManager fileExistsAtPath:[self defaultCachePathForKey:key]]; + if (completionBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + completionBlock(exists); + }); + } + }); +} + +- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key { + return [self.memCache objectForKey:key]; +} + +- (UIImage *)imageFromDiskCacheForKey:(NSString *)key { + // First check the in-memory cache... + UIImage *image = [self imageFromMemoryCacheForKey:key]; + if (image) { + return image; + } + + // Second check the disk cache... + UIImage *diskImage = [self diskImageForKey:key]; + if (diskImage) { + NSUInteger cost = SDCacheCostForImage(diskImage); + [self.memCache setObject:diskImage forKey:key cost:cost]; + } + + return diskImage; +} + +- (NSData *)diskImageDataBySearchingAllPathsForKey:(NSString *)key { + NSString *defaultPath = [self defaultCachePathForKey:key]; + NSData *data = [NSData dataWithContentsOfFile:defaultPath]; + if (data) { + return data; + } + + NSArray *customPaths = [self.customPaths copy]; + for (NSString *path in customPaths) { + NSString *filePath = [self cachePathForKey:key inPath:path]; + NSData *imageData = [NSData dataWithContentsOfFile:filePath]; + if (imageData) { + return imageData; + } + } + + return nil; +} + +- (UIImage *)diskImageForKey:(NSString *)key { + NSData *data = [self diskImageDataBySearchingAllPathsForKey:key]; + if (data) { + UIImage *image = [UIImage sd_imageWithData:data]; + image = [self scaledImageForKey:key image:image]; + if (self.shouldDecompressImages) { + image = [UIImage decodedImageWithImage:image]; + } + return image; + } + else { + return nil; + } +} + +- (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image { + return SDScaledImageForKey(key, image); +} + +- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock { + if (!doneBlock) { + return nil; + } + + if (!key) { + doneBlock(nil, SDImageCacheTypeNone); + return nil; + } + + // First check the in-memory cache... + UIImage *image = [self imageFromMemoryCacheForKey:key]; + if (image) { + doneBlock(image, SDImageCacheTypeMemory); + return nil; + } + + NSOperation *operation = [NSOperation new]; + dispatch_async(self.ioQueue, ^{ + if (operation.isCancelled) { + return; + } + + @autoreleasepool { + UIImage *diskImage = [self diskImageForKey:key]; + if (diskImage) { + NSUInteger cost = SDCacheCostForImage(diskImage); + [self.memCache setObject:diskImage forKey:key cost:cost]; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + doneBlock(diskImage, SDImageCacheTypeDisk); + }); + } + }); + + return operation; +} + +- (void)removeImageForKey:(NSString *)key { + [self removeImageForKey:key withCompletion:nil]; +} + +- (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion { + [self removeImageForKey:key fromDisk:YES withCompletion:completion]; +} + +- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk { + [self removeImageForKey:key fromDisk:fromDisk withCompletion:nil]; +} + +- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion { + + if (key == nil) { + return; + } + + [self.memCache removeObjectForKey:key]; + + if (fromDisk) { + dispatch_async(self.ioQueue, ^{ + [_fileManager removeItemAtPath:[self defaultCachePathForKey:key] error:nil]; + + if (completion) { + dispatch_async(dispatch_get_main_queue(), ^{ + completion(); + }); + } + }); + } else if (completion){ + completion(); + } + +} + +- (void)setMaxMemoryCost:(NSUInteger)maxMemoryCost { + self.memCache.totalCostLimit = maxMemoryCost; +} + +- (NSUInteger)maxMemoryCost { + return self.memCache.totalCostLimit; +} + +- (NSUInteger)maxMemoryCountLimit { + return self.memCache.countLimit; +} + +- (void)setMaxMemoryCountLimit:(NSUInteger)maxCountLimit { + self.memCache.countLimit = maxCountLimit; +} + +- (void)clearMemory { + [self.memCache removeAllObjects]; +} + +- (void)clearDisk { + [self clearDiskOnCompletion:nil]; +} + +- (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion +{ + dispatch_async(self.ioQueue, ^{ + [_fileManager removeItemAtPath:self.diskCachePath error:nil]; + [_fileManager createDirectoryAtPath:self.diskCachePath + withIntermediateDirectories:YES + attributes:nil + error:NULL]; + + if (completion) { + dispatch_async(dispatch_get_main_queue(), ^{ + completion(); + }); + } + }); +} + +- (void)cleanDisk { + [self cleanDiskWithCompletionBlock:nil]; +} + +- (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock { + dispatch_async(self.ioQueue, ^{ + NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; + NSArray *resourceKeys = @[NSURLIsDirectoryKey, NSURLContentModificationDateKey, NSURLTotalFileAllocatedSizeKey]; + + // This enumerator prefetches useful properties for our cache files. + NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtURL:diskCacheURL + includingPropertiesForKeys:resourceKeys + options:NSDirectoryEnumerationSkipsHiddenFiles + errorHandler:NULL]; + + NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-self.maxCacheAge]; + NSMutableDictionary *cacheFiles = [NSMutableDictionary dictionary]; + NSUInteger currentCacheSize = 0; + + // Enumerate all of the files in the cache directory. This loop has two purposes: + // + // 1. Removing files that are older than the expiration date. + // 2. Storing file attributes for the size-based cleanup pass. + NSMutableArray *urlsToDelete = [[NSMutableArray alloc] init]; + for (NSURL *fileURL in fileEnumerator) { + NSDictionary *resourceValues = [fileURL resourceValuesForKeys:resourceKeys error:NULL]; + + // Skip directories. + if ([resourceValues[NSURLIsDirectoryKey] boolValue]) { + continue; + } + + // Remove files that are older than the expiration date; + NSDate *modificationDate = resourceValues[NSURLContentModificationDateKey]; + if ([[modificationDate laterDate:expirationDate] isEqualToDate:expirationDate]) { + [urlsToDelete addObject:fileURL]; + continue; + } + + // Store a reference to this file and account for its total size. + NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; + currentCacheSize += [totalAllocatedSize unsignedIntegerValue]; + [cacheFiles setObject:resourceValues forKey:fileURL]; + } + + for (NSURL *fileURL in urlsToDelete) { + [_fileManager removeItemAtURL:fileURL error:nil]; + } + + // If our remaining disk cache exceeds a configured maximum size, perform a second + // size-based cleanup pass. We delete the oldest files first. + if (self.maxCacheSize > 0 && currentCacheSize > self.maxCacheSize) { + // Target half of our maximum cache size for this cleanup pass. + const NSUInteger desiredCacheSize = self.maxCacheSize / 2; + + // Sort the remaining cache files by their last modification time (oldest first). + NSArray *sortedFiles = [cacheFiles keysSortedByValueWithOptions:NSSortConcurrent + usingComparator:^NSComparisonResult(id obj1, id obj2) { + return [obj1[NSURLContentModificationDateKey] compare:obj2[NSURLContentModificationDateKey]]; + }]; + + // Delete files until we fall below our desired cache size. + for (NSURL *fileURL in sortedFiles) { + if ([_fileManager removeItemAtURL:fileURL error:nil]) { + NSDictionary *resourceValues = cacheFiles[fileURL]; + NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; + currentCacheSize -= [totalAllocatedSize unsignedIntegerValue]; + + if (currentCacheSize < desiredCacheSize) { + break; + } + } + } + } + if (completionBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + completionBlock(); + }); + } + }); +} + +- (void)backgroundCleanDisk { + Class UIApplicationClass = NSClassFromString(@"UIApplication"); + if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { + return; + } + UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)]; + __block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{ + // Clean up any unfinished task business by marking where you + // stopped or ending the task outright. + [application endBackgroundTask:bgTask]; + bgTask = UIBackgroundTaskInvalid; + }]; + + // Start the long-running task and return immediately. + [self cleanDiskWithCompletionBlock:^{ + [application endBackgroundTask:bgTask]; + bgTask = UIBackgroundTaskInvalid; + }]; +} + +- (NSUInteger)getSize { + __block NSUInteger size = 0; + dispatch_sync(self.ioQueue, ^{ + NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; + for (NSString *fileName in fileEnumerator) { + NSString *filePath = [self.diskCachePath stringByAppendingPathComponent:fileName]; + NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; + size += [attrs fileSize]; + } + }); + return size; +} + +- (NSUInteger)getDiskCount { + __block NSUInteger count = 0; + dispatch_sync(self.ioQueue, ^{ + NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; + count = [[fileEnumerator allObjects] count]; + }); + return count; +} + +- (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock { + NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; + + dispatch_async(self.ioQueue, ^{ + NSUInteger fileCount = 0; + NSUInteger totalSize = 0; + + NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtURL:diskCacheURL + includingPropertiesForKeys:@[NSFileSize] + options:NSDirectoryEnumerationSkipsHiddenFiles + errorHandler:NULL]; + + for (NSURL *fileURL in fileEnumerator) { + NSNumber *fileSize; + [fileURL getResourceValue:&fileSize forKey:NSURLFileSizeKey error:NULL]; + totalSize += [fileSize unsignedIntegerValue]; + fileCount += 1; + } + + if (completionBlock) { + dispatch_async(dispatch_get_main_queue(), ^{ + completionBlock(fileCount, totalSize); + }); + } + }); +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h new file mode 100644 index 0000000..9773545 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageCompat.h @@ -0,0 +1,72 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * (c) Jamie Pinkham + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import + +#ifdef __OBJC_GC__ +#error SDWebImage does not support Objective-C Garbage Collection +#endif + +#if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 +#error SDWebImage doesn't support Deployement Target version < 5.0 +#endif + +#if !TARGET_OS_IPHONE +#import +#ifndef UIImage +#define UIImage NSImage +#endif +#ifndef UIImageView +#define UIImageView NSImageView +#endif +#else + +#import + +#endif + +#ifndef NS_ENUM +#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type +#endif + +#ifndef NS_OPTIONS +#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type +#endif + +#if OS_OBJECT_USE_OBJC + #undef SDDispatchQueueRelease + #undef SDDispatchQueueSetterSementics + #define SDDispatchQueueRelease(q) + #define SDDispatchQueueSetterSementics strong +#else +#undef SDDispatchQueueRelease +#undef SDDispatchQueueSetterSementics +#define SDDispatchQueueRelease(q) (dispatch_release(q)) +#define SDDispatchQueueSetterSementics assign +#endif + +extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); + +typedef void(^SDWebImageNoParamsBlock)(); + +extern NSString *const SDWebImageErrorDomain; + +#define dispatch_main_sync_safe(block)\ + if ([NSThread isMainThread]) {\ + block();\ + } else {\ + dispatch_sync(dispatch_get_main_queue(), block);\ + } + +#define dispatch_main_async_safe(block)\ + if ([NSThread isMainThread]) {\ + block();\ + } else {\ + dispatch_async(dispatch_get_main_queue(), block);\ + } diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m new file mode 100644 index 0000000..54fb60e --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageCompat.m @@ -0,0 +1,51 @@ +// +// SDWebImageCompat.m +// SDWebImage +// +// Created by Olivier Poitrey on 11/12/12. +// Copyright (c) 2012 Dailymotion. All rights reserved. +// + +#import "SDWebImageCompat.h" + +#if !__has_feature(objc_arc) +#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag +#endif + +inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { + if (!image) { + return nil; + } + + if ([image.images count] > 0) { + NSMutableArray *scaledImages = [NSMutableArray array]; + + for (UIImage *tempImage in image.images) { + [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; + } + + return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; + } + else { + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { + CGFloat scale = 1.0; + if (key.length >= 8) { + NSRange range = [key rangeOfString:@"@2x."]; + if (range.location != NSNotFound) { + scale = 2.0; + } + + range = [key rangeOfString:@"@3x."]; + if (range.location != NSNotFound) { + scale = 3.0; + } + } + + UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; + image = scaledImage; + } + return image; + } +} + +NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h new file mode 100644 index 0000000..0176a7b --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.h @@ -0,0 +1,18 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * Created by james on 9/28/11. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" + +@interface UIImage (ForceDecode) + ++ (UIImage *)decodedImageWithImage:(UIImage *)image; + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m new file mode 100644 index 0000000..79ddb30 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDecoder.m @@ -0,0 +1,72 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * Created by james on 9/28/11. + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDecoder.h" + +@implementation UIImage (ForceDecode) + ++ (UIImage *)decodedImageWithImage:(UIImage *)image { + if (image.images) { + // Do not decode animated images + return image; + } + + CGImageRef imageRef = image.CGImage; + CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); + CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize}; + + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + + int infoMask = (bitmapInfo & kCGBitmapAlphaInfoMask); + BOOL anyNonAlpha = (infoMask == kCGImageAlphaNone || + infoMask == kCGImageAlphaNoneSkipFirst || + infoMask == kCGImageAlphaNoneSkipLast); + + // CGBitmapContextCreate doesn't support kCGImageAlphaNone with RGB. + // https://developer.apple.com/library/mac/#qa/qa1037/_index.html + if (infoMask == kCGImageAlphaNone && CGColorSpaceGetNumberOfComponents(colorSpace) > 1) { + // Unset the old alpha info. + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + + // Set noneSkipFirst. + bitmapInfo |= kCGImageAlphaNoneSkipFirst; + } + // Some PNGs tell us they have alpha but only 3 components. Odd. + else if (!anyNonAlpha && CGColorSpaceGetNumberOfComponents(colorSpace) == 3) { + // Unset the old alpha info. + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaPremultipliedFirst; + } + + // It calculates the bytes-per-row based on the bitsPerComponent and width arguments. + CGContextRef context = CGBitmapContextCreate(NULL, + imageSize.width, + imageSize.height, + CGImageGetBitsPerComponent(imageRef), + 0, + colorSpace, + bitmapInfo); + CGColorSpaceRelease(colorSpace); + + // If failed, return undecompressed image + if (!context) return image; + + CGContextDrawImage(context, imageRect, imageRef); + CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + UIImage *decompressedImage = [UIImage imageWithCGImage:decompressedImageRef scale:image.scale orientation:image.imageOrientation]; + CGImageRelease(decompressedImageRef); + return decompressedImage; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h new file mode 100644 index 0000000..b8db86f --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.h @@ -0,0 +1,186 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" +#import "SDWebImageOperation.h" + +typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { + SDWebImageDownloaderLowPriority = 1 << 0, + SDWebImageDownloaderProgressiveDownload = 1 << 1, + + /** + * By default, request prevent the of NSURLCache. With this flag, NSURLCache + * is used with default policies. + */ + SDWebImageDownloaderUseNSURLCache = 1 << 2, + + /** + * Call completion block with nil image/imageData if the image was read from NSURLCache + * (to be combined with `SDWebImageDownloaderUseNSURLCache`). + */ + + SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, + /** + * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for + * extra time in background to let the request finish. If the background task expires the operation will be cancelled. + */ + + SDWebImageDownloaderContinueInBackground = 1 << 4, + + /** + * Handles cookies stored in NSHTTPCookieStore by setting + * NSMutableURLRequest.HTTPShouldHandleCookies = YES; + */ + SDWebImageDownloaderHandleCookies = 1 << 5, + + /** + * Enable to allow untrusted SSL ceriticates. + * Useful for testing purposes. Use with caution in production. + */ + SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, + + /** + * Put the image in the high priority queue. + */ + SDWebImageDownloaderHighPriority = 1 << 7, +}; + +typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { + /** + * Default value. All download operations will execute in queue style (first-in-first-out). + */ + SDWebImageDownloaderFIFOExecutionOrder, + + /** + * All download operations will execute in stack style (last-in-first-out). + */ + SDWebImageDownloaderLIFOExecutionOrder +}; + +extern NSString *const SDWebImageDownloadStartNotification; +extern NSString *const SDWebImageDownloadStopNotification; + +typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); + +typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); + +typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDictionary *headers); + +/** + * Asynchronous downloader dedicated and optimized for image loading. + */ +@interface SDWebImageDownloader : NSObject + +/** + * Decompressing images that are downloaded and cached can improve peformance but can consume lot of memory. + * Defaults to YES. Set this to NO if you are experiencing a crash due to excessive memory consumption. + */ +@property (assign, nonatomic) BOOL shouldDecompressImages; + +@property (assign, nonatomic) NSInteger maxConcurrentDownloads; + +/** + * Shows the current amount of downloads that still need to be downloaded + */ +@property (readonly, nonatomic) NSUInteger currentDownloadCount; + + +/** + * The timeout value (in seconds) for the download operation. Default: 15.0. + */ +@property (assign, nonatomic) NSTimeInterval downloadTimeout; + + +/** + * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. + */ +@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; + +/** + * Singleton method, returns the shared instance + * + * @return global shared instance of downloader class + */ ++ (SDWebImageDownloader *)sharedDownloader; + +/** + * Set username + */ +@property (strong, nonatomic) NSString *username; + +/** + * Set password + */ +@property (strong, nonatomic) NSString *password; + +/** + * Set filter to pick headers for downloading image HTTP request. + * + * This block will be invoked for each downloading image request, returned + * NSDictionary will be used as headers in corresponding HTTP request. + */ +@property (nonatomic, copy) SDWebImageDownloaderHeadersFilterBlock headersFilter; + +/** + * Set a value for a HTTP header to be appended to each download HTTP request. + * + * @param value The value for the header field. Use `nil` value to remove the header. + * @param field The name of the header field to set. + */ +- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field; + +/** + * Returns the value of the specified HTTP header field. + * + * @return The value associated with the header field field, or `nil` if there is no corresponding header field. + */ +- (NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + * Sets a subclass of `SDWebImageDownloaderOperation` as the default + * `NSOperation` to be used each time SDWebImage constructs a request + * operation to download an image. + * + * @param operationClass The subclass of `SDWebImageDownloaderOperation` to set + * as default. Passing `nil` will revert to `SDWebImageDownloaderOperation`. + */ +- (void)setOperationClass:(Class)operationClass; + +/** + * Creates a SDWebImageDownloader async downloader instance with a given URL + * + * The delegate will be informed when the image is finish downloaded or an error has happen. + * + * @see SDWebImageDownloaderDelegate + * + * @param url The URL to the image to download + * @param options The options to be used for this download + * @param progressBlock A block called repeatedly while the image is downloading + * @param completedBlock A block called once the download is completed. + * If the download succeeded, the image parameter is set, in case of error, + * error parameter is set with the error. The last parameter is always YES + * if SDWebImageDownloaderProgressiveDownload isn't use. With the + * SDWebImageDownloaderProgressiveDownload option, this block is called + * repeatedly with the partial image object and the finished argument set to NO + * before to be called a last time with the full image and finished argument + * set to YES. In case of error, the finished argument is always YES. + * + * @return A cancellable SDWebImageOperation + */ +- (id )downloadImageWithURL:(NSURL *)url + options:(SDWebImageDownloaderOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageDownloaderCompletedBlock)completedBlock; + +/** + * Sets the download queue suspension state + */ +- (void)setSuspended:(BOOL)suspended; + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m new file mode 100644 index 0000000..acda892 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloader.m @@ -0,0 +1,228 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDownloader.h" +#import "SDWebImageDownloaderOperation.h" +#import + +static NSString *const kProgressCallbackKey = @"progress"; +static NSString *const kCompletedCallbackKey = @"completed"; + +@interface SDWebImageDownloader () + +@property (strong, nonatomic) NSOperationQueue *downloadQueue; +@property (weak, nonatomic) NSOperation *lastAddedOperation; +@property (assign, nonatomic) Class operationClass; +@property (strong, nonatomic) NSMutableDictionary *URLCallbacks; +@property (strong, nonatomic) NSMutableDictionary *HTTPHeaders; +// This queue is used to serialize the handling of the network responses of all the download operation in a single queue +@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t barrierQueue; + +@end + +@implementation SDWebImageDownloader + ++ (void)initialize { + // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator ) + // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import + if (NSClassFromString(@"SDNetworkActivityIndicator")) { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")]; +#pragma clang diagnostic pop + + // Remove observer in case it was previously added. + [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:activityIndicator + selector:NSSelectorFromString(@"startActivity") + name:SDWebImageDownloadStartNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:activityIndicator + selector:NSSelectorFromString(@"stopActivity") + name:SDWebImageDownloadStopNotification object:nil]; + } +} + ++ (SDWebImageDownloader *)sharedDownloader { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (id)init { + if ((self = [super init])) { + _operationClass = [SDWebImageDownloaderOperation class]; + _shouldDecompressImages = YES; + _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; + _downloadQueue = [NSOperationQueue new]; + _downloadQueue.maxConcurrentOperationCount = 6; + _URLCallbacks = [NSMutableDictionary new]; +#ifdef SD_WEBP + _HTTPHeaders = [@{@"Accept": @"image/webp,image/*;q=0.8"} mutableCopy]; +#else + _HTTPHeaders = [@{@"Accept": @"image/*;q=0.8"} mutableCopy]; +#endif + _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT); + _downloadTimeout = 15.0; + } + return self; +} + +- (void)dealloc { + [self.downloadQueue cancelAllOperations]; + SDDispatchQueueRelease(_barrierQueue); +} + +- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field { + if (value) { + self.HTTPHeaders[field] = value; + } + else { + [self.HTTPHeaders removeObjectForKey:field]; + } +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + return self.HTTPHeaders[field]; +} + +- (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads { + _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads; +} + +- (NSUInteger)currentDownloadCount { + return _downloadQueue.operationCount; +} + +- (NSInteger)maxConcurrentDownloads { + return _downloadQueue.maxConcurrentOperationCount; +} + +- (void)setOperationClass:(Class)operationClass { + _operationClass = operationClass ?: [SDWebImageDownloaderOperation class]; +} + +- (id )downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock { + __block SDWebImageDownloaderOperation *operation; + __weak __typeof(self)wself = self; + + [self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^{ + NSTimeInterval timeoutInterval = wself.downloadTimeout; + if (timeoutInterval == 0.0) { + timeoutInterval = 15.0; + } + + // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval]; + request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies); + request.HTTPShouldUsePipelining = YES; + if (wself.headersFilter) { + request.allHTTPHeaderFields = wself.headersFilter(url, [wself.HTTPHeaders copy]); + } + else { + request.allHTTPHeaderFields = wself.HTTPHeaders; + } + operation = [[wself.operationClass alloc] initWithRequest:request + options:options + progress:^(NSInteger receivedSize, NSInteger expectedSize) { + SDWebImageDownloader *sself = wself; + if (!sself) return; + __block NSArray *callbacksForURL; + dispatch_sync(sself.barrierQueue, ^{ + callbacksForURL = [sself.URLCallbacks[url] copy]; + }); + for (NSDictionary *callbacks in callbacksForURL) { + SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey]; + if (callback) callback(receivedSize, expectedSize); + } + } + completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { + SDWebImageDownloader *sself = wself; + if (!sself) return; + __block NSArray *callbacksForURL; + dispatch_barrier_sync(sself.barrierQueue, ^{ + callbacksForURL = [sself.URLCallbacks[url] copy]; + if (finished) { + [sself.URLCallbacks removeObjectForKey:url]; + } + }); + for (NSDictionary *callbacks in callbacksForURL) { + SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey]; + if (callback) callback(image, data, error, finished); + } + } + cancelled:^{ + SDWebImageDownloader *sself = wself; + if (!sself) return; + dispatch_barrier_async(sself.barrierQueue, ^{ + [sself.URLCallbacks removeObjectForKey:url]; + }); + }]; + operation.shouldDecompressImages = wself.shouldDecompressImages; + + if (wself.username && wself.password) { + operation.credential = [NSURLCredential credentialWithUser:wself.username password:wself.password persistence:NSURLCredentialPersistenceForSession]; + } + + if (options & SDWebImageDownloaderHighPriority) { + operation.queuePriority = NSOperationQueuePriorityHigh; + } else if (options & SDWebImageDownloaderLowPriority) { + operation.queuePriority = NSOperationQueuePriorityLow; + } + + [wself.downloadQueue addOperation:operation]; + if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { + // Emulate LIFO execution order by systematically adding new operations as last operation's dependency + [wself.lastAddedOperation addDependency:operation]; + wself.lastAddedOperation = operation; + } + }]; + + return operation; +} + +- (void)addProgressCallback:(SDWebImageDownloaderProgressBlock)progressBlock andCompletedBlock:(SDWebImageDownloaderCompletedBlock)completedBlock forURL:(NSURL *)url createCallback:(SDWebImageNoParamsBlock)createCallback { + // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data. + if (url == nil) { + if (completedBlock != nil) { + completedBlock(nil, nil, nil, NO); + } + return; + } + + dispatch_barrier_sync(self.barrierQueue, ^{ + BOOL first = NO; + if (!self.URLCallbacks[url]) { + self.URLCallbacks[url] = [NSMutableArray new]; + first = YES; + } + + // Handle single download of simultaneous download request for the same URL + NSMutableArray *callbacksForURL = self.URLCallbacks[url]; + NSMutableDictionary *callbacks = [NSMutableDictionary new]; + if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy]; + if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy]; + [callbacksForURL addObject:callbacks]; + self.URLCallbacks[url] = callbacksForURL; + + if (first) { + createCallback(); + } + }); +} + +- (void)setSuspended:(BOOL)suspended { + [self.downloadQueue setSuspended:suspended]; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h new file mode 100644 index 0000000..dd48b22 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.h @@ -0,0 +1,78 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageDownloader.h" +#import "SDWebImageOperation.h" + +extern NSString *const SDWebImageDownloadStartNotification; +extern NSString *const SDWebImageDownloadReceiveResponseNotification; +extern NSString *const SDWebImageDownloadStopNotification; +extern NSString *const SDWebImageDownloadFinishNotification; + +@interface SDWebImageDownloaderOperation : NSOperation + +/** + * The request used by the operation's connection. + */ +@property (strong, nonatomic, readonly) NSURLRequest *request; + + +@property (assign, nonatomic) BOOL shouldDecompressImages; + +/** + * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. + * + * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. + * + * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + */ +@property (nonatomic, strong) NSURLCredential *credential; + +/** + * The SDWebImageDownloaderOptions for the receiver. + */ +@property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; + +/** + * The expected size of data. + */ +@property (assign, nonatomic) NSInteger expectedSize; + +/** + * The response returned by the operation's connection. + */ +@property (strong, nonatomic) NSURLResponse *response; + +/** + * Initializes a `SDWebImageDownloaderOperation` object + * + * @see SDWebImageDownloaderOperation + * + * @param request the URL request + * @param options downloader options + * @param progressBlock the block executed when a new chunk of data arrives. + * @note the progress block is executed on a background queue + * @param completedBlock the block executed when the download is done. + * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue + * @param cancelBlock the block executed if the download (operation) is cancelled + * + * @return the initialized instance + */ +- (id)initWithRequest:(NSURLRequest *)request + options:(SDWebImageDownloaderOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageDownloaderCompletedBlock)completedBlock + cancelled:(SDWebImageNoParamsBlock)cancelBlock; + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m new file mode 100644 index 0000000..5a8bd11 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageDownloaderOperation.m @@ -0,0 +1,466 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageDownloaderOperation.h" +#import "SDWebImageDecoder.h" +#import "UIImage+MultiFormat.h" +#import +#import "SDWebImageManager.h" + +NSString *const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification"; +NSString *const SDWebImageDownloadReceiveResponseNotification = @"SDWebImageDownloadReceiveResponseNotification"; +NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification"; +NSString *const SDWebImageDownloadFinishNotification = @"SDWebImageDownloadFinishNotification"; + +@interface SDWebImageDownloaderOperation () + +@property (copy, nonatomic) SDWebImageDownloaderProgressBlock progressBlock; +@property (copy, nonatomic) SDWebImageDownloaderCompletedBlock completedBlock; +@property (copy, nonatomic) SDWebImageNoParamsBlock cancelBlock; + +@property (assign, nonatomic, getter = isExecuting) BOOL executing; +@property (assign, nonatomic, getter = isFinished) BOOL finished; +@property (strong, nonatomic) NSMutableData *imageData; +@property (strong, nonatomic) NSURLConnection *connection; +@property (strong, atomic) NSThread *thread; + +#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 +@property (assign, nonatomic) UIBackgroundTaskIdentifier backgroundTaskId; +#endif + +@end + +@implementation SDWebImageDownloaderOperation { + size_t width, height; + UIImageOrientation orientation; + BOOL responseFromCached; +} + +@synthesize executing = _executing; +@synthesize finished = _finished; + +- (id)initWithRequest:(NSURLRequest *)request + options:(SDWebImageDownloaderOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageDownloaderCompletedBlock)completedBlock + cancelled:(SDWebImageNoParamsBlock)cancelBlock { + if ((self = [super init])) { + _request = request; + _shouldDecompressImages = YES; + _shouldUseCredentialStorage = YES; + _options = options; + _progressBlock = [progressBlock copy]; + _completedBlock = [completedBlock copy]; + _cancelBlock = [cancelBlock copy]; + _executing = NO; + _finished = NO; + _expectedSize = 0; + responseFromCached = YES; // Initially wrong until `connection:willCacheResponse:` is called or not called + } + return self; +} + +- (void)start { + @synchronized (self) { + if (self.isCancelled) { + self.finished = YES; + [self reset]; + return; + } + +#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + Class UIApplicationClass = NSClassFromString(@"UIApplication"); + BOOL hasApplication = UIApplicationClass && [UIApplicationClass respondsToSelector:@selector(sharedApplication)]; + if (hasApplication && [self shouldContinueWhenAppEntersBackground]) { + __weak __typeof__ (self) wself = self; + UIApplication * app = [UIApplicationClass performSelector:@selector(sharedApplication)]; + self.backgroundTaskId = [app beginBackgroundTaskWithExpirationHandler:^{ + __strong __typeof (wself) sself = wself; + + if (sself) { + [sself cancel]; + + [app endBackgroundTask:sself.backgroundTaskId]; + sself.backgroundTaskId = UIBackgroundTaskInvalid; + } + }]; + } +#endif + + self.executing = YES; + self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; + self.thread = [NSThread currentThread]; + } + + [self.connection start]; + + if (self.connection) { + if (self.progressBlock) { + self.progressBlock(0, NSURLResponseUnknownLength); + } + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; + }); + + if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_5_1) { + // Make sure to run the runloop in our background thread so it can process downloaded data + // Note: we use a timeout to work around an issue with NSURLConnection cancel under iOS 5 + // not waking up the runloop, leading to dead threads (see https://github.com/rs/SDWebImage/issues/466) + CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, false); + } + else { + CFRunLoopRun(); + } + + if (!self.isFinished) { + [self.connection cancel]; + [self connection:self.connection didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorTimedOut userInfo:@{NSURLErrorFailingURLErrorKey : self.request.URL}]]; + } + } + else { + if (self.completedBlock) { + self.completedBlock(nil, nil, [NSError errorWithDomain:NSURLErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Connection can't be initialized"}], YES); + } + } + +#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + Class UIApplicationClass = NSClassFromString(@"UIApplication"); + if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) { + return; + } + if (self.backgroundTaskId != UIBackgroundTaskInvalid) { + UIApplication * app = [UIApplication performSelector:@selector(sharedApplication)]; + [app endBackgroundTask:self.backgroundTaskId]; + self.backgroundTaskId = UIBackgroundTaskInvalid; + } +#endif +} + +- (void)cancel { + @synchronized (self) { + if (self.thread) { + [self performSelector:@selector(cancelInternalAndStop) onThread:self.thread withObject:nil waitUntilDone:NO]; + } + else { + [self cancelInternal]; + } + } +} + +- (void)cancelInternalAndStop { + if (self.isFinished) return; + [self cancelInternal]; + CFRunLoopStop(CFRunLoopGetCurrent()); +} + +- (void)cancelInternal { + if (self.isFinished) return; + [super cancel]; + if (self.cancelBlock) self.cancelBlock(); + + if (self.connection) { + [self.connection cancel]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + }); + + // As we cancelled the connection, its callback won't be called and thus won't + // maintain the isFinished and isExecuting flags. + if (self.isExecuting) self.executing = NO; + if (!self.isFinished) self.finished = YES; + } + + [self reset]; +} + +- (void)done { + self.finished = YES; + self.executing = NO; + [self reset]; +} + +- (void)reset { + self.cancelBlock = nil; + self.completedBlock = nil; + self.progressBlock = nil; + self.connection = nil; + self.imageData = nil; + self.thread = nil; +} + +- (void)setFinished:(BOOL)finished { + [self willChangeValueForKey:@"isFinished"]; + _finished = finished; + [self didChangeValueForKey:@"isFinished"]; +} + +- (void)setExecuting:(BOOL)executing { + [self willChangeValueForKey:@"isExecuting"]; + _executing = executing; + [self didChangeValueForKey:@"isExecuting"]; +} + +- (BOOL)isConcurrent { + return YES; +} + +#pragma mark NSURLConnection (delegate) + +- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { + + //'304 Not Modified' is an exceptional one + if (![response respondsToSelector:@selector(statusCode)] || ([((NSHTTPURLResponse *)response) statusCode] < 400 && [((NSHTTPURLResponse *)response) statusCode] != 304)) { + NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0; + self.expectedSize = expected; + if (self.progressBlock) { + self.progressBlock(0, expected); + } + + self.imageData = [[NSMutableData alloc] initWithCapacity:expected]; + self.response = response; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadReceiveResponseNotification object:self]; + }); + } + else { + NSUInteger code = [((NSHTTPURLResponse *)response) statusCode]; + + //This is the case when server returns '304 Not Modified'. It means that remote image is not changed. + //In case of 304 we need just cancel the operation and return cached image from the cache. + if (code == 304) { + [self cancelInternal]; + } else { + [self.connection cancel]; + } + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + }); + + if (self.completedBlock) { + self.completedBlock(nil, nil, [NSError errorWithDomain:NSURLErrorDomain code:[((NSHTTPURLResponse *)response) statusCode] userInfo:nil], YES); + } + CFRunLoopStop(CFRunLoopGetCurrent()); + [self done]; + } +} + +- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { + [self.imageData appendData:data]; + + if ((self.options & SDWebImageDownloaderProgressiveDownload) && self.expectedSize > 0 && self.completedBlock) { + // The following code is from http://www.cocoaintheshell.com/2011/05/progressive-images-download-imageio/ + // Thanks to the author @Nyx0uf + + // Get the total bytes downloaded + const NSInteger totalSize = self.imageData.length; + + // Update the data source, we must pass ALL the data, not just the new bytes + CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)self.imageData, NULL); + + if (width + height == 0) { + CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); + if (properties) { + NSInteger orientationValue = -1; + CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight); + if (val) CFNumberGetValue(val, kCFNumberLongType, &height); + val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth); + if (val) CFNumberGetValue(val, kCFNumberLongType, &width); + val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); + if (val) CFNumberGetValue(val, kCFNumberNSIntegerType, &orientationValue); + CFRelease(properties); + + // When we draw to Core Graphics, we lose orientation information, + // which means the image below born of initWithCGIImage will be + // oriented incorrectly sometimes. (Unlike the image born of initWithData + // in connectionDidFinishLoading.) So save it here and pass it on later. + orientation = [[self class] orientationFromPropertyValue:(orientationValue == -1 ? 1 : orientationValue)]; + } + + } + + if (width + height > 0 && totalSize < self.expectedSize) { + // Create the image + CGImageRef partialImageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL); + +#ifdef TARGET_OS_IPHONE + // Workaround for iOS anamorphic image + if (partialImageRef) { + const size_t partialHeight = CGImageGetHeight(partialImageRef); + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGContextRef bmContext = CGBitmapContextCreate(NULL, width, height, 8, width * 4, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); + CGColorSpaceRelease(colorSpace); + if (bmContext) { + CGContextDrawImage(bmContext, (CGRect){.origin.x = 0.0f, .origin.y = 0.0f, .size.width = width, .size.height = partialHeight}, partialImageRef); + CGImageRelease(partialImageRef); + partialImageRef = CGBitmapContextCreateImage(bmContext); + CGContextRelease(bmContext); + } + else { + CGImageRelease(partialImageRef); + partialImageRef = nil; + } + } +#endif + + if (partialImageRef) { + UIImage *image = [UIImage imageWithCGImage:partialImageRef scale:1 orientation:orientation]; + NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; + UIImage *scaledImage = [self scaledImageForKey:key image:image]; + if (self.shouldDecompressImages) { + image = [UIImage decodedImageWithImage:scaledImage]; + } + else { + image = scaledImage; + } + CGImageRelease(partialImageRef); + dispatch_main_sync_safe(^{ + if (self.completedBlock) { + self.completedBlock(image, nil, nil, NO); + } + }); + } + } + + CFRelease(imageSource); + } + + if (self.progressBlock) { + self.progressBlock(self.imageData.length, self.expectedSize); + } +} + ++ (UIImageOrientation)orientationFromPropertyValue:(NSInteger)value { + switch (value) { + case 1: + return UIImageOrientationUp; + case 3: + return UIImageOrientationDown; + case 8: + return UIImageOrientationLeft; + case 6: + return UIImageOrientationRight; + case 2: + return UIImageOrientationUpMirrored; + case 4: + return UIImageOrientationDownMirrored; + case 5: + return UIImageOrientationLeftMirrored; + case 7: + return UIImageOrientationRightMirrored; + default: + return UIImageOrientationUp; + } +} + +- (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image { + return SDScaledImageForKey(key, image); +} + +- (void)connectionDidFinishLoading:(NSURLConnection *)aConnection { + SDWebImageDownloaderCompletedBlock completionBlock = self.completedBlock; + @synchronized(self) { + CFRunLoopStop(CFRunLoopGetCurrent()); + self.thread = nil; + self.connection = nil; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadFinishNotification object:self]; + }); + } + + if (![[NSURLCache sharedURLCache] cachedResponseForRequest:_request]) { + responseFromCached = NO; + } + + if (completionBlock) { + if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached) { + completionBlock(nil, nil, nil, YES); + } else if (self.imageData) { + UIImage *image = [UIImage sd_imageWithData:self.imageData]; + NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; + image = [self scaledImageForKey:key image:image]; + + // Do not force decoding animated GIFs + if (!image.images) { + if (self.shouldDecompressImages) { + image = [UIImage decodedImageWithImage:image]; + } + } + if (CGSizeEqualToSize(image.size, CGSizeZero)) { + completionBlock(nil, nil, [NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}], YES); + } + else { + completionBlock(image, self.imageData, nil, YES); + } + } else { + completionBlock(nil, nil, [NSError errorWithDomain:SDWebImageErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Image data is nil"}], YES); + } + } + self.completionBlock = nil; + [self done]; +} + +- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { + @synchronized(self) { + CFRunLoopStop(CFRunLoopGetCurrent()); + self.thread = nil; + self.connection = nil; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; + }); + } + + if (self.completedBlock) { + self.completedBlock(nil, nil, error, YES); + } + self.completionBlock = nil; + [self done]; +} + +- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse { + responseFromCached = NO; // If this method is called, it means the response wasn't read from cache + if (self.request.cachePolicy == NSURLRequestReloadIgnoringLocalCacheData) { + // Prevents caching of responses + return nil; + } + else { + return cachedResponse; + } +} + +- (BOOL)shouldContinueWhenAppEntersBackground { + return self.options & SDWebImageDownloaderContinueInBackground; +} + +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + +- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{ + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if (!(self.options & SDWebImageDownloaderAllowInvalidSSLCertificates) && + [challenge.sender respondsToSelector:@selector(performDefaultHandlingForAuthenticationChallenge:)]) { + [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge]; + } else { + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } + } else { + if ([challenge previousFailureCount] == 0) { + if (self.credential) { + [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageManager.h b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageManager.h new file mode 100644 index 0000000..7f80e24 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageManager.h @@ -0,0 +1,299 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDWebImageOperation.h" +#import "SDWebImageDownloader.h" +#import "SDImageCache.h" + +typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { + /** + * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. + * This flag disable this blacklisting. + */ + SDWebImageRetryFailed = 1 << 0, + + /** + * By default, image downloads are started during UI interactions, this flags disable this feature, + * leading to delayed download on UIScrollView deceleration for instance. + */ + SDWebImageLowPriority = 1 << 1, + + /** + * This flag disables on-disk caching + */ + SDWebImageCacheMemoryOnly = 1 << 2, + + /** + * This flag enables progressive download, the image is displayed progressively during download as a browser would do. + * By default, the image is only displayed once completely downloaded. + */ + SDWebImageProgressiveDownload = 1 << 3, + + /** + * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. + * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. + * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. + * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. + * + * Use this flag only if you can't make your URLs static with embeded cache busting parameter. + */ + SDWebImageRefreshCached = 1 << 4, + + /** + * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for + * extra time in background to let the request finish. If the background task expires the operation will be cancelled. + */ + SDWebImageContinueInBackground = 1 << 5, + + /** + * Handles cookies stored in NSHTTPCookieStore by setting + * NSMutableURLRequest.HTTPShouldHandleCookies = YES; + */ + SDWebImageHandleCookies = 1 << 6, + + /** + * Enable to allow untrusted SSL ceriticates. + * Useful for testing purposes. Use with caution in production. + */ + SDWebImageAllowInvalidSSLCertificates = 1 << 7, + + /** + * By default, image are loaded in the order they were queued. This flag move them to + * the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which + * could take a while). + */ + SDWebImageHighPriority = 1 << 8, + + /** + * By default, placeholder images are loaded while the image is loading. This flag will delay the loading + * of the placeholder image until after the image has finished loading. + */ + SDWebImageDelayPlaceholder = 1 << 9, + + /** + * We usually don't call transformDownloadedImage delegate method on animated images, + * as most transformation code would mangle it. + * Use this flag to transform them anyway. + */ + SDWebImageTransformAnimatedImage = 1 << 10, + + /** + * By default, image is added to the imageView after download. But in some cases, we want to + * have the hand before setting the image (apply a filter or add it with cross-fade animation for instance) + * Use this flag if you want to manually set the image in the completion when success + */ + SDWebImageAvoidAutoSetImage = 1 << 11 +}; + +typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL); + +typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL); + +typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url); + + +@class SDWebImageManager; + +@protocol SDWebImageManagerDelegate + +@optional + +/** + * Controls which image should be downloaded when the image is not found in the cache. + * + * @param imageManager The current `SDWebImageManager` + * @param imageURL The url of the image to be downloaded + * + * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied. + */ +- (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL; + +/** + * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory. + * NOTE: This method is called from a global queue in order to not to block the main thread. + * + * @param imageManager The current `SDWebImageManager` + * @param image The image to transform + * @param imageURL The url of the image to transform + * + * @return The transformed image object. + */ +- (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL; + +@end + +/** + * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes. + * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache). + * You can use this class directly to benefit from web image downloading with caching in another context than + * a UIView. + * + * Here is a simple example of how to use SDWebImageManager: + * + * @code + +SDWebImageManager *manager = [SDWebImageManager sharedManager]; +[manager downloadImageWithURL:imageURL + options:0 + progress:nil + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (image) { + // do something with image + } + }]; + + * @endcode + */ +@interface SDWebImageManager : NSObject + +@property (weak, nonatomic) id delegate; + +@property (strong, nonatomic, readonly) SDImageCache *imageCache; +@property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader; + +/** + * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can + * be used to remove dynamic part of an image URL. + * + * The following example sets a filter in the application delegate that will remove any query-string from the + * URL before to use it as a cache key: + * + * @code + +[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) { + url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; + return [url absoluteString]; +}]; + + * @endcode + */ +@property (nonatomic, copy) SDWebImageCacheKeyFilterBlock cacheKeyFilter; + +/** + * Returns global SDWebImageManager instance. + * + * @return SDWebImageManager shared instance + */ ++ (SDWebImageManager *)sharedManager; + +/** + * Downloads the image at the given URL if not present in cache or return the cached version otherwise. + * + * @param url The URL to the image + * @param options A mask to specify options to use for this request + * @param progressBlock A block called while image is downloading + * @param completedBlock A block called when operation has been completed. + * + * This parameter is required. + * + * This block has no return value and takes the requested UIImage as first parameter. + * In case of error the image parameter is nil and the second parameter may contain an NSError. + * + * The third parameter is an `SDImageCacheType` enum indicating if the image was retrived from the local cache + * or from the memory cache or from the network. + * + * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is + * downloading. This block is thus called repetidly with a partial image. When image is fully downloaded, the + * block is called a last time with the full image and the last parameter set to YES. + * + * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation + */ +- (id )downloadImageWithURL:(NSURL *)url + options:(SDWebImageOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageCompletionWithFinishedBlock)completedBlock; + +/** + * Saves image to cache for given URL + * + * @param image The image to cache + * @param url The URL to the image + * + */ + +- (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url; + +/** + * Cancel all current opreations + */ +- (void)cancelAll; + +/** + * Check one or more operations running + */ +- (BOOL)isRunning; + +/** + * Check if image has already been cached + * + * @param url image url + * + * @return if the image was already cached + */ +- (BOOL)cachedImageExistsForURL:(NSURL *)url; + +/** + * Check if image has already been cached on disk only + * + * @param url image url + * + * @return if the image was already cached (disk only) + */ +- (BOOL)diskImageExistsForURL:(NSURL *)url; + +/** + * Async check if image has already been cached + * + * @param url image url + * @param completionBlock the block to be executed when the check is finished + * + * @note the completion block is always executed on the main queue + */ +- (void)cachedImageExistsForURL:(NSURL *)url + completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; + +/** + * Async check if image has already been cached on disk only + * + * @param url image url + * @param completionBlock the block to be executed when the check is finished + * + * @note the completion block is always executed on the main queue + */ +- (void)diskImageExistsForURL:(NSURL *)url + completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; + + +/** + *Return the cache key for a given URL + */ +- (NSString *)cacheKeyForURL:(NSURL *)url; + +@end + + +#pragma mark - Deprecated + +typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionBlock`"); +typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionWithFinishedBlock`"); + + +@interface SDWebImageManager (Deprecated) + +/** + * Downloads the image at the given URL if not present in cache or return the cached version otherwise. + * + * @deprecated This method has been deprecated. Use `downloadImageWithURL:options:progress:completed:` + */ +- (id )downloadWithURL:(NSURL *)url + options:(SDWebImageOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageCompletedWithFinishedBlock)completedBlock __deprecated_msg("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`"); + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageManager.m b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageManager.m new file mode 100644 index 0000000..3980ced --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageManager.m @@ -0,0 +1,354 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageManager.h" +#import + +@interface SDWebImageCombinedOperation : NSObject + +@property (assign, nonatomic, getter = isCancelled) BOOL cancelled; +@property (copy, nonatomic) SDWebImageNoParamsBlock cancelBlock; +@property (strong, nonatomic) NSOperation *cacheOperation; + +@end + +@interface SDWebImageManager () + +@property (strong, nonatomic, readwrite) SDImageCache *imageCache; +@property (strong, nonatomic, readwrite) SDWebImageDownloader *imageDownloader; +@property (strong, nonatomic) NSMutableSet *failedURLs; +@property (strong, nonatomic) NSMutableArray *runningOperations; + +@end + +@implementation SDWebImageManager + ++ (id)sharedManager { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (id)init { + if ((self = [super init])) { + _imageCache = [self createCache]; + _imageDownloader = [SDWebImageDownloader sharedDownloader]; + _failedURLs = [NSMutableSet new]; + _runningOperations = [NSMutableArray new]; + } + return self; +} + +- (SDImageCache *)createCache { + return [SDImageCache sharedImageCache]; +} + +- (NSString *)cacheKeyForURL:(NSURL *)url { + if (self.cacheKeyFilter) { + return self.cacheKeyFilter(url); + } + else { + return [url absoluteString]; + } +} + +- (BOOL)cachedImageExistsForURL:(NSURL *)url { + NSString *key = [self cacheKeyForURL:url]; + if ([self.imageCache imageFromMemoryCacheForKey:key] != nil) return YES; + return [self.imageCache diskImageExistsWithKey:key]; +} + +- (BOOL)diskImageExistsForURL:(NSURL *)url { + NSString *key = [self cacheKeyForURL:url]; + return [self.imageCache diskImageExistsWithKey:key]; +} + +- (void)cachedImageExistsForURL:(NSURL *)url + completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { + NSString *key = [self cacheKeyForURL:url]; + + BOOL isInMemoryCache = ([self.imageCache imageFromMemoryCacheForKey:key] != nil); + + if (isInMemoryCache) { + // making sure we call the completion block on the main queue + dispatch_async(dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(YES); + } + }); + return; + } + + [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { + // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch + if (completionBlock) { + completionBlock(isInDiskCache); + } + }]; +} + +- (void)diskImageExistsForURL:(NSURL *)url + completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { + NSString *key = [self cacheKeyForURL:url]; + + [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { + // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch + if (completionBlock) { + completionBlock(isInDiskCache); + } + }]; +} + +- (id )downloadImageWithURL:(NSURL *)url + options:(SDWebImageOptions)options + progress:(SDWebImageDownloaderProgressBlock)progressBlock + completed:(SDWebImageCompletionWithFinishedBlock)completedBlock { + // Invoking this method without a completedBlock is pointless + NSAssert(completedBlock != nil, @"If you mean to prefetch the image, use -[SDWebImagePrefetcher prefetchURLs] instead"); + + // Very common mistake is to send the URL using NSString object instead of NSURL. For some strange reason, XCode won't + // throw any warning for this type mismatch. Here we failsafe this error by allowing URLs to be passed as NSString. + if ([url isKindOfClass:NSString.class]) { + url = [NSURL URLWithString:(NSString *)url]; + } + + // Prevents app crashing on argument type error like sending NSNull instead of NSURL + if (![url isKindOfClass:NSURL.class]) { + url = nil; + } + + __block SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new]; + __weak SDWebImageCombinedOperation *weakOperation = operation; + + BOOL isFailedUrl = NO; + @synchronized (self.failedURLs) { + isFailedUrl = [self.failedURLs containsObject:url]; + } + + if (!url || (!(options & SDWebImageRetryFailed) && isFailedUrl)) { + dispatch_main_sync_safe(^{ + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]; + completedBlock(nil, error, SDImageCacheTypeNone, YES, url); + }); + return operation; + } + + @synchronized (self.runningOperations) { + [self.runningOperations addObject:operation]; + } + NSString *key = [self cacheKeyForURL:url]; + + operation.cacheOperation = [self.imageCache queryDiskCacheForKey:key done:^(UIImage *image, SDImageCacheType cacheType) { + if (operation.isCancelled) { + @synchronized (self.runningOperations) { + [self.runningOperations removeObject:operation]; + } + + return; + } + + if ((!image || options & SDWebImageRefreshCached) && (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url])) { + if (image && options & SDWebImageRefreshCached) { + dispatch_main_sync_safe(^{ + // If image was found in the cache bug SDWebImageRefreshCached is provided, notify about the cached image + // AND try to re-download it in order to let a chance to NSURLCache to refresh it from server. + completedBlock(image, nil, cacheType, YES, url); + }); + } + + // download if no image or requested to refresh anyway, and download allowed by delegate + SDWebImageDownloaderOptions downloaderOptions = 0; + if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority; + if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload; + if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache; + if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground; + if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies; + if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates; + if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority; + if (image && options & SDWebImageRefreshCached) { + // force progressive off if image already cached but forced refreshing + downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload; + // ignore image read from NSURLCache if image if cached but force refreshing + downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse; + } + id subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished) { + if (weakOperation.isCancelled) { + // Do nothing if the operation was cancelled + // See #699 for more details + // if we would call the completedBlock, there could be a race condition between this block and another completedBlock for the same object, so if this one is called second, we will overwrite the new data + } + else if (error) { + dispatch_main_sync_safe(^{ + if (!weakOperation.isCancelled) { + completedBlock(nil, error, SDImageCacheTypeNone, finished, url); + } + }); + + BOOL shouldBeFailedURLAlliOSVersion = (error.code != NSURLErrorNotConnectedToInternet && error.code != NSURLErrorCancelled && error.code != NSURLErrorTimedOut); + BOOL shouldBeFailedURLiOS7 = (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1 && error.code != NSURLErrorInternationalRoamingOff && error.code != NSURLErrorCallIsActive && error.code != NSURLErrorDataNotAllowed); + if (shouldBeFailedURLAlliOSVersion || shouldBeFailedURLiOS7) { + @synchronized (self.failedURLs) { + [self.failedURLs addObject:url]; + } + } + } + else { + if ((options & SDWebImageRetryFailed)) { + @synchronized (self.failedURLs) { + [self.failedURLs removeObject:url]; + } + } + + BOOL cacheOnDisk = !(options & SDWebImageCacheMemoryOnly); + + if (options & SDWebImageRefreshCached && image && !downloadedImage) { + // Image refresh hit the NSURLCache cache, do not call the completion block + } + else if (downloadedImage && (!downloadedImage.images || (options & SDWebImageTransformAnimatedImage)) && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)]) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ + UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url]; + + if (transformedImage && finished) { + BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage]; + [self.imageCache storeImage:transformedImage recalculateFromImage:imageWasTransformed imageData:(imageWasTransformed ? nil : data) forKey:key toDisk:cacheOnDisk]; + } + + dispatch_main_sync_safe(^{ + if (!weakOperation.isCancelled) { + completedBlock(transformedImage, nil, SDImageCacheTypeNone, finished, url); + } + }); + }); + } + else { + if (downloadedImage && finished) { + [self.imageCache storeImage:downloadedImage recalculateFromImage:NO imageData:data forKey:key toDisk:cacheOnDisk]; + } + + dispatch_main_sync_safe(^{ + if (!weakOperation.isCancelled) { + completedBlock(downloadedImage, nil, SDImageCacheTypeNone, finished, url); + } + }); + } + } + + if (finished) { + @synchronized (self.runningOperations) { + [self.runningOperations removeObject:operation]; + } + } + }]; + operation.cancelBlock = ^{ + [subOperation cancel]; + + @synchronized (self.runningOperations) { + [self.runningOperations removeObject:weakOperation]; + } + }; + } + else if (image) { + dispatch_main_sync_safe(^{ + if (!weakOperation.isCancelled) { + completedBlock(image, nil, cacheType, YES, url); + } + }); + @synchronized (self.runningOperations) { + [self.runningOperations removeObject:operation]; + } + } + else { + // Image not in cache and download disallowed by delegate + dispatch_main_sync_safe(^{ + if (!weakOperation.isCancelled) { + completedBlock(nil, nil, SDImageCacheTypeNone, YES, url); + } + }); + @synchronized (self.runningOperations) { + [self.runningOperations removeObject:operation]; + } + } + }]; + + return operation; +} + +- (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url { + if (image && url) { + NSString *key = [self cacheKeyForURL:url]; + [self.imageCache storeImage:image forKey:key toDisk:YES]; + } +} + +- (void)cancelAll { + @synchronized (self.runningOperations) { + NSArray *copiedOperations = [self.runningOperations copy]; + [copiedOperations makeObjectsPerformSelector:@selector(cancel)]; + [self.runningOperations removeObjectsInArray:copiedOperations]; + } +} + +- (BOOL)isRunning { + return self.runningOperations.count > 0; +} + +@end + + +@implementation SDWebImageCombinedOperation + +- (void)setCancelBlock:(SDWebImageNoParamsBlock)cancelBlock { + // check if the operation is already cancelled, then we just call the cancelBlock + if (self.isCancelled) { + if (cancelBlock) { + cancelBlock(); + } + _cancelBlock = nil; // don't forget to nil the cancelBlock, otherwise we will get crashes + } else { + _cancelBlock = [cancelBlock copy]; + } +} + +- (void)cancel { + self.cancelled = YES; + if (self.cacheOperation) { + [self.cacheOperation cancel]; + self.cacheOperation = nil; + } + if (self.cancelBlock) { + self.cancelBlock(); + + // TODO: this is a temporary fix to #809. + // Until we can figure the exact cause of the crash, going with the ivar instead of the setter +// self.cancelBlock = nil; + _cancelBlock = nil; + } +} + +@end + + +@implementation SDWebImageManager (Deprecated) + +// deprecated method, uses the non deprecated method +// adapter for the completion block +- (id )downloadWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedWithFinishedBlock)completedBlock { + return [self downloadImageWithURL:url + options:options + progress:progressBlock + completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType, finished); + } + }]; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h new file mode 100644 index 0000000..71094ee --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImageOperation.h @@ -0,0 +1,15 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import + +@protocol SDWebImageOperation + +- (void)cancel; + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h b/InControl/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h new file mode 100644 index 0000000..7bb67ac --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.h @@ -0,0 +1,103 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageManager.h" + +@class SDWebImagePrefetcher; + +@protocol SDWebImagePrefetcherDelegate + +@optional + +/** + * Called when an image was prefetched. + * + * @param imagePrefetcher The current image prefetcher + * @param imageURL The image url that was prefetched + * @param finishedCount The total number of images that were prefetched (successful or not) + * @param totalCount The total number of images that were to be prefetched + */ +- (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; + +/** + * Called when all images are prefetched. + * @param imagePrefetcher The current image prefetcher + * @param totalCount The total number of images that were prefetched (whether successful or not) + * @param skippedCount The total number of images that were skipped + */ +- (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; + +@end + +typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls); +typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls); + +/** + * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. + */ +@interface SDWebImagePrefetcher : NSObject + +/** + * The web image manager + */ +@property (strong, nonatomic, readonly) SDWebImageManager *manager; + +/** + * Maximum number of URLs to prefetch at the same time. Defaults to 3. + */ +@property (nonatomic, assign) NSUInteger maxConcurrentDownloads; + +/** + * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. + */ +@property (nonatomic, assign) SDWebImageOptions options; + +/** + * Queue options for Prefetcher. Defaults to Main Queue. + */ +@property (nonatomic, assign) dispatch_queue_t prefetcherQueue; + +@property (weak, nonatomic) id delegate; + +/** + * Return the global image prefetcher instance. + */ ++ (SDWebImagePrefetcher *)sharedImagePrefetcher; + +/** + * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, + * currently one image is downloaded at a time, + * and skips images for failed downloads and proceed to the next image in the list + * + * @param urls list of URLs to prefetch + */ +- (void)prefetchURLs:(NSArray *)urls; + +/** + * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, + * currently one image is downloaded at a time, + * and skips images for failed downloads and proceed to the next image in the list + * + * @param urls list of URLs to prefetch + * @param progressBlock block to be called when progress updates; + * first parameter is the number of completed (successful or not) requests, + * second parameter is the total number of images originally requested to be prefetched + * @param completionBlock block to be called when prefetching is completed + * first param is the number of completed (successful or not) requests, + * second parameter is the number of skipped requests + */ +- (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock; + +/** + * Remove and cancel queued list + */ +- (void)cancelPrefetching; + + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m b/InControl/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m new file mode 100644 index 0000000..8756bd0 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/SDWebImagePrefetcher.m @@ -0,0 +1,145 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImagePrefetcher.h" + +#if (!defined(DEBUG) && !defined (SD_VERBOSE)) || defined(SD_LOG_NONE) +#define NSLog(...) +#endif + +@interface SDWebImagePrefetcher () + +@property (strong, nonatomic) SDWebImageManager *manager; +@property (strong, nonatomic) NSArray *prefetchURLs; +@property (assign, nonatomic) NSUInteger requestedCount; +@property (assign, nonatomic) NSUInteger skippedCount; +@property (assign, nonatomic) NSUInteger finishedCount; +@property (assign, nonatomic) NSTimeInterval startedTime; +@property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock; +@property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock; + +@end + +@implementation SDWebImagePrefetcher + ++ (SDWebImagePrefetcher *)sharedImagePrefetcher { + static dispatch_once_t once; + static id instance; + dispatch_once(&once, ^{ + instance = [self new]; + }); + return instance; +} + +- (id)init { + if ((self = [super init])) { + _manager = [SDWebImageManager new]; + _options = SDWebImageLowPriority; + _prefetcherQueue = dispatch_get_main_queue(); + self.maxConcurrentDownloads = 3; + } + return self; +} + +- (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { + self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; +} + +- (NSUInteger)maxConcurrentDownloads { + return self.manager.imageDownloader.maxConcurrentDownloads; +} + +- (void)startPrefetchingAtIndex:(NSUInteger)index { + if (index >= self.prefetchURLs.count) return; + self.requestedCount++; + [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!finished) return; + self.finishedCount++; + + if (image) { + if (self.progressBlock) { + self.progressBlock(self.finishedCount,[self.prefetchURLs count]); + } + NSLog(@"Prefetched %@ out of %@", @(self.finishedCount), @(self.prefetchURLs.count)); + } + else { + if (self.progressBlock) { + self.progressBlock(self.finishedCount,[self.prefetchURLs count]); + } + NSLog(@"Prefetched %@ out of %@ (Failed)", @(self.finishedCount), @(self.prefetchURLs.count)); + + // Add last failed + self.skippedCount++; + } + if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { + [self.delegate imagePrefetcher:self + didPrefetchURL:self.prefetchURLs[index] + finishedCount:self.finishedCount + totalCount:self.prefetchURLs.count + ]; + } + if (self.prefetchURLs.count > self.requestedCount) { + dispatch_async(self.prefetcherQueue, ^{ + [self startPrefetchingAtIndex:self.requestedCount]; + }); + } + else if (self.finishedCount == self.requestedCount) { + [self reportStatus]; + if (self.completionBlock) { + self.completionBlock(self.finishedCount, self.skippedCount); + self.completionBlock = nil; + } + self.progressBlock = nil; + } + }]; +} + +- (void)reportStatus { + NSUInteger total = [self.prefetchURLs count]; + NSLog(@"Finished prefetching (%@ successful, %@ skipped, timeElasped %.2f)", @(total - self.skippedCount), @(self.skippedCount), CFAbsoluteTimeGetCurrent() - self.startedTime); + if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { + [self.delegate imagePrefetcher:self + didFinishWithTotalCount:(total - self.skippedCount) + skippedCount:self.skippedCount + ]; + } +} + +- (void)prefetchURLs:(NSArray *)urls { + [self prefetchURLs:urls progress:nil completed:nil]; +} + +- (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock { + [self cancelPrefetching]; // Prevent duplicate prefetch request + self.startedTime = CFAbsoluteTimeGetCurrent(); + self.prefetchURLs = urls; + self.completionBlock = completionBlock; + self.progressBlock = progressBlock; + + if(urls.count == 0){ + if(completionBlock){ + completionBlock(0,0); + } + }else{ + // Starts prefetching from the very first image on the list with the max allowed concurrency + NSUInteger listCount = self.prefetchURLs.count; + for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { + [self startPrefetchingAtIndex:i]; + } + } +} + +- (void)cancelPrefetching { + self.prefetchURLs = nil; + self.skippedCount = 0; + self.requestedCount = 0; + self.finishedCount = 0; + [self.manager cancelAll]; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h b/InControl/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h new file mode 100644 index 0000000..48ad0d5 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIButton+WebCache.h @@ -0,0 +1,229 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDWebImageManager.h" + +/** + * Integrates SDWebImage async downloading and caching of remote images with UIButtonView. + */ +@interface UIButton (WebCache) + +/** + * Get the current image URL. + */ +- (NSURL *)sd_currentImageURL; + +/** + * Get the image URL for a control state. + * + * @param state Which state you want to know the URL for. The values are described in UIControlState. + */ +- (NSURL *)sd_imageURLForState:(UIControlState)state; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state; + +/** + * Set the imageView `image` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @see sd_setImageWithURL:placeholderImage:options: + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the backgroundImageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state; + +/** + * Set the backgroundImageView `image` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @see sd_setImageWithURL:placeholderImage:options: + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; + +/** + * Set the backgroundImageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; + +/** + * Set the backgroundImageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the backgroundImageView `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param state The state that uses the specified title. The values are described in UIControlState. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the backgroundImageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Cancel the current image download + */ +- (void)sd_cancelImageLoadForState:(UIControlState)state; + +/** + * Cancel the current backgroundImage download + */ +- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state; + +@end + + +@interface UIButton (WebCacheDeprecated) + +- (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`"); +- (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`"); + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`"); +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`"); +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:`"); + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:completed:`"); +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:completed:`"); +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:completed:`"); + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:`"); +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:`"); +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:`"); + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:completed:`"); +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`"); +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:`"); + +- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelImageLoadForState:`"); +- (void)cancelBackgroundImageLoadForState:(UIControlState)state __deprecated_msg("Use `sd_cancelBackgroundImageLoadForState:`"); + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m b/InControl/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m new file mode 100644 index 0000000..33f7c29 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIButton+WebCache.m @@ -0,0 +1,260 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIButton+WebCache.h" +#import "objc/runtime.h" +#import "UIView+WebCacheOperation.h" + +static char imageURLStorageKey; + +@implementation UIButton (WebCache) + +- (NSURL *)sd_currentImageURL { + NSURL *url = self.imageURLStorage[@(self.state)]; + + if (!url) { + url = self.imageURLStorage[@(UIControlStateNormal)]; + } + + return url; +} + +- (NSURL *)sd_imageURLForState:(UIControlState)state { + return self.imageURLStorage[@(state)]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state { + [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { + + [self setImage:placeholder forState:state]; + [self sd_cancelImageLoadForState:state]; + + if (!url) { + [self.imageURLStorage removeObjectForKey:@(state)]; + + dispatch_main_async_safe(^{ + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; + if (completedBlock) { + completedBlock(nil, error, SDImageCacheTypeNone, url); + } + }); + + return; + } + + self.imageURLStorage[@(state)] = url; + + __weak __typeof(self)wself = self; + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe(^{ + __strong UIButton *sself = wself; + if (!sself) return; + if (image) { + [sself setImage:image forState:state]; + } + if (completedBlock && finished) { + completedBlock(image, error, cacheType, url); + } + }); + }]; + [self sd_setImageLoadOperation:operation forState:state]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; +} + +- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_cancelImageLoadForState:state]; + + [self setBackgroundImage:placeholder forState:state]; + + if (url) { + __weak __typeof(self)wself = self; + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe(^{ + __strong UIButton *sself = wself; + if (!sself) return; + if (image) { + [sself setBackgroundImage:image forState:state]; + } + if (completedBlock && finished) { + completedBlock(image, error, cacheType, url); + } + }); + }]; + [self sd_setBackgroundImageLoadOperation:operation forState:state]; + } else { + dispatch_main_async_safe(^{ + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; + if (completedBlock) { + completedBlock(nil, error, SDImageCacheTypeNone, url); + } + }); + } +} + +- (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state { + [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; +} + +- (void)sd_cancelImageLoadForState:(UIControlState)state { + [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; +} + +- (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state { + [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; +} + +- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state { + [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; +} + +- (NSMutableDictionary *)imageURLStorage { + NSMutableDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey); + if (!storage) + { + storage = [NSMutableDictionary dictionary]; + objc_setAssociatedObject(self, &imageURLStorageKey, storage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + + return storage; +} + +@end + + +@implementation UIButton (WebCacheDeprecated) + +- (NSURL *)currentImageURL { + return [self sd_currentImageURL]; +} + +- (NSURL *)imageURLForState:(UIControlState)state { + return [self sd_imageURLForState:state]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state { + [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)cancelCurrentImageLoad { + // in a backwards compatible manner, cancel for current state + [self sd_cancelImageLoadForState:self.state]; +} + +- (void)cancelBackgroundImageLoadForState:(UIControlState)state { + [self sd_cancelBackgroundImageLoadForState:state]; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIImage+GIF.h b/InControl/Pods/SDWebImage/SDWebImage/UIImage+GIF.h new file mode 100755 index 0000000..084f424 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIImage+GIF.h @@ -0,0 +1,19 @@ +// +// UIImage+GIF.h +// LBGIFImage +// +// Created by Laurin Brandner on 06.01.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import + +@interface UIImage (GIF) + ++ (UIImage *)sd_animatedGIFNamed:(NSString *)name; + ++ (UIImage *)sd_animatedGIFWithData:(NSData *)data; + +- (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIImage+GIF.m b/InControl/Pods/SDWebImage/SDWebImage/UIImage+GIF.m new file mode 100755 index 0000000..a703637 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIImage+GIF.m @@ -0,0 +1,158 @@ +// +// UIImage+GIF.m +// LBGIFImage +// +// Created by Laurin Brandner on 06.01.12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#import "UIImage+GIF.h" +#import + +@implementation UIImage (GIF) + ++ (UIImage *)sd_animatedGIFWithData:(NSData *)data { + if (!data) { + return nil; + } + + CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); + + size_t count = CGImageSourceGetCount(source); + + UIImage *animatedImage; + + if (count <= 1) { + animatedImage = [[UIImage alloc] initWithData:data]; + } + else { + NSMutableArray *images = [NSMutableArray array]; + + NSTimeInterval duration = 0.0f; + + for (size_t i = 0; i < count; i++) { + CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); + + duration += [self sd_frameDurationAtIndex:i source:source]; + + [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; + + CGImageRelease(image); + } + + if (!duration) { + duration = (1.0f / 10.0f) * count; + } + + animatedImage = [UIImage animatedImageWithImages:images duration:duration]; + } + + CFRelease(source); + + return animatedImage; +} + ++ (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { + float frameDuration = 0.1f; + CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); + NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; + NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; + + NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; + if (delayTimeUnclampedProp) { + frameDuration = [delayTimeUnclampedProp floatValue]; + } + else { + + NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; + if (delayTimeProp) { + frameDuration = [delayTimeProp floatValue]; + } + } + + // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. + // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify + // a duration of <= 10 ms. See and + // for more information. + + if (frameDuration < 0.011f) { + frameDuration = 0.100f; + } + + CFRelease(cfFrameProperties); + return frameDuration; +} + ++ (UIImage *)sd_animatedGIFNamed:(NSString *)name { + CGFloat scale = [UIScreen mainScreen].scale; + + if (scale > 1.0f) { + NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"]; + + NSData *data = [NSData dataWithContentsOfFile:retinaPath]; + + if (data) { + return [UIImage sd_animatedGIFWithData:data]; + } + + NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; + + data = [NSData dataWithContentsOfFile:path]; + + if (data) { + return [UIImage sd_animatedGIFWithData:data]; + } + + return [UIImage imageNamed:name]; + } + else { + NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; + + NSData *data = [NSData dataWithContentsOfFile:path]; + + if (data) { + return [UIImage sd_animatedGIFWithData:data]; + } + + return [UIImage imageNamed:name]; + } +} + +- (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size { + if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) { + return self; + } + + CGSize scaledSize = size; + CGPoint thumbnailPoint = CGPointZero; + + CGFloat widthFactor = size.width / self.size.width; + CGFloat heightFactor = size.height / self.size.height; + CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor; + scaledSize.width = self.size.width * scaleFactor; + scaledSize.height = self.size.height * scaleFactor; + + if (widthFactor > heightFactor) { + thumbnailPoint.y = (size.height - scaledSize.height) * 0.5; + } + else if (widthFactor < heightFactor) { + thumbnailPoint.x = (size.width - scaledSize.width) * 0.5; + } + + NSMutableArray *scaledImages = [NSMutableArray array]; + + UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); + + for (UIImage *image in self.images) { + [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)]; + UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); + + [scaledImages addObject:newImage]; + } + + UIGraphicsEndImageContext(); + + return [UIImage animatedImageWithImages:scaledImages duration:self.duration]; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h b/InControl/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h new file mode 100644 index 0000000..186ebc0 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.h @@ -0,0 +1,15 @@ +// +// UIImage+MultiFormat.h +// SDWebImage +// +// Created by Olivier Poitrey on 07/06/13. +// Copyright (c) 2013 Dailymotion. All rights reserved. +// + +#import + +@interface UIImage (MultiFormat) + ++ (UIImage *)sd_imageWithData:(NSData *)data; + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m b/InControl/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m new file mode 100644 index 0000000..a830754 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIImage+MultiFormat.m @@ -0,0 +1,118 @@ +// +// UIImage+MultiFormat.m +// SDWebImage +// +// Created by Olivier Poitrey on 07/06/13. +// Copyright (c) 2013 Dailymotion. All rights reserved. +// + +#import "UIImage+MultiFormat.h" +#import "UIImage+GIF.h" +#import "NSData+ImageContentType.h" +#import + +#ifdef SD_WEBP +#import "UIImage+WebP.h" +#endif + +@implementation UIImage (MultiFormat) + ++ (UIImage *)sd_imageWithData:(NSData *)data { + if (!data) { + return nil; + } + + UIImage *image; + NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; + if ([imageContentType isEqualToString:@"image/gif"]) { + image = [UIImage sd_animatedGIFWithData:data]; + } +#ifdef SD_WEBP + else if ([imageContentType isEqualToString:@"image/webp"]) + { + image = [UIImage sd_imageWithWebPData:data]; + } +#endif + else { + image = [[UIImage alloc] initWithData:data]; + UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; + if (orientation != UIImageOrientationUp) { + image = [UIImage imageWithCGImage:image.CGImage + scale:image.scale + orientation:orientation]; + } + } + + + return image; +} + + ++(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData { + UIImageOrientation result = UIImageOrientationUp; + CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); + if (imageSource) { + CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); + if (properties) { + CFTypeRef val; + int exifOrientation; + val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); + if (val) { + CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); + result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; + } // else - if it's not set it remains at up + CFRelease((CFTypeRef) properties); + } else { + //NSLog(@"NO PROPERTIES, FAIL"); + } + CFRelease(imageSource); + } + return result; +} + +#pragma mark EXIF orientation tag converter +// Convert an EXIF image orientation to an iOS one. +// reference see here: http://sylvana.net/jpegcrop/exif_orientation.html ++ (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { + UIImageOrientation orientation = UIImageOrientationUp; + switch (exifOrientation) { + case 1: + orientation = UIImageOrientationUp; + break; + + case 3: + orientation = UIImageOrientationDown; + break; + + case 8: + orientation = UIImageOrientationLeft; + break; + + case 6: + orientation = UIImageOrientationRight; + break; + + case 2: + orientation = UIImageOrientationUpMirrored; + break; + + case 4: + orientation = UIImageOrientationDownMirrored; + break; + + case 5: + orientation = UIImageOrientationLeftMirrored; + break; + + case 7: + orientation = UIImageOrientationRightMirrored; + break; + default: + break; + } + return orientation; +} + + + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h b/InControl/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h new file mode 100644 index 0000000..57f708f --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.h @@ -0,0 +1,100 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageCompat.h" +#import "SDWebImageManager.h" + +/** + * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. + */ +@interface UIImageView (HighlightedWebCache) + +/** + * Set the imageView `highlightedImage` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url; + +/** + * Set the imageView `highlightedImage` with an `url` and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options; + +/** + * Set the imageView `highlightedImage` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `highlightedImage` with an `url` and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `highlightedImage` with an `url` and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Cancel the current download + */ +- (void)sd_cancelCurrentHighlightedImageLoad; + +@end + + +@interface UIImageView (HighlightedWebCacheDeprecated) + +- (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`"); +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`"); +- (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`"); +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); + +- (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m b/InControl/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m new file mode 100644 index 0000000..eed798f --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIImageView+HighlightedWebCache.m @@ -0,0 +1,107 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIImageView+HighlightedWebCache.h" +#import "UIView+WebCacheOperation.h" + +#define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage" + +@implementation UIImageView (HighlightedWebCache) + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url { + [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; +} + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { + [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; +} + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; +} + +- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_cancelCurrentHighlightedImageLoad]; + + if (url) { + __weak __typeof(self)wself = self; + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe (^ + { + if (!wself) return; + if (image) { + wself.highlightedImage = image; + [wself setNeedsLayout]; + } + if (completedBlock && finished) { + completedBlock(image, error, cacheType, url); + } + }); + }]; + [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; + } else { + dispatch_main_async_safe(^{ + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; + if (completedBlock) { + completedBlock(nil, error, SDImageCacheTypeNone, url); + } + }); + } +} + +- (void)sd_cancelCurrentHighlightedImageLoad { + [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; +} + +@end + + +@implementation UIImageView (HighlightedWebCacheDeprecated) + +- (void)setHighlightedImageWithURL:(NSURL *)url { + [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; +} + +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { + [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; +} + +- (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)cancelCurrentHighlightedImageLoad { + [self sd_cancelCurrentHighlightedImageLoad]; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h b/InControl/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h new file mode 100644 index 0000000..e7489f4 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.h @@ -0,0 +1,201 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "SDWebImageCompat.h" +#import "SDWebImageManager.h" + +/** + * Integrates SDWebImage async downloading and caching of remote images with UIImageView. + * + * Usage with a UITableViewCell sub-class: + * + * @code + +#import + +... + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *MyIdentifier = @"MyIdentifier"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; + + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] + autorelease]; + } + + // Here we use the provided sd_setImageWithURL: method to load the web image + // Ensure you use a placeholder image otherwise cells will be initialized with no image + [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] + placeholderImage:[UIImage imageNamed:@"placeholder"]]; + + cell.textLabel.text = @"My Text"; + return cell; +} + + * @endcode + */ +@interface UIImageView (WebCache) + +/** + * Get the current image URL. + * + * Note that because of the limitations of categories this property can get out of sync + * if you use sd_setImage: directly. + */ +- (NSURL *)sd_imageURL; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + */ +- (void)sd_setImageWithURL:(NSURL *)url; + +/** + * Set the imageView `image` with an `url` and a placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @see sd_setImageWithURL:placeholderImage:options: + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; + +/** + * Set the imageView `image` with an `url`. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url`, placeholder and custom options. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Set the imageView `image` with an `url` and a optionaly placeholder image. + * + * The download is asynchronous and cached. + * + * @param url The url for the image. + * @param placeholder The image to be set initially, until the image request finishes. + * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. + * @param progressBlock A block called while image is downloading + * @param completedBlock A block called when operation has been completed. This block has no return value + * and takes the requested UIImage as first parameter. In case of error the image parameter + * is nil and the second parameter may contain an NSError. The third parameter is a Boolean + * indicating if the image was retrived from the local cache or from the network. + * The fourth parameter is the original image url. + */ +- (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; + +/** + * Download an array of images and starts them in an animation loop + * + * @param arrayOfURLs An array of NSURL + */ +- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; + +/** + * Cancel the current download + */ +- (void)sd_cancelCurrentImageLoad; + +- (void)sd_cancelCurrentAnimationImagesLoad; + +@end + + +@interface UIImageView (WebCacheDeprecated) + +- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); + +- (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`"); + +- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`"); + +- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`"); + +- (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`"); + +- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m b/InControl/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m new file mode 100644 index 0000000..162c49a --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIImageView+WebCache.m @@ -0,0 +1,202 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIImageView+WebCache.h" +#import "objc/runtime.h" +#import "UIView+WebCacheOperation.h" + +static char imageURLKey; + +@implementation UIImageView (WebCache) + +- (void)sd_setImageWithURL:(NSURL *)url { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; +} + +- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { + [self sd_cancelCurrentImageLoad]; + objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + + if (!(options & SDWebImageDelayPlaceholder)) { + dispatch_main_async_safe(^{ + self.image = placeholder; + }); + } + + if (url) { + __weak __typeof(self)wself = self; + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe(^{ + if (!wself) return; + if (image && (options & SDWebImageAvoidAutoSetImage) && completedBlock) + { + completedBlock(image, error, cacheType, url); + return; + } + else if (image) { + wself.image = image; + [wself setNeedsLayout]; + } else { + if ((options & SDWebImageDelayPlaceholder)) { + wself.image = placeholder; + [wself setNeedsLayout]; + } + } + if (completedBlock && finished) { + completedBlock(image, error, cacheType, url); + } + }); + }]; + [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; + } else { + dispatch_main_async_safe(^{ + NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; + if (completedBlock) { + completedBlock(nil, error, SDImageCacheTypeNone, url); + } + }); + } +} + +- (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { + NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url]; + UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key]; + + [self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock]; +} + +- (NSURL *)sd_imageURL { + return objc_getAssociatedObject(self, &imageURLKey); +} + +- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { + [self sd_cancelCurrentAnimationImagesLoad]; + __weak __typeof(self)wself = self; + + NSMutableArray *operationsArray = [[NSMutableArray alloc] init]; + + for (NSURL *logoImageURL in arrayOfURLs) { + id operation = [SDWebImageManager.sharedManager downloadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { + if (!wself) return; + dispatch_main_sync_safe(^{ + __strong UIImageView *sself = wself; + [sself stopAnimating]; + if (sself && image) { + NSMutableArray *currentImages = [[sself animationImages] mutableCopy]; + if (!currentImages) { + currentImages = [[NSMutableArray alloc] init]; + } + [currentImages addObject:image]; + + sself.animationImages = currentImages; + [sself setNeedsLayout]; + } + [sself startAnimating]; + }); + }]; + [operationsArray addObject:operation]; + } + + [self sd_setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"]; +} + +- (void)sd_cancelCurrentImageLoad { + [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"]; +} + +- (void)sd_cancelCurrentAnimationImagesLoad { + [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; +} + +@end + + +@implementation UIImageView (WebCacheDeprecated) + +- (NSURL *)imageURL { + return [self sd_imageURL]; +} + +- (void)setImageWithURL:(NSURL *)url { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; +} + +- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { + [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { + if (completedBlock) { + completedBlock(image, error, cacheType); + } + }]; +} + +- (void)cancelCurrentArrayLoad { + [self sd_cancelCurrentAnimationImagesLoad]; +} + +- (void)cancelCurrentImageLoad { + [self sd_cancelCurrentImageLoad]; +} + +- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { + [self sd_setAnimationImagesWithURLs:arrayOfURLs]; +} + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h b/InControl/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h new file mode 100644 index 0000000..6719036 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.h @@ -0,0 +1,36 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import +#import "SDWebImageManager.h" + +@interface UIView (WebCacheOperation) + +/** + * Set the image load operation (storage in a UIView based dictionary) + * + * @param operation the operation + * @param key key for storing the operation + */ +- (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; + +/** + * Cancel all operations for the current UIView and key + * + * @param key key for identifying the operations + */ +- (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; + +/** + * Just remove the operations corresponding to the current UIView and key without cancelling them + * + * @param key key for identifying the operations + */ +- (void)sd_removeImageLoadOperationWithKey:(NSString *)key; + +@end diff --git a/InControl/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m b/InControl/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m new file mode 100644 index 0000000..9219478 --- /dev/null +++ b/InControl/Pods/SDWebImage/SDWebImage/UIView+WebCacheOperation.m @@ -0,0 +1,55 @@ +/* + * This file is part of the SDWebImage package. + * (c) Olivier Poitrey + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +#import "UIView+WebCacheOperation.h" +#import "objc/runtime.h" + +static char loadOperationKey; + +@implementation UIView (WebCacheOperation) + +- (NSMutableDictionary *)operationDictionary { + NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); + if (operations) { + return operations; + } + operations = [NSMutableDictionary dictionary]; + objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + return operations; +} + +- (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { + [self sd_cancelImageLoadOperationWithKey:key]; + NSMutableDictionary *operationDictionary = [self operationDictionary]; + [operationDictionary setObject:operation forKey:key]; +} + +- (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { + // Cancel in progress downloader from queue + NSMutableDictionary *operationDictionary = [self operationDictionary]; + id operations = [operationDictionary objectForKey:key]; + if (operations) { + if ([operations isKindOfClass:[NSArray class]]) { + for (id operation in operations) { + if (operation) { + [operation cancel]; + } + } + } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ + [(id) operations cancel]; + } + [operationDictionary removeObjectForKey:key]; + } +} + +- (void)sd_removeImageLoadOperationWithKey:(NSString *)key { + NSMutableDictionary *operationDictionary = [self operationDictionary]; + [operationDictionary removeObjectForKey:key]; +} + +@end diff --git a/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-Private.xcconfig b/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-Private.xcconfig new file mode 100644 index 0000000..223387c --- /dev/null +++ b/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-Private.xcconfig @@ -0,0 +1,6 @@ +#include "AFNetworking.xcconfig" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/XCDYouTubeKit" +OTHER_LDFLAGS = ${AFNETWORKING_OTHER_LDFLAGS} +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m b/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m new file mode 100644 index 0000000..6a29cf8 --- /dev/null +++ b/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_AFNetworking : NSObject +@end +@implementation PodsDummy_AFNetworking +@end diff --git a/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch b/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch new file mode 100644 index 0000000..1e116a3 --- /dev/null +++ b/InControl/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch @@ -0,0 +1,11 @@ +#ifdef __OBJC__ +#import +#endif + +#ifndef TARGET_OS_IOS + #define TARGET_OS_IOS TARGET_OS_IPHONE +#endif + +#ifndef TARGET_OS_WATCH + #define TARGET_OS_WATCH 0 +#endif diff --git a/InControl/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig b/InControl/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig new file mode 100644 index 0000000..b0b2d52 --- /dev/null +++ b/InControl/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig @@ -0,0 +1 @@ +AFNETWORKING_OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" \ No newline at end of file diff --git a/InControl/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown b/InControl/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown new file mode 100644 index 0000000..b507a27 --- /dev/null +++ b/InControl/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown @@ -0,0 +1,76 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## AFNetworking + +Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +## SDWebImage + +Copyright (c) 2009 Olivier Poitrey + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + +## XCDYouTubeKit + +The MIT License (MIT) + +Copyright (c) 2013-2015 Cédric Luthi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +Generated by CocoaPods - http://cocoapods.org diff --git a/InControl/Pods/Target Support Files/Pods/Pods-acknowledgements.plist b/InControl/Pods/Target Support Files/Pods/Pods-acknowledgements.plist new file mode 100644 index 0000000..eb9258d --- /dev/null +++ b/InControl/Pods/Target Support Files/Pods/Pods-acknowledgements.plist @@ -0,0 +1,114 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + Title + AFNetworking + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2009 Olivier Poitrey <rs@dailymotion.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + Title + SDWebImage + Type + PSGroupSpecifier + + + FooterText + The MIT License (MIT) + +Copyright (c) 2013-2015 Cédric Luthi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + Title + XCDYouTubeKit + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - http://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/InControl/Pods/Target Support Files/Pods/Pods-dummy.m b/InControl/Pods/Target Support Files/Pods/Pods-dummy.m new file mode 100644 index 0000000..ade64bd --- /dev/null +++ b/InControl/Pods/Target Support Files/Pods/Pods-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods : NSObject +@end +@implementation PodsDummy_Pods +@end diff --git a/InControl/Pods/Target Support Files/Pods/Pods-resources.sh b/InControl/Pods/Target Support Files/Pods/Pods-resources.sh new file mode 100755 index 0000000..ea685a2 --- /dev/null +++ b/InControl/Pods/Target Support Files/Pods/Pods-resources.sh @@ -0,0 +1,95 @@ +#!/bin/sh +set -e + +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +realpath() { + DIRECTORY="$(cd "${1%/*}" && pwd)" + FILENAME="${1##*/}" + echo "$DIRECTORY/$FILENAME" +} + +install_resource() +{ + case $1 in + *.storyboard) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" + ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" + ;; + *.xib) + echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" + ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" + ;; + *.framework) + echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" + xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" + xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" + xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + /*) + echo "$1" + echo "$1" >> "$RESOURCES_TO_COPY" + ;; + *) + echo "${PODS_ROOT}/$1" + echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" + ;; + esac +} + +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; + esac + + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "`realpath $PODS_ROOT`*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi diff --git a/InControl/Pods/Target Support Files/Pods/Pods.debug.xcconfig b/InControl/Pods/Target Support Files/Pods/Pods.debug.xcconfig new file mode 100644 index 0000000..b4cb953 --- /dev/null +++ b/InControl/Pods/Target Support Files/Pods/Pods.debug.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/XCDYouTubeKit" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage" -isystem "${PODS_ROOT}/Headers/Public/XCDYouTubeKit" +OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"SDWebImage" -l"XCDYouTubeKit" -framework "CoreGraphics" -framework "ImageIO" -framework "JavaScriptCore" -framework "MediaPlayer" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/InControl/Pods/Target Support Files/Pods/Pods.release.xcconfig b/InControl/Pods/Target Support Files/Pods/Pods.release.xcconfig new file mode 100644 index 0000000..b4cb953 --- /dev/null +++ b/InControl/Pods/Target Support Files/Pods/Pods.release.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/XCDYouTubeKit" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/SDWebImage" -isystem "${PODS_ROOT}/Headers/Public/XCDYouTubeKit" +OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"SDWebImage" -l"XCDYouTubeKit" -framework "CoreGraphics" -framework "ImageIO" -framework "JavaScriptCore" -framework "MediaPlayer" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-Private.xcconfig b/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-Private.xcconfig new file mode 100644 index 0000000..89c632d --- /dev/null +++ b/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-Private.xcconfig @@ -0,0 +1,6 @@ +#include "SDWebImage.xcconfig" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SDWebImage" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/XCDYouTubeKit" +OTHER_LDFLAGS = ${SDWEBIMAGE_OTHER_LDFLAGS} +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m b/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m new file mode 100644 index 0000000..86d2b5f --- /dev/null +++ b/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_SDWebImage : NSObject +@end +@implementation PodsDummy_SDWebImage +@end diff --git a/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch b/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/InControl/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/InControl/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig b/InControl/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig new file mode 100644 index 0000000..6ac563d --- /dev/null +++ b/InControl/Pods/Target Support Files/SDWebImage/SDWebImage.xcconfig @@ -0,0 +1 @@ +SDWEBIMAGE_OTHER_LDFLAGS = -framework "ImageIO" \ No newline at end of file diff --git a/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-Private.xcconfig b/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-Private.xcconfig new file mode 100644 index 0000000..1a6ec1e --- /dev/null +++ b/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-Private.xcconfig @@ -0,0 +1,6 @@ +#include "XCDYouTubeKit.xcconfig" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/XCDYouTubeKit" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/XCDYouTubeKit" +OTHER_LDFLAGS = ${XCDYOUTUBEKIT_OTHER_LDFLAGS} +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-dummy.m b/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-dummy.m new file mode 100644 index 0000000..2183349 --- /dev/null +++ b/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_XCDYouTubeKit : NSObject +@end +@implementation PodsDummy_XCDYouTubeKit +@end diff --git a/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-prefix.pch b/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit.xcconfig b/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit.xcconfig new file mode 100644 index 0000000..4d8900a --- /dev/null +++ b/InControl/Pods/Target Support Files/XCDYouTubeKit/XCDYouTubeKit.xcconfig @@ -0,0 +1 @@ +XCDYOUTUBEKIT_OTHER_LDFLAGS = -framework "JavaScriptCore" -framework "MediaPlayer" \ No newline at end of file diff --git a/InControl/Pods/XCDYouTubeKit/LICENSE b/InControl/Pods/XCDYouTubeKit/LICENSE new file mode 100644 index 0000000..37026f3 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2013-2015 Cédric Luthi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/InControl/Pods/XCDYouTubeKit/README.md b/InControl/Pods/XCDYouTubeKit/README.md new file mode 100644 index 0000000..f1917d9 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/README.md @@ -0,0 +1,129 @@ +## About + +[![Build Status](https://img.shields.io/travis/0xced/XCDYouTubeKit/master.svg?style=flat)](https://travis-ci.org/0xced/XCDYouTubeKit) +[![Coverage Status](https://img.shields.io/coveralls/0xced/XCDYouTubeKit/master.svg?style=flat)](https://coveralls.io/r/0xced/XCDYouTubeKit?branch=master) +[![Platform](https://img.shields.io/cocoapods/p/XCDYouTubeKit.svg?style=flat)](http://cocoadocs.org/docsets/XCDYouTubeKit/) +[![Pod Version](https://img.shields.io/cocoapods/v/XCDYouTubeKit.svg?style=flat)](https://cocoapods.org/pods/XCDYouTubeKit) +[![Carthage Compatibility](https://img.shields.io/badge/carthage-✓-f2a77e.svg?style=flat)](https://github.com/Carthage/Carthage/) +[![License](https://img.shields.io/cocoapods/l/XCDYouTubeKit.svg?style=flat)](LICENSE) + +**XCDYouTubeKit** is a YouTube video player for iOS and OS X. + + + +Are you enjoying XCDYouTubeKit? You can say thank you with [a tweet](https://twitter.com/intent/tweet?text=%400xced%20Thank%20you%20for%20XCDYouTubeKit%2E). I am also accepting donations. ;-) + +[![Donate button](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MGEPRSNQFMV3W) + +## Requirements + +- Runs on iOS 7.0 and later +- Runs on OS X 10.9 and later + +## Warning + +XCDYouTubeKit is against the YouTube [Terms of Service](https://www.youtube.com/t/terms). The only *official* way of playing a YouTube video inside an app is with a web view and the [iframe player API](https://developers.google.com/youtube/iframe_api_reference). Unfortunately, this is very slow and quite ugly, so I wrote this player to give users a better viewing experience. + +## Installation + +XCDYouTubeKit is available through CocoaPods and Carthage. + +CocoaPods: +```ruby +pod "XCDYouTubeKit", "~> 2.3.2" +``` + +Carthage: +```objc +github "0xced/XCDYouTubeKit" ~> 2.3.2 +``` + +Alternatively, you can manually use the provided static library on iOS or dynamic framework on OS X. In order to use the iOS static library, you must: + +1. Create a workspace (File → New → Workspace…) +2. Add your project to the workspace +3. Add the XCDYouTubeKit project to the workspace +4. Drag and drop the `libXCDYouTubeKit.a` file referenced from XCDYouTubeKit → Products → libXCDYouTubeKit.a into the *Link Binary With Libraries* build phase of your app’s target. + +These steps will ensure that `#import ` will work properly in your project. + +## Usage + +XCDYouTubeKit is [fully documented](http://cocoadocs.org/docsets/XCDYouTubeKit/). + +### iOS and OS X + +```objc +NSString *videoIdentifier = @"EdeVaT-zZt4"; // A 11 characters YouTube video identifier +[[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo *video, NSError *error) { + if (video) + { + // Do something with the `video` object + } + else + { + // Handle error + } +}]; +``` + +### iOS only + +On iOS, you can use the class `XCDYouTubeVideoPlayerViewController` the same way you use a `MPMoviePlayerViewController`, except you initialize it with a YouTube video identifier instead of a content URL. + +#### Present the video in full-screen + +```objc +XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"9bZkp7q19f0"]; +[self presentMoviePlayerViewControllerAnimated:videoPlayerViewController]; +``` + +#### Present the video in a non full-screen view + +```objc +XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:@"9bZkp7q19f0"]; +[videoPlayerViewController presentInView:self.videoContainerView]; +[videoPlayerViewController.moviePlayer play]; +``` + +See the demo project for more sample code. + +## Logging + +Since version 2.2.0, XCDYouTubeKit produces logs. XCDYouTubeKit supports [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack) but does not require it. If your project includes CocoaLumberjack, all logs will be routed through CocoaLumberjack, else logs will be emitted with `NSLog`. + +The context for identifying all XCDYouTubeKit logs in CocoaLumberjack is the number `(NSInteger)0xced70676`. Beware, CocoaLumberjack contexts are NSIntegers, don’t forget the cast. + +### Controlling log levels + +If you are using CocoaLumberjack, you are responsible for controlling the log levels with the CocoaLumberjack APIs. + +If you are not using CocoaLumberjack, you can control the log levels with the `XCDYouTubeKitLogLevel` environment variable. The log levels are the same as CocoaLumberjack, with the addition of the *trace* level. + +Level | Value +--------|------ +Error | 0x01 +Warning | 0x02 +Info | 0x04 +Debug | 0x08 +Verbose | 0x10 +Trace | 0x20 + +The levels are bitmasks, so you can combine them. For example, if you want to log *error*, *warning* and *info* levels, set the `XCDYouTubeKitLogLevel` environment variable to `0x7`. + +If you do not set the `XCDYouTubeKitLogLevel` environment variable, only warning and error levels are logged. + +## Credits + +The URL extraction algorithms in *XCDYouTubeKit* are inspired by the [YouTube extractor](https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py) module of the *youtube-dl* project. + +## Contact + +Cédric Luthi + +- http://github.com/0xced +- http://twitter.com/0xced + +## License + +XCDYouTubeKit is available under the MIT license. See the [LICENSE](LICENSE) file for more information. diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeClient.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeClient.h new file mode 100644 index 0000000..00e6715 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeClient.h @@ -0,0 +1,84 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#if !__has_feature(nullability) +#define NS_ASSUME_NONNULL_BEGIN +#define NS_ASSUME_NONNULL_END +#define nullable +#define __nullable +#endif + +#import + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * The `XCDYouTubeClient` class is responsible for interacting with the YouTube API. Given a YouTube video identifier, you will get video information with the `<-getVideoWithIdentifier:completionHandler:>` method. + * + * On iOS, you probably don’t want to use `XCDYouTubeClient` directly but the higher level class ``. + */ +@interface XCDYouTubeClient : NSObject + +/** + * ------------------ + * @name Initializing + * ------------------ + */ + +/** + * Returns the shared client with the default language, i.e. the preferred language of the main bundle. + * + * @return The default client. + */ ++ (instancetype) defaultClient; + +/** + * Initializes a client with the specified language identifier. + * + * @param languageIdentifier An [ISO 639-1 two-letter language code](http://www.loc.gov/standards/iso639-2/php/code_list.php) used for error localization. If you pass a nil language identifier, the preferred language of the main bundle will be used. + * + * @return A client with the specified language identifier. + */ +- (instancetype) initWithLanguageIdentifier:(nullable NSString *)languageIdentifier; + +/** + * --------------------------------- + * @name Accessing client properties + * --------------------------------- + */ + +/** + * The language identifier of the client, used for error localization. + * + * @see -initWithLanguageIdentifier: + */ +@property (nonatomic, readonly) NSString *languageIdentifier; + +/** + * -------------------------------------- + * @name Interacting with the YouTube API + * -------------------------------------- + */ + +/** + * Starts an asynchronous operation for the specified video identifier, and calls a handler upon completion. + * + * @param videoIdentifier A 11 characters YouTube video identifier. If the video identifier is invalid (including nil) the completion handler will be called with an error with `XCDYouTubeVideoErrorDomain` domain and `XCDYouTubeErrorInvalidVideoIdentifier` code. + * @param completionHandler A block to execute when the client finishes the operation. The completion handler is executed on the main thread. If the completion handler is nil, this method throws an exception. + * + * @discussion If the operation completes successfully, the video parameter of the handler block contains a `` object, and the error parameter is nil. If the operation fails, the video parameter is nil and the error parameter contains information about the failure. The error's domain is always `XCDYouTubeVideoErrorDomain`. + * + * @see XCDYouTubeErrorCode + * + * @return An opaque object conforming to the `` protocol for canceling the asynchronous video information operation. If you call the `cancel` method before the operation is finished, the completion handler will not be called. It is recommended that you store this opaque object as a weak property. + */ +- (id) getVideoWithIdentifier:(nullable NSString *)videoIdentifier completionHandler:(void (^)(XCDYouTubeVideo * __nullable video, NSError * __nullable error))completionHandler; + +@end + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeClient.m b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeClient.m new file mode 100644 index 0000000..0adf822 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeClient.m @@ -0,0 +1,77 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import "XCDYouTubeClient.h" + +#import "XCDYouTubeVideoOperation.h" + +@interface XCDYouTubeClient () +@property (nonatomic, strong) NSOperationQueue *queue; +@end + +@implementation XCDYouTubeClient + +@synthesize languageIdentifier = _languageIdentifier; + ++ (instancetype) defaultClient +{ + static XCDYouTubeClient *defaultClient; + static dispatch_once_t once; + dispatch_once(&once, ^{ + defaultClient = [self new]; + }); + return defaultClient; +} + +- (instancetype) init +{ + return [self initWithLanguageIdentifier:nil]; +} + +- (instancetype) initWithLanguageIdentifier:(NSString *)languageIdentifier +{ + if (!(self = [super init])) + return nil; + + _languageIdentifier = languageIdentifier; + _queue = [NSOperationQueue new]; + _queue.maxConcurrentOperationCount = 6; // paul_irish: Chrome re-confirmed that the 6 connections-per-host limit is the right magic number: https://code.google.com/p/chromium/issues/detail?id=285567#c14 [https://twitter.com/paul_irish/status/422808635698212864] + _queue.name = NSStringFromClass(self.class); + + return self; +} + +- (NSString *) languageIdentifier +{ + if (!_languageIdentifier) + { + _languageIdentifier = @"en"; + NSArray *preferredLocalizations = [[NSBundle mainBundle] preferredLocalizations]; + if (preferredLocalizations.count > 0) + _languageIdentifier = [NSLocale canonicalLanguageIdentifierFromString:preferredLocalizations[0]]; + } + return _languageIdentifier; +} + +- (id) getVideoWithIdentifier:(NSString *)videoIdentifier completionHandler:(void (^)(XCDYouTubeVideo * __nullable video, NSError * __nullable error))completionHandler +{ + if (!completionHandler) + @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"The `completionHandler` argument must not be nil." userInfo:nil]; + + XCDYouTubeVideoOperation *operation = [[XCDYouTubeVideoOperation alloc] initWithVideoIdentifier:videoIdentifier languageIdentifier:self.languageIdentifier]; + operation.completionBlock = ^{ + [[NSOperationQueue mainQueue] addOperationWithBlock:^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" + if (operation.video || operation.error) // If both `video` and `error` are nil, then the operation was cancelled + completionHandler(operation.video, operation.error); + operation.completionBlock = nil; +#pragma clang diagnostic pop + }]; + }; + [self.queue addOperation:operation]; + return operation; +} + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeError.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeError.h new file mode 100644 index 0000000..a427513 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeError.h @@ -0,0 +1,41 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import + +/** + * The error domain used throughout XCDYouTubeKit. + */ +extern NSString *const XCDYouTubeVideoErrorDomain; + +/** + * These values are returned as the error code property of an NSError object with the domain `XCDYouTubeVideoErrorDomain`. + */ +typedef NS_ENUM(NSInteger, XCDYouTubeErrorCode) { + /** + * Returned when no suitable video stream is available. + */ + XCDYouTubeErrorNoStreamAvailable = -2, + + /** + * Returned when a network error occurs. See `NSUnderlyingErrorKey` in the userInfo dictionary for more information. + */ + XCDYouTubeErrorNetwork = -1, + + /** + * Returned when the given video identifier string is invalid. + */ + XCDYouTubeErrorInvalidVideoIdentifier = 2, + + /** + * Previously returned when the video was removed as a violation of YouTube's policy or when the video did not exist. + * Now replaced by code 150, i.e. `XCDYouTubeErrorRestrictedPlayback`. + */ + XCDYouTubeErrorRemovedVideo DEPRECATED_MSG_ATTRIBUTE("YouTube has stopped using error code 100.") = 100, + + /** + * Returned when the video is not playable because of legal reasons or when the video is private. + */ + XCDYouTubeErrorRestrictedPlayback = 150 +}; diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeKit.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeKit.h new file mode 100644 index 0000000..abcdd51 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeKit.h @@ -0,0 +1,15 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import + +#import +#import +#import +#import +#import + +#if TARGET_OS_IPHONE +#import +#endif diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeLogger.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeLogger.h new file mode 100644 index 0000000..dbc9c1b --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeLogger.h @@ -0,0 +1,32 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import + +// From CocoaLumberjack's DDLog.h +typedef NS_OPTIONS(NSUInteger, DDLogFlag) { + DDLogFlagError = (1 << 0), // 0...00001 + DDLogFlagWarning = (1 << 1), // 0...00010 + DDLogFlagInfo = (1 << 2), // 0...00100 + DDLogFlagDebug = (1 << 3), // 0...01000 + DDLogFlagVerbose = (1 << 4), // 0...10000 + DDLogFlagTrace = (1 << 5) // 0..100000 (custom level not present in DDLog.h) +}; + +__attribute__((visibility("hidden"))) +@interface XCDYouTubeLogger : NSObject +// Compatible with CocoaLumberjack's DDLog interface ++ (void) log:(BOOL)asynchronous level:(NSUInteger)level flag:(DDLogFlag)flag context:(NSInteger)context file:(const char *)file function:(const char *)function line:(NSUInteger)line tag:(id)tag format:(NSString *)format, ... NS_FORMAT_FUNCTION(9,10); +@end + +extern Class XCDYouTubeLogClass(void); + +#define XCDYouTubeLog(_flag, _format, ...) [XCDYouTubeLogClass() log:YES level:NSUIntegerMax flag:(_flag) context:(NSInteger)0xced70676 file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__ tag:nil format:(_format), ##__VA_ARGS__] + +#define XCDYouTubeLogError(format, ...) XCDYouTubeLog(DDLogFlagError, format, ##__VA_ARGS__) +#define XCDYouTubeLogWarning(format, ...) XCDYouTubeLog(DDLogFlagWarning, format, ##__VA_ARGS__) +#define XCDYouTubeLogInfo(format, ...) XCDYouTubeLog(DDLogFlagInfo, format, ##__VA_ARGS__) +#define XCDYouTubeLogDebug(format, ...) XCDYouTubeLog(DDLogFlagDebug, format, ##__VA_ARGS__) +#define XCDYouTubeLogVerbose(format, ...) XCDYouTubeLog(DDLogFlagVerbose, format, ##__VA_ARGS__) +#define XCDYouTubeLogTrace(format, ...) XCDYouTubeLog(DDLogFlagTrace, format, ##__VA_ARGS__) diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeLogger.m b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeLogger.m new file mode 100644 index 0000000..aeb7b18 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeLogger.m @@ -0,0 +1,34 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import "XCDYouTubeLogger.h" + +@implementation XCDYouTubeLogger + ++ (void) log:(BOOL)asynchronous level:(NSUInteger)level flag:(DDLogFlag)flag context:(NSInteger)context file:(const char *)file function:(const char *)function line:(NSUInteger)line tag:(id)tag format:(NSString *)format, ... +{ + char *logLevelString = getenv("XCDYouTubeKitLogLevel"); + NSUInteger logLevel = logLevelString ? strtoul(logLevelString, NULL, 0) : DDLogFlagError | DDLogFlagWarning; + if (!(flag & logLevel)) + return; + + va_list arguments; + va_start(arguments, format); + NSLog(@"[XCDYouTubeKit] %@", [[NSString alloc] initWithFormat:format arguments:arguments]); + va_end(arguments); +} + +@end + +Class XCDYouTubeLogClass(void) +{ + static Class logClass; + static dispatch_once_t once; + dispatch_once(&once, ^{ + logClass = NSClassFromString(@"DDLog"); + if (![logClass methodSignatureForSelector:@selector(log:level:flag:context:file:function:line:tag:format:)]) + logClass = [XCDYouTubeLogger class]; + }); + return logClass; +} diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeOperation.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeOperation.h new file mode 100644 index 0000000..46136fb --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeOperation.h @@ -0,0 +1,23 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import + +/** + * The `XCDYouTubeOperation` protocol is adopted by opaque objects returned by the `<-[XCDYouTubeClient getVideoWithIdentifier:completionHandler:]>` method. + */ +@protocol XCDYouTubeOperation + +/** + * --------------- + * @name Canceling + * --------------- + */ + +/** + * Cancels the operation. If the operation is already finished, does nothing. + */ +- (void) cancel; + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubePlayerScript.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubePlayerScript.h new file mode 100644 index 0000000..ee247b1 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubePlayerScript.h @@ -0,0 +1,14 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import + +__attribute__((visibility("hidden"))) +@interface XCDYouTubePlayerScript : NSObject + +- (instancetype) initWithString:(NSString *)string; + +- (NSString *) unscrambleSignature:(NSString *)scrambledSignature; + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubePlayerScript.m b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubePlayerScript.m new file mode 100644 index 0000000..c3e2454 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubePlayerScript.m @@ -0,0 +1,77 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import "XCDYouTubePlayerScript.h" + +#import + +#import "XCDYouTubeLogger.h" + +@interface XCDYouTubePlayerScript () +@property (nonatomic, strong) JSContext *context; +@property (nonatomic, strong) JSValue *signatureFunction; +@end + +@implementation XCDYouTubePlayerScript + +- (instancetype) initWithString:(NSString *)string +{ + if (!(self = [super init])) + return nil; + + NSString *script = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + XCDYouTubeLogTrace(@"%@", script); + static NSString *jsPrologue = @"(function()"; + static NSString *jsEpilogue = @")();"; + if ([script hasPrefix:jsPrologue] && [script hasSuffix:jsEpilogue]) + script = [script substringWithRange:NSMakeRange(jsPrologue.length, script.length - (jsPrologue.length + jsEpilogue.length))]; + else + XCDYouTubeLogWarning(@"Unexpected player script (not an anonymous function)"); + + _context = [JSContext new]; + _context.exceptionHandler = ^(JSContext *context, JSValue *exception) { + XCDYouTubeLogWarning(@"JavaScript exception: %@", exception); + }; + + NSDictionary *environment = @{ + @"document": @{}, + @"navigator": @{}, + @"window": @{ + @"location": @{ + @"hash": @"" + }, + @"navigator": @{} + } + }; + for (NSString *propertyName in environment) + { + JSValue *value = [JSValue valueWithObject:environment[propertyName] inContext:_context]; + _context[propertyName] = value; + } + + [_context evaluateScript:script]; + + NSRegularExpression *signatureRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"[\"']signature[\"']\\s*,\\s*([^\\(]+)" options:NSRegularExpressionCaseInsensitive error:NULL]; + NSTextCheckingResult *result = [signatureRegularExpression firstMatchInString:script options:(NSMatchingOptions)0 range:NSMakeRange(0, script.length)]; + NSString *signatureFunctionName = result.numberOfRanges > 1 ? [script substringWithRange:[result rangeAtIndex:1]] : nil; + + if (signatureFunctionName) + _signatureFunction = self.context[signatureFunctionName]; + + if (!_signatureFunction) + XCDYouTubeLogWarning(@"No signature function in player script"); + + return self; +} + +- (NSString *) unscrambleSignature:(NSString *)scrambledSignature +{ + if (!self.signatureFunction || !scrambledSignature) + return nil; + + JSValue *unscrambledSignature = [self.signatureFunction callWithArguments:@[ scrambledSignature ]]; + return [unscrambledSignature isString] ? [unscrambledSignature toString] : nil; +} + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo+Private.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo+Private.h new file mode 100644 index 0000000..1a45c64 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo+Private.h @@ -0,0 +1,22 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import + +#import "XCDYouTubePlayerScript.h" + +#define XCDYouTubeErrorUseCipherSignature -1000 + +extern NSString *const XCDYouTubeNoStreamVideoUserInfoKey; + +extern NSDictionary *XCDDictionaryWithQueryString(NSString *string, NSStringEncoding encoding); +extern NSString *XCDQueryStringWithDictionary(NSDictionary *dictionary, NSStringEncoding encoding); + +@interface XCDYouTubeVideo () + +- (instancetype) initWithIdentifier:(NSString *)identifier info:(NSDictionary *)info playerScript:(XCDYouTubePlayerScript *)playerScript response:(NSURLResponse *)response error:(NSError **)error; + +- (void) mergeVideo:(XCDYouTubeVideo *)video; + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo.h new file mode 100644 index 0000000..f568c5b --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo.h @@ -0,0 +1,111 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#if !__has_feature(nullability) +#define NS_ASSUME_NONNULL_BEGIN +#define NS_ASSUME_NONNULL_END +#define nullable +#endif + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * The quality of YouTube videos. These values are used as keys in the `<[XCDYouTubeVideo streamURLs]>` property. + * + * The constant numbers are the YouTube [itag](https://en.wikipedia.org/wiki/YouTube#Quality_and_formats) values. + */ +typedef NS_ENUM(NSUInteger, XCDYouTubeVideoQuality) { + /** + * Video: 240p MPEG-4 Visual | 0.175 Mbit/s + * Audio: AAC | 36 kbit/s + */ + XCDYouTubeVideoQualitySmall240 = 36, + + /** + * Video: 360p H.264 | 0.5 Mbit/s + * Audio: AAC | 96 kbit/s + */ + XCDYouTubeVideoQualityMedium360 = 18, + + /** + * Video: 720p H.264 | 2-3 Mbit/s + * Audio: AAC | 192 kbit/s + */ + XCDYouTubeVideoQualityHD720 = 22, + + /** + * Video: 1080p H.264 | 3–5.9 Mbit/s + * Audio: AAC | 192 kbit/s + * + * @deprecated YouTube has removed 1080p mp4 videos. + */ + XCDYouTubeVideoQualityHD1080 DEPRECATED_MSG_ATTRIBUTE("YouTube has removed 1080p mp4 videos.") = 37, +}; + +/** + * Used as a key in the `streamURLs` property of the `XCDYouTubeVideo` class for live videos. + */ +extern NSString *const XCDYouTubeVideoQualityHTTPLiveStreaming; + +/** + * Represents a YouTube video. Use the `<-[XCDYouTubeClient getVideoWithIdentifier:completionHandler:]>` method to obtain a `XCDYouTubeVideo` object. + */ +@interface XCDYouTubeVideo : NSObject + +/** + * -------------------------------- + * @name Accessing video properties + * -------------------------------- + */ + +/** + * The 11 characters YouTube video identifier. + */ +@property (nonatomic, readonly) NSString *identifier; +/** + * The title of the video. + */ +@property (nonatomic, readonly) NSString *title; +/** + * The duration of the video in seconds. + */ +@property (nonatomic, readonly) NSTimeInterval duration; + +/** + * A thumbnail URL for an image of small size, i.e. 120×90. May be nil. + */ +@property (nonatomic, readonly, nullable) NSURL *smallThumbnailURL; +/** + * A thumbnail URL for an image of medium size, i.e. 320×180, 480×360 or 640×480. May be nil. + */ +@property (nonatomic, readonly, nullable) NSURL *mediumThumbnailURL; +/** + * A thumbnail URL for an image of large size, i.e. 1'280×720 or 1'980×1'080. May be nil. + */ +@property (nonatomic, readonly, nullable) NSURL *largeThumbnailURL; + +/** + * A dictionary of video stream URLs. + * + * The keys are the YouTube [itag](https://en.wikipedia.org/wiki/YouTube#Quality_and_formats) values as `NSNumber` objects. The values are the video URLs as `NSURL` objects. There is also the special `XCDYouTubeVideoQualityHTTPLiveStreaming` key for live videos. + * + * You should not store the URLs for later use since they have a limited lifetime and are bound to an IP address. + * + * @see XCDYouTubeVideoQuality + * @see expirationDate + */ +@property (nonatomic, readonly) NSDictionary *streamURLs; + +/** + * The expiration date of the video. + * + * After this date, the stream URLs will not be playable. May be nil if it can not be determined, for example in live videos. + */ +@property (nonatomic, readonly, nullable) NSDate *expirationDate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo.m b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo.m new file mode 100644 index 0000000..2022d99 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideo.m @@ -0,0 +1,211 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import "XCDYouTubeVideo+Private.h" + +#import "XCDYouTubeError.h" + +#import + +NSString *const XCDYouTubeVideoErrorDomain = @"XCDYouTubeVideoErrorDomain"; +NSString *const XCDYouTubeNoStreamVideoUserInfoKey = @"NoStreamVideo"; +NSString *const XCDYouTubeVideoQualityHTTPLiveStreaming = @"HTTPLiveStreaming"; + +NSDictionary *XCDDictionaryWithQueryString(NSString *string, NSStringEncoding encoding) +{ + NSMutableDictionary *dictionary = [NSMutableDictionary new]; + NSArray *fields = [string componentsSeparatedByString:@"&"]; + for (NSString *field in fields) + { + NSArray *pair = [field componentsSeparatedByString:@"="]; + if (pair.count == 2) + { + NSString *key = pair[0]; + NSString *value = [pair[1] stringByReplacingPercentEscapesUsingEncoding:encoding]; + value = [value stringByReplacingOccurrencesOfString:@"+" withString:@" "]; + dictionary[key] = value; + } + } + return [dictionary copy]; +} + +static NSString *XCDURLEncodedStringUsingEncoding(NSString *string, NSStringEncoding encoding) +{ + return CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), CFStringConvertNSStringEncodingToEncoding(encoding))); +} + +NSString *XCDQueryStringWithDictionary(NSDictionary *dictionary, NSStringEncoding encoding) +{ + NSArray *keys = [dictionary.allKeys filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { + return [evaluatedObject isKindOfClass:[NSString class]]; + }]]; + + NSMutableString *query = [NSMutableString new]; + for (NSString *key in [keys sortedArrayUsingSelector:@selector(compare:)]) + { + if (query.length > 0) + [query appendString:@"&"]; + + [query appendString:XCDURLEncodedStringUsingEncoding(key, encoding)]; + [query appendString:@"="]; + [query appendString:XCDURLEncodedStringUsingEncoding([dictionary[key] description], encoding)]; + } + return [query copy]; +} + +@implementation XCDYouTubeVideo + +static NSDate * ExpirationDate(NSURL *streamURL) +{ + NSDictionary *query = XCDDictionaryWithQueryString(streamURL.query, NSUTF8StringEncoding); + NSTimeInterval expire = [query[@"expire"] doubleValue]; + return expire > 0 ? [NSDate dateWithTimeIntervalSince1970:expire] : nil; +} + +- (instancetype) initWithIdentifier:(NSString *)identifier info:(NSDictionary *)info playerScript:(XCDYouTubePlayerScript *)playerScript response:(NSURLResponse *)response error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) + return nil; + + _identifier = identifier; + + NSString *streamMap = info[@"url_encoded_fmt_stream_map"]; + NSString *httpLiveStream = info[@"hlsvp"]; + NSString *adaptiveFormats = info[@"adaptive_fmts"]; + + NSMutableDictionary *userInfo = response.URL ? [@{ NSURLErrorKey: response.URL } mutableCopy] : [NSMutableDictionary new]; + + if (streamMap.length > 0 || httpLiveStream.length > 0) + { + NSMutableArray *streamQueries = [[streamMap componentsSeparatedByString:@","] mutableCopy]; + [streamQueries addObjectsFromArray:[adaptiveFormats componentsSeparatedByString:@","]]; + + NSString *title = info[@"title"] ?: @""; + _title = title; + _duration = [info[@"length_seconds"] doubleValue]; + + NSString *smallThumbnail = info[@"thumbnail_url"] ?: info[@"iurl"]; + NSString *mediumThumbnail = info[@"iurlsd"] ?: info[@"iurlhq"] ?: info[@"iurlmq"]; + NSString *largeThumbnail = info[@"iurlmaxres"]; + _smallThumbnailURL = smallThumbnail ? [NSURL URLWithString:smallThumbnail] : nil; + _mediumThumbnailURL = mediumThumbnail ? [NSURL URLWithString:mediumThumbnail] : nil; + _largeThumbnailURL = largeThumbnail ? [NSURL URLWithString:largeThumbnail] : nil; + + NSMutableDictionary *streamURLs = [NSMutableDictionary new]; + + if (httpLiveStream) + streamURLs[XCDYouTubeVideoQualityHTTPLiveStreaming] = [NSURL URLWithString:httpLiveStream]; + + for (NSString *streamQuery in streamQueries) + { + NSDictionary *stream = XCDDictionaryWithQueryString(streamQuery, NSUTF8StringEncoding); + + NSString *scrambledSignature = stream[@"s"]; + if (scrambledSignature && !playerScript) + { + userInfo[XCDYouTubeNoStreamVideoUserInfoKey] = self; + if (error) + *error = [NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:XCDYouTubeErrorUseCipherSignature userInfo:userInfo]; + + return nil; + } + NSString *signature = [playerScript unscrambleSignature:scrambledSignature]; + if (playerScript && scrambledSignature && !signature) + continue; + + NSString *urlString = stream[@"url"]; + NSString *itag = stream[@"itag"]; + if (urlString && itag) + { + NSURL *streamURL = [NSURL URLWithString:urlString]; + if (!_expirationDate) + _expirationDate = ExpirationDate(streamURL); + + if (signature) + streamURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@&signature=%@", urlString, [signature stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; + + streamURLs[@(itag.integerValue)] = streamURL; + } + } + _streamURLs = [streamURLs copy]; + + if (_streamURLs.count == 0) + { + if (error) + *error = [NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:XCDYouTubeErrorNoStreamAvailable userInfo:userInfo]; + + return nil; + } + + return self; + } + else + { + if (error) + { + NSString *reason = info[@"reason"]; + if (reason) + { + reason = [reason stringByReplacingOccurrencesOfString:@"" withString:@" " options:NSRegularExpressionSearch range:NSMakeRange(0, reason.length)]; + reason = [reason stringByReplacingOccurrencesOfString:@"\n" withString:@" " options:(NSStringCompareOptions)0 range:NSMakeRange(0, reason.length)]; + NSRange range; + while ((range = [reason rangeOfString:@"<[^>]+>" options:NSRegularExpressionSearch]).location != NSNotFound) + reason = [reason stringByReplacingCharactersInRange:range withString:@""]; + + userInfo[NSLocalizedDescriptionKey] = reason; + } + + NSString *errorcode = info[@"errorcode"]; + NSInteger code = errorcode ? errorcode.integerValue : XCDYouTubeErrorNoStreamAvailable; + *error = [NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:code userInfo:userInfo]; + } + return nil; + } +} + +- (void) mergeVideo:(XCDYouTubeVideo *)video +{ + unsigned int count; + objc_property_t *properties = class_copyPropertyList(self.class, &count); + for (unsigned int i = 0; i < count; i++) + { + NSString *propertyName = @(property_getName(properties[i])); + if (![self valueForKey:propertyName]) + [self setValue:[video valueForKey:propertyName] forKeyPath:propertyName]; + } + free(properties); +} + +#pragma mark - NSObject + +- (BOOL) isEqual:(id)object +{ + return [object isKindOfClass:[XCDYouTubeVideo class]] && [((XCDYouTubeVideo *)object).identifier isEqual:self.identifier]; +} + +- (NSUInteger) hash +{ + return self.identifier.hash; +} + +- (NSString *) description +{ + return [NSString stringWithFormat:@"[%@] %@", self.identifier, self.title]; +} + +- (NSString *) debugDescription +{ + NSString *duration = [[NSDateComponentsFormatter new] stringFromTimeInterval:self.duration] ?: [NSString stringWithFormat:@"%@ seconds", @(self.duration)]; + NSString *thumbnailDescription = [NSString stringWithFormat:@"Small thumbnail: %@\nMedium thumbnail: %@\nLarge thumbnail: %@", self.smallThumbnailURL, self.mediumThumbnailURL, self.largeThumbnailURL]; + return [NSString stringWithFormat:@"<%@: %p> %@\nDuration: %@\nExpiration date: %@\n%@\nVideo Streams: %@", self.class, self, self.description, duration, self.expirationDate, thumbnailDescription, self.streamURLs]; +} + +#pragma mark - NSCopying + +- (id) copyWithZone:(NSZone *)zone +{ + return self; +} + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoOperation.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoOperation.h new file mode 100644 index 0000000..39fa902 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoOperation.h @@ -0,0 +1,64 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#if !__has_feature(nullability) +#define NS_ASSUME_NONNULL_BEGIN +#define NS_ASSUME_NONNULL_END +#define nullable +#endif + +#import + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * XCDYouTubeVideoOperation is a subclass of `NSOperation` that connects to the YouTube API and parse the response. + * + * You should probably use the higher level class ``. Use this class only if you are very familiar with `NSOperation` and need to manage dependencies between operations. + * + * Since version 2.2.0 this operation is synchronous and must not be started on the main thread. Starting the operation on the main thread throws an exception. + */ +@interface XCDYouTubeVideoOperation : NSOperation + +/** + * ------------------ + * @name Initializing + * ------------------ + */ + +/** + * Initializes a video operation with the specified video identifier and language identifier. + * + * @param videoIdentifier A 11 characters YouTube video identifier. + * @param languageIdentifier An [ISO 639-1 two-letter language code](http://www.loc.gov/standards/iso639-2/php/code_list.php) used for error localization. If you pass a nil language identifier then English (`en`) is used. + * + * @return An initialized `XCDYouTubeVideoOperation` object. + */ +- (instancetype) initWithVideoIdentifier:(NSString *)videoIdentifier languageIdentifier:(nullable NSString *)languageIdentifier; + +/** + * -------------------------------- + * @name Accessing operation result + * -------------------------------- + */ + +/** + * Returns an error of the `XCDYouTubeVideoErrorDomain` domain if the operation failed or nil if it succeeded. + * + * Returns nil if the operation is not yet finished or if it was canceled. + */ +@property (atomic, readonly, nullable) NSError *error; +/** + * Returns a video object if the operation succeeded or nil if it failed. + * + * Returns nil if the operation is not yet finished or if it was canceled. + */ +@property (atomic, readonly, nullable) XCDYouTubeVideo *video; + +@end + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoOperation.m b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoOperation.m new file mode 100644 index 0000000..8396b85 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoOperation.m @@ -0,0 +1,316 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import "XCDYouTubeVideoOperation.h" + +#import + +#import "XCDYouTubeVideo+Private.h" +#import "XCDYouTubeError.h" +#import "XCDYouTubeVideoWebpage.h" +#import "XCDYouTubePlayerScript.h" +#import "XCDYouTubeLogger.h" + +static const void * const XCDYouTubeRequestTypeKey = &XCDYouTubeRequestTypeKey; + +typedef NS_ENUM(NSUInteger, XCDYouTubeRequestType) { + XCDYouTubeRequestTypeGetVideoInfo = 1, + XCDYouTubeRequestTypeWatchPage, + XCDYouTubeRequestTypeEmbedPage, + XCDYouTubeRequestTypeJavaScriptPlayer, +}; + +@interface XCDYouTubeVideoOperation () +@property (atomic, copy, readonly) NSString *videoIdentifier; +@property (atomic, copy, readonly) NSString *languageIdentifier; + +@property (atomic, assign) NSInteger requestCount; +@property (atomic, strong) NSURLConnection *connection; +@property (atomic, strong) NSURLResponse *response; +@property (atomic, strong) NSMutableData *connectionData; +@property (atomic, strong) NSMutableArray *eventLabels; + +@property (atomic, assign) BOOL keepRunning; + +@property (atomic, strong) XCDYouTubeVideoWebpage *webpage; +@property (atomic, strong) XCDYouTubeVideoWebpage *embedWebpage; +@property (atomic, strong) XCDYouTubePlayerScript *playerScript; +@property (atomic, strong) XCDYouTubeVideo *noStreamVideo; +@property (atomic, strong) NSError *lastError; +@property (atomic, strong) NSError *youTubeError; // Error actually coming from the YouTube API, i.e. explicit and localized error + +@property (atomic, strong, readwrite) NSError *error; +@property (atomic, strong, readwrite) XCDYouTubeVideo *video; +@end + +@implementation XCDYouTubeVideoOperation + +- (instancetype) init +{ + @throw [NSException exceptionWithName:NSGenericException reason:@"Use the `initWithVideoIdentifier:languageIdentifier:` method instead." userInfo:nil]; +} + +- (instancetype) initWithVideoIdentifier:(NSString *)videoIdentifier languageIdentifier:(NSString *)languageIdentifier +{ + if (!(self = [super init])) + return nil; + + _videoIdentifier = videoIdentifier ?: @""; + _languageIdentifier = languageIdentifier ?: @"en"; + + _keepRunning = YES; + + return self; +} + +- (void) startNextRequest +{ + if (self.eventLabels.count == 0) + { + XCDYouTubeRequestType requestType = [objc_getAssociatedObject(self.connection, XCDYouTubeRequestTypeKey) unsignedIntegerValue]; + if (requestType == XCDYouTubeRequestTypeWatchPage || self.webpage) + [self finishWithError]; + else + [self startWatchPageRequest]; + } + else + { + NSString *eventLabel = [self.eventLabels objectAtIndex:0]; + [self.eventLabels removeObjectAtIndex:0]; + + NSDictionary *query = @{ @"video_id": self.videoIdentifier, @"hl": self.languageIdentifier, @"el": eventLabel, @"ps": @"default" }; + NSString *queryString = XCDQueryStringWithDictionary(query, NSUTF8StringEncoding); + NSURL *videoInfoURL = [NSURL URLWithString:[@"https://www.youtube.com/get_video_info?" stringByAppendingString:queryString]]; + [self startRequestWithURL:videoInfoURL type:XCDYouTubeRequestTypeGetVideoInfo]; + } +} + +- (void) startWatchPageRequest +{ + NSDictionary *query = @{ @"v": self.videoIdentifier, @"hl": self.languageIdentifier, @"has_verified": @YES }; + NSString *queryString = XCDQueryStringWithDictionary(query, NSUTF8StringEncoding); + NSURL *webpageURL = [NSURL URLWithString:[@"https://www.youtube.com/watch?" stringByAppendingString:queryString]]; + [self startRequestWithURL:webpageURL type:XCDYouTubeRequestTypeWatchPage]; +} + +- (void) startRequestWithURL:(NSURL *)url type:(XCDYouTubeRequestType)requestType +{ + // Max (age-restricted VEVO) = 2×GetVideoInfo + 1×WatchPage + 1×EmbedPage + 1×JavaScriptPlayer + 1×GetVideoInfo + if (++self.requestCount > 6) + { + // This condition should never happen but the request flow is quite complex so better abort here than go into an infinite loop of requests + [self finishWithError]; + return; + } + + XCDYouTubeLogDebug(@"Starting request: %@", url); + + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10]; + [request setValue:self.languageIdentifier forHTTPHeaderField:@"Accept-Language"]; + + NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO]; + objc_setAssociatedObject(connection, XCDYouTubeRequestTypeKey, @(requestType), OBJC_ASSOCIATION_RETAIN); + [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [connection start]; + self.connection = connection; +} + +- (void) handleVideoInfoResponseWithInfo:(NSDictionary *)info +{ + XCDYouTubeLogDebug(@"Handling video info response"); + XCDYouTubeLogVerbose(@"Video info: %@", info); + + NSError *error = nil; + XCDYouTubeVideo *video = [[XCDYouTubeVideo alloc] initWithIdentifier:self.videoIdentifier info:info playerScript:self.playerScript response:self.response error:&error]; + if (video) + { + [video mergeVideo:self.noStreamVideo]; + [self finishWithVideo:video]; + } + else + { + if ([error.domain isEqual:XCDYouTubeVideoErrorDomain] && error.code == XCDYouTubeErrorUseCipherSignature) + { + self.noStreamVideo = error.userInfo[XCDYouTubeNoStreamVideoUserInfoKey]; + + [self startWatchPageRequest]; + } + else + { + self.lastError = error; + if (error.code > 0) + self.youTubeError = error; + + [self startNextRequest]; + } + } +} + +- (void) handleWebPageResponse +{ + XCDYouTubeLogDebug(@"Handling web page response"); + + self.webpage = [[XCDYouTubeVideoWebpage alloc] initWithData:self.connectionData response:self.response]; + + if (self.webpage.javaScriptPlayerURL) + { + [self startRequestWithURL:self.webpage.javaScriptPlayerURL type:XCDYouTubeRequestTypeJavaScriptPlayer]; + } + else + { + if (self.webpage.isAgeRestricted) + { + NSString *embedURLString = [NSString stringWithFormat:@"https://www.youtube.com/embed/%@", self.videoIdentifier]; + [self startRequestWithURL:[NSURL URLWithString:embedURLString] type:XCDYouTubeRequestTypeEmbedPage]; + } + else + { + [self startNextRequest]; + } + } +} + +- (void) handleEmbedWebPageResponse +{ + XCDYouTubeLogDebug(@"Handling embed web page response"); + + self.embedWebpage = [[XCDYouTubeVideoWebpage alloc] initWithData:self.connectionData response:self.response]; + + if (self.embedWebpage.javaScriptPlayerURL) + { + [self startRequestWithURL:self.embedWebpage.javaScriptPlayerURL type:XCDYouTubeRequestTypeJavaScriptPlayer]; + } + else + { + [self startNextRequest]; + } +} + +- (void) handleJavaScriptPlayerResponse +{ + XCDYouTubeLogDebug(@"Handling JavaScript player response"); + + NSString *script = [[NSString alloc] initWithData:self.connectionData encoding:NSISOLatin1StringEncoding]; + self.playerScript = [[XCDYouTubePlayerScript alloc] initWithString:script]; + + if (self.webpage.isAgeRestricted) + { + NSString *eurl = [@"https://youtube.googleapis.com/v/" stringByAppendingString:self.videoIdentifier]; + NSString *sts = [self.embedWebpage.playerConfiguration[@"sts"] description] ?: [self.webpage.playerConfiguration[@"sts"] description] ?: @""; + NSDictionary *query = @{ @"video_id": self.videoIdentifier, @"hl": self.languageIdentifier, @"eurl": eurl, @"sts": sts}; + NSString *queryString = XCDQueryStringWithDictionary(query, NSUTF8StringEncoding); + NSURL *videoInfoURL = [NSURL URLWithString:[@"https://www.youtube.com/get_video_info?" stringByAppendingString:queryString]]; + [self startRequestWithURL:videoInfoURL type:XCDYouTubeRequestTypeGetVideoInfo]; + } + else + { + [self handleVideoInfoResponseWithInfo:self.webpage.videoInfo]; + } +} + +- (void) finishWithVideo:(XCDYouTubeVideo *)video +{ + self.video = video; + XCDYouTubeLogInfo(@"Video operation finished with success: %@", video); + XCDYouTubeLogDebug(@"%@", video.debugDescription); + [self finish]; +} + +- (void) finishWithError +{ + self.error = self.youTubeError ?: self.lastError; + XCDYouTubeLogError(@"Video operation finished with error: %@\nDomain: %@\nCode: %@\nUser Info: %@", self.error.localizedDescription, self.error.domain, @(self.error.code), self.error.userInfo); + [self finish]; +} + +#pragma mark - NSOperation + +- (void) main +{ + if ([NSThread isMainThread]) + @throw [NSException exceptionWithName:NSGenericException reason:@"XCDYouTubeVideoOperation must not be executed on the main thread." userInfo:nil]; + + XCDYouTubeLogInfo(@"Starting video operation: %@", self); + + self.eventLabels = [[NSMutableArray alloc] initWithArray:@[ @"embedded", @"detailpage" ]]; + [self startNextRequest]; + + while (self.keepRunning) + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; +} + +- (void) cancel +{ + if (self.isCancelled || self.isFinished) + return; + + XCDYouTubeLogInfo(@"Canceling video operation: %@", self); + + [super cancel]; + + [self.connection cancel]; + + [self finish]; +} + +- (void) finish +{ + self.keepRunning = NO; +} + +#pragma mark - NSURLConnectionDataDelegate / NSURLConnectionDelegate + +- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response +{ + NSUInteger capacity = response.expectedContentLength == NSURLResponseUnknownLength ? 0 : (NSUInteger)response.expectedContentLength; + self.connectionData = [[NSMutableData alloc] initWithCapacity:capacity]; + self.response = response; +} + +- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data +{ + [self.connectionData appendData:data]; +} + +- (void) connectionDidFinishLoading:(NSURLConnection *)connection +{ + XCDYouTubeRequestType requestType = [objc_getAssociatedObject(connection, XCDYouTubeRequestTypeKey) unsignedIntegerValue]; + switch (requestType) + { + case XCDYouTubeRequestTypeGetVideoInfo: + { + NSString *videoQuery = [[NSString alloc] initWithData:self.connectionData encoding:NSASCIIStringEncoding]; + NSDictionary *info = XCDDictionaryWithQueryString(videoQuery, NSUTF8StringEncoding); + [self handleVideoInfoResponseWithInfo:info]; + } + break; + case XCDYouTubeRequestTypeWatchPage: + [self handleWebPageResponse]; + break; + case XCDYouTubeRequestTypeEmbedPage: + [self handleEmbedWebPageResponse]; + break; + case XCDYouTubeRequestTypeJavaScriptPlayer: + [self handleJavaScriptPlayerResponse]; + break; + } +} + +- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)connectionError +{ + NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: connectionError.localizedDescription, + NSUnderlyingErrorKey: connectionError }; + self.lastError = [NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:XCDYouTubeErrorNetwork userInfo:userInfo]; + + [self startNextRequest]; +} + +#pragma mark - NSObject + +- (NSString *) description +{ + return [NSString stringWithFormat:@"<%@: %p> %@ (%@)", self.class, self, self.videoIdentifier, self.languageIdentifier]; +} + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h new file mode 100644 index 0000000..fb77e3e --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.h @@ -0,0 +1,121 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#if !__has_feature(nullability) +#define NS_ASSUME_NONNULL_BEGIN +#define NS_ASSUME_NONNULL_END +#define nullable +#endif + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + * ------------------- + * @name Notifications + * ------------------- + */ + +/** + * NSError key for the `MPMoviePlayerPlaybackDidFinishNotification` userInfo dictionary. + * + * Ideally, there should be a `MPMoviePlayerPlaybackDidFinishErrorUserInfoKey` declared near to `MPMoviePlayerPlaybackDidFinishReasonUserInfoKey` in MPMoviePlayerController.h but since it doesn't exist, here is a convenient constant key. + */ +MP_EXTERN NSString *const XCDMoviePlayerPlaybackDidFinishErrorUserInfoKey; + +/** + * Posted when the video player has received the video information. The `object` of the notification is the `XCDYouTubeVideoPlayerViewController` instance. The `userInfo` dictionary contains the `XCDYouTubeVideo` object. + */ +MP_EXTERN NSString *const XCDYouTubeVideoPlayerViewControllerDidReceiveVideoNotification; +/** + * The key for the `XCDYouTubeVideo` object in the user info dictionary of `XCDYouTubeVideoPlayerViewControllerDidReceiveVideoNotification`. + */ +MP_EXTERN NSString *const XCDYouTubeVideoUserInfoKey; + +/** + * A subclass of `MPMoviePlayerViewController` for playing YouTube videos. + * + * Use UIViewController’s `presentMoviePlayerViewControllerAnimated:` method to play a YouTube video fullscreen. + * + * Use the `` method to play a YouTube video inline. + */ +@interface XCDYouTubeVideoPlayerViewController : MPMoviePlayerViewController + +/** + * ------------------ + * @name Initializing + * ------------------ + */ + +/** + * Initializes a YouTube video player view controller + * + * @param videoIdentifier A 11 characters YouTube video identifier. If the video identifier is invalid the `MPMoviePlayerPlaybackDidFinishNotification` will be posted with a `MPMovieFinishReasonPlaybackError` reason. + * + * @return An initialized YouTube video player view controller with the specified video identifier. + * + * @discussion You can pass a nil *videoIdentifier* (or use the standard `init` method instead) and set the `` property later. + */ +- (instancetype) initWithVideoIdentifier:(nullable NSString *)videoIdentifier __attribute__((objc_designated_initializer)); + +/** + * ------------------------------------ + * @name Accessing the video identifier + * ------------------------------------ + */ + +/** + * The 11 characters YouTube video identifier. + */ +@property (nonatomic, copy, nullable) NSString *videoIdentifier; + +/** + * ------------------------------------------ + * @name Defining the preferred video quality + * ------------------------------------------ + */ + +/** + * The preferred order for the quality of the video to play. Plays the first match when multiple video streams are available. + * + * Defaults to @[ XCDYouTubeVideoQualityHTTPLiveStreaming, @(XCDYouTubeVideoQualityHD720), @(XCDYouTubeVideoQualityMedium360), @(XCDYouTubeVideoQualitySmall240) ] + * + * You should set this property right after calling the `` method. Setting this property to nil restores its default values. + * + * @see XCDYouTubeVideoQuality + */ +@property (nonatomic, copy) NSArray *preferredVideoQualities; + +/** + * ------------------------ + * @name Presenting a video + * ------------------------ + */ + +/** + * Present the video inside a view. + * + * @param view The view inside which you want to present the video. + * + * @discussion The video view is added as a subview of the specified view. The video does not start playing immediately, you have to call `[videoPlayerViewController.moviePlayer play]` for playback to start. See `MPMoviePlayerController` documentation for more information. + * + * Ownership of the XCDYouTubeVideoPlayerViewController instance is transferred to the view. + */ +- (void) presentInView:(UIView *)view; + +@end + +/** + * ------------------------------ + * @name Deprecated notifications + * ------------------------------ + */ +MP_EXTERN NSString *const XCDYouTubeVideoPlayerViewControllerDidReceiveMetadataNotification DEPRECATED_MSG_ATTRIBUTE("Use XCDYouTubeVideoPlayerViewControllerDidReceiveVideoNotification instead."); +MP_EXTERN NSString *const XCDMetadataKeyTitle DEPRECATED_MSG_ATTRIBUTE("Use XCDYouTubeVideoUserInfoKey instead."); +MP_EXTERN NSString *const XCDMetadataKeySmallThumbnailURL DEPRECATED_MSG_ATTRIBUTE("Use XCDYouTubeVideoUserInfoKey instead."); +MP_EXTERN NSString *const XCDMetadataKeyMediumThumbnailURL DEPRECATED_MSG_ATTRIBUTE("Use XCDYouTubeVideoUserInfoKey instead."); +MP_EXTERN NSString *const XCDMetadataKeyLargeThumbnailURL DEPRECATED_MSG_ATTRIBUTE("Use XCDYouTubeVideoUserInfoKey instead."); + +NS_ASSUME_NONNULL_END diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m new file mode 100644 index 0000000..245ab87 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoPlayerViewController.m @@ -0,0 +1,198 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import "XCDYouTubeVideoPlayerViewController.h" + +#import "XCDYouTubeClient.h" + +#import + +NSString *const XCDMoviePlayerPlaybackDidFinishErrorUserInfoKey = @"error"; // documented in -[MPMoviePlayerController initWithContentURL:] + +NSString *const XCDYouTubeVideoPlayerViewControllerDidReceiveMetadataNotification = @"XCDYouTubeVideoPlayerViewControllerDidReceiveMetadataNotification"; +NSString *const XCDMetadataKeyTitle = @"Title"; +NSString *const XCDMetadataKeySmallThumbnailURL = @"SmallThumbnailURL"; +NSString *const XCDMetadataKeyMediumThumbnailURL = @"MediumThumbnailURL"; +NSString *const XCDMetadataKeyLargeThumbnailURL = @"LargeThumbnailURL"; + +NSString *const XCDYouTubeVideoPlayerViewControllerDidReceiveVideoNotification = @"XCDYouTubeVideoPlayerViewControllerDidReceiveVideoNotification"; +NSString *const XCDYouTubeVideoUserInfoKey = @"Video"; + +@interface XCDYouTubeVideoPlayerViewController () +@property (nonatomic, weak) id videoOperation; +@property (nonatomic, assign, getter = isEmbedded) BOOL embedded; +@end + +@implementation XCDYouTubeVideoPlayerViewController + +/* + * MPMoviePlayerViewController on iOS 7 and earlier + * - (id) init + * `-- [super init] + * + * - (id) initWithContentURL:(NSURL *)contentURL + * |-- [self init] + * `-- [self.moviePlayer setContentURL:contentURL] + * + * MPMoviePlayerViewController on iOS 8 and later + * - (id) init + * `-- [self initWithContentURL:nil] + * + * - (id) initWithContentURL:(NSURL *)contentURL + * |-- [super init] + * `-- [self.moviePlayer setContentURL:contentURL] + */ + +- (instancetype) init +{ + return [self initWithVideoIdentifier:nil]; +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-designated-initializers" +- (instancetype) initWithContentURL:(NSURL *)contentURL +{ + @throw [NSException exceptionWithName:NSGenericException reason:@"Use the `initWithVideoIdentifier:` method instead." userInfo:nil]; +} + +- (instancetype) initWithVideoIdentifier:(NSString *)videoIdentifier +{ + if ([[[UIDevice currentDevice] systemVersion] integerValue] >= 8) + self = [super initWithContentURL:nil]; + else + self = [super init]; + + if (!self) + return nil; + + // See https://github.com/0xced/XCDYouTubeKit/commit/cadec1c3857d6a302f71b9ce7d1ae48e389e6890 + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; + + if (videoIdentifier) + self.videoIdentifier = videoIdentifier; + + return self; +} +#pragma clang diagnostic pop + +#pragma mark - Public + +- (NSArray *) preferredVideoQualities +{ + if (!_preferredVideoQualities) + _preferredVideoQualities = @[ XCDYouTubeVideoQualityHTTPLiveStreaming, @(XCDYouTubeVideoQualityHD720), @(XCDYouTubeVideoQualityMedium360), @(XCDYouTubeVideoQualitySmall240) ]; + + return _preferredVideoQualities; +} + +- (void) setVideoIdentifier:(NSString *)videoIdentifier +{ + if ([videoIdentifier isEqual:self.videoIdentifier]) + return; + + _videoIdentifier = [videoIdentifier copy]; + + [self.videoOperation cancel]; + self.videoOperation = [[XCDYouTubeClient defaultClient] getVideoWithIdentifier:videoIdentifier completionHandler:^(XCDYouTubeVideo *video, NSError *error) + { + if (video) + { + NSURL *streamURL = nil; + for (NSNumber *videoQuality in self.preferredVideoQualities) + { + streamURL = video.streamURLs[videoQuality]; + if (streamURL) + { + [self startVideo:video streamURL:streamURL]; + break; + } + } + + if (!streamURL) + { + NSError *noStreamError = [NSError errorWithDomain:XCDYouTubeVideoErrorDomain code:XCDYouTubeErrorNoStreamAvailable userInfo:nil]; + [self stopWithError:noStreamError]; + } + } + else + { + [self stopWithError:error]; + } + }]; +} + +- (void) presentInView:(UIView *)view +{ + static const void * const XCDYouTubeVideoPlayerViewControllerKey = &XCDYouTubeVideoPlayerViewControllerKey; + + self.embedded = YES; + + self.moviePlayer.controlStyle = MPMovieControlStyleEmbedded; + self.moviePlayer.view.frame = CGRectMake(0.f, 0.f, view.bounds.size.width, view.bounds.size.height); + self.moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + if (![view.subviews containsObject:self.moviePlayer.view]) + [view addSubview:self.moviePlayer.view]; + objc_setAssociatedObject(view, XCDYouTubeVideoPlayerViewControllerKey, self, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - Private + +- (void) startVideo:(XCDYouTubeVideo *)video streamURL:(NSURL *)streamURL +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + NSMutableDictionary *userInfo = [NSMutableDictionary new]; + if (video.title) + userInfo[XCDMetadataKeyTitle] = video.title; + if (video.smallThumbnailURL) + userInfo[XCDMetadataKeySmallThumbnailURL] = video.smallThumbnailURL; + if (video.mediumThumbnailURL) + userInfo[XCDMetadataKeyMediumThumbnailURL] = video.mediumThumbnailURL; + if (video.largeThumbnailURL) + userInfo[XCDMetadataKeyLargeThumbnailURL] = video.largeThumbnailURL; + + [[NSNotificationCenter defaultCenter] postNotificationName:XCDYouTubeVideoPlayerViewControllerDidReceiveMetadataNotification object:self userInfo:userInfo]; +#pragma clang diagnostic pop + + [[NSNotificationCenter defaultCenter] postNotificationName:XCDYouTubeVideoPlayerViewControllerDidReceiveVideoNotification object:self userInfo:@{ XCDYouTubeVideoUserInfoKey: video }]; + + self.moviePlayer.contentURL = streamURL; +} + +- (void) stopWithError:(NSError *)error +{ + NSDictionary *userInfo = @{ MPMoviePlayerPlaybackDidFinishReasonUserInfoKey: @(MPMovieFinishReasonPlaybackError), + XCDMoviePlayerPlaybackDidFinishErrorUserInfoKey: error }; + [[NSNotificationCenter defaultCenter] postNotificationName:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer userInfo:userInfo]; + + if (self.isEmbedded) + [self.moviePlayer.view removeFromSuperview]; + else + [self.presentingViewController dismissMoviePlayerViewControllerAnimated]; +} + +#pragma mark - UIViewController + +- (void) viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + if (![self isBeingPresented]) + return; + + self.moviePlayer.controlStyle = MPMovieControlStyleFullscreen; + [self.moviePlayer play]; +} + +- (void) viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; + + if (![self isBeingDismissed]) + return; + + [self.videoOperation cancel]; +} + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoWebpage.h b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoWebpage.h new file mode 100644 index 0000000..1840841 --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoWebpage.h @@ -0,0 +1,17 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import + +__attribute__((visibility("hidden"))) +@interface XCDYouTubeVideoWebpage : NSObject + +- (instancetype) initWithData:(NSData *)data response:(NSURLResponse *)response; + +@property (nonatomic, readonly) NSDictionary *playerConfiguration; +@property (nonatomic, readonly) NSDictionary *videoInfo; +@property (nonatomic, readonly) NSURL *javaScriptPlayerURL; +@property (nonatomic, readonly) BOOL isAgeRestricted; + +@end diff --git a/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoWebpage.m b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoWebpage.m new file mode 100644 index 0000000..0075bed --- /dev/null +++ b/InControl/Pods/XCDYouTubeKit/XCDYouTubeKit/XCDYouTubeVideoWebpage.m @@ -0,0 +1,115 @@ +// +// Copyright (c) 2013-2015 Cédric Luthi. All rights reserved. +// + +#import "XCDYouTubeVideoWebpage.h" + +#import "XCDYouTubeLogger.h" + +@interface XCDYouTubeVideoWebpage () +@property (nonatomic, strong) NSData *data; +@property (nonatomic, strong) NSURLResponse *response; +@end + +@implementation XCDYouTubeVideoWebpage +{ + NSDictionary *_playerConfiguration; + NSDictionary *_videoInfo; + NSURL *_javaScriptPlayerURL; + BOOL _isAgeRestricted; +} + +- (instancetype) initWithData:(NSData *)data response:(NSURLResponse *)response +{ + if (!(self = [super init])) + return nil; + + _data = data; + _response = response; + + return self; +} + +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +- (NSDictionary *) playerConfiguration +{ + if (!_playerConfiguration) + { + __block NSDictionary *playerConfigurationDictionary; + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName ?: CFSTR("")); + NSString *html = CFBridgingRelease(CFStringCreateWithBytes(kCFAllocatorDefault, self.data.bytes, (CFIndex)self.data.length, encoding != kCFStringEncodingInvalidId ? encoding : kCFStringEncodingISOLatin1, false)); + XCDYouTubeLogTrace(@"%@", html); + NSRegularExpression *playerConfigRegularExpression = [NSRegularExpression regularExpressionWithPattern:@"ytplayer.config\\s*=\\s*(\\{.*?\\});|\\(\\s*'PLAYER_CONFIG',\\s*(\\{.*?\\})\\s*\\)" options:NSRegularExpressionCaseInsensitive error:NULL]; + [playerConfigRegularExpression enumerateMatchesInString:html options:(NSMatchingOptions)0 range:NSMakeRange(0, html.length) usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) + { + for (NSUInteger i = 1; i < result.numberOfRanges; i++) + { + NSRange range = [result rangeAtIndex:i]; + if (range.length == 0) + continue; + + NSString *configString = [html substringWithRange:range]; + NSData *configData = [configString dataUsingEncoding:NSUTF8StringEncoding]; + NSDictionary *playerConfiguration = [NSJSONSerialization JSONObjectWithData:configData ?: [NSData new] options:(NSJSONReadingOptions)0 error:NULL]; + if ([playerConfiguration isKindOfClass:[NSDictionary class]]) + { + playerConfigurationDictionary = playerConfiguration; + *stop = YES; + } + } + }]; + _playerConfiguration = playerConfigurationDictionary; + } + return _playerConfiguration; +} + +- (NSDictionary *) videoInfo +{ + if (!_videoInfo) + { + NSDictionary *args = self.playerConfiguration[@"args"]; + if ([args isKindOfClass:[NSDictionary class]]) + { + NSMutableDictionary *info = [NSMutableDictionary new]; + [args enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) + { + if ([value isKindOfClass:[NSString class]] || [value isKindOfClass:[NSNumber class]]) + info[key] = [value description]; + }]; + _videoInfo = [info copy]; + } + } + return _videoInfo; +} + +- (NSURL *) javaScriptPlayerURL +{ + if (!_javaScriptPlayerURL) + { + NSString *jsAssets = [self.playerConfiguration valueForKeyPath:@"assets.js"]; + if ([jsAssets isKindOfClass:[NSString class]]) + { + NSString *javaScriptPlayerURLString = jsAssets; + if ([jsAssets hasPrefix:@"//"]) + javaScriptPlayerURLString = [@"https:" stringByAppendingString:jsAssets]; + + _javaScriptPlayerURL = [NSURL URLWithString:javaScriptPlayerURLString]; + } + } + return _javaScriptPlayerURL; +} + +- (BOOL) isAgeRestricted +{ + if (!_isAgeRestricted) + { + NSData *openGraphAgeRestriction = [@"og:restrictions:age" dataUsingEncoding:NSUTF8StringEncoding]; + NSDataSearchOptions options = (NSDataSearchOptions)0; + NSRange range = NSMakeRange(0, self.data.length); + _isAgeRestricted = [self.data rangeOfData:openGraphAgeRestriction options:options range:range].location != NSNotFound; + } + return _isAgeRestricted; +} + +@end diff --git a/InControl/RNFrostedSidebar.h b/InControl/RNFrostedSidebar.h new file mode 100644 index 0000000..566682b --- /dev/null +++ b/InControl/RNFrostedSidebar.h @@ -0,0 +1,81 @@ +// +// RNFrostedMenu.h +// RNFrostedMenu +// +// Created by Ryan Nystrom on 8/13/13. +// Copyright (c) 2013 Ryan Nystrom. All rights reserved. +// +// Original Dribbble shot by Jakub Antalik +// http://dribbble.com/shots/1194205-Sidebar-calendar-animation +// + +#import + +@class RNFrostedSidebar; + +@protocol RNFrostedSidebarDelegate +@optional +- (void)sidebar:(RNFrostedSidebar *)sidebar willShowOnScreenAnimated:(BOOL)animatedYesOrNo; +- (void)sidebar:(RNFrostedSidebar *)sidebar didShowOnScreenAnimated:(BOOL)animatedYesOrNo; +- (void)sidebar:(RNFrostedSidebar *)sidebar willDismissFromScreenAnimated:(BOOL)animatedYesOrNo; +- (void)sidebar:(RNFrostedSidebar *)sidebar didDismissFromScreenAnimated:(BOOL)animatedYesOrNo; +- (void)sidebar:(RNFrostedSidebar *)sidebar didTapItemAtIndex:(NSUInteger)index; +- (void)sidebar:(RNFrostedSidebar *)sidebar didEnable:(BOOL)itemEnabled itemAtIndex:(NSUInteger)index; +@end + +@interface RNFrostedSidebar : UIViewController + ++ (instancetype)visibleSidebar; + +// The width of the sidebar +// Default 150 +@property (nonatomic, assign) CGFloat width; + +// Access the view that contains the menu items +@property (nonatomic, strong, readonly) UIScrollView *contentView; + +// Toggle displaying the sidebar on the right side of the device +// Default NO +@property (nonatomic, assign) BOOL showFromRight; + +// The duration of the show and hide animations +// Default 0.25 +@property (nonatomic, assign) CGFloat animationDuration; + +// The dimension for each item view, not including padding +// Default {75, 75} +@property (nonatomic, assign) CGSize itemSize; + +// The color to tint the blur effect +// Default white: 0.2, alpha: 0.73 +@property (nonatomic, strong) UIColor *tintColor; + +// The background color for each item view +// NOTE: set using either colorWithWhite:alpha or colorWithRed:green:blue:alpha +// Default white: 1, alpha 0.25 +@property (nonatomic, strong) UIColor *itemBackgroundColor; + +// The width of the colored border for selected item views +// Default 2 +@property (nonatomic, assign) NSUInteger borderWidth; + +// If YES, only a single item can be selected at a time, and one item is always selected +// Default NO +@property (nonatomic, assign) BOOL isSingleSelect; + +// An optional delegate to respond to interaction events +@property (nonatomic, weak) id delegate; + +- (instancetype)initWithImages:(NSArray *)images selectedIndices:(NSIndexSet *)selectedIndices borderColors:(NSArray *)colors; +- (instancetype)initWithImages:(NSArray *)images selectedIndices:(NSIndexSet *)selectedIndices; +- (instancetype)initWithImages:(NSArray *)images; + +- (void)show; +- (void)showAnimated:(BOOL)animated; +- (void)showInViewController:(UIViewController *)controller animated:(BOOL)animated; + +- (void)dismiss; +- (void)dismissAnimated:(BOOL)animated; +- (void)dismissAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion; + +@end diff --git a/InControl/RNFrostedSidebar.m b/InControl/RNFrostedSidebar.m new file mode 100644 index 0000000..83f9269 --- /dev/null +++ b/InControl/RNFrostedSidebar.m @@ -0,0 +1,667 @@ +// +// RNFrostedMenu.m +// RNFrostedMenu +// +// Created by Ryan Nystrom on 8/13/13. +// Copyright (c) 2013 Ryan Nystrom. All rights reserved. +// + +#define __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED __IPHONE_7_0 + +#import "RNFrostedSidebar.h" +#import + +#pragma mark - Categories + +@implementation UIView (rn_Screenshot) + +- (UIImage *)rn_screenshot { + UIGraphicsBeginImageContext(self.bounds.size); + if([self respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]){ + [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:NO]; + } + else{ + [self.layer renderInContext:UIGraphicsGetCurrentContext()]; + } + UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + NSData *imageData = UIImageJPEGRepresentation(image, 0.75); + image = [UIImage imageWithData:imageData]; + return image; +} + +@end + +#import + +@implementation UIImage (rn_Blur) + +- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage +{ + // Check pre-conditions. + if (self.size.width < 1 || self.size.height < 1) { + NSLog (@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", self.size.width, self.size.height, self); + return nil; + } + if (!self.CGImage) { + NSLog (@"*** error: image must be backed by a CGImage: %@", self); + return nil; + } + if (maskImage && !maskImage.CGImage) { + NSLog (@"*** error: maskImage must be backed by a CGImage: %@", maskImage); + return nil; + } + + CGRect imageRect = { CGPointZero, self.size }; + UIImage *effectImage = self; + + BOOL hasBlur = blurRadius > __FLT_EPSILON__; + BOOL hasSaturationChange = fabs(saturationDeltaFactor - 1.) > __FLT_EPSILON__; + if (hasBlur || hasSaturationChange) { + UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); + CGContextRef effectInContext = UIGraphicsGetCurrentContext(); + CGContextScaleCTM(effectInContext, 1.0, -1.0); + CGContextTranslateCTM(effectInContext, 0, -self.size.height); + CGContextDrawImage(effectInContext, imageRect, self.CGImage); + + vImage_Buffer effectInBuffer; + effectInBuffer.data = CGBitmapContextGetData(effectInContext); + effectInBuffer.width = CGBitmapContextGetWidth(effectInContext); + effectInBuffer.height = CGBitmapContextGetHeight(effectInContext); + effectInBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectInContext); + + UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); + CGContextRef effectOutContext = UIGraphicsGetCurrentContext(); + vImage_Buffer effectOutBuffer; + effectOutBuffer.data = CGBitmapContextGetData(effectOutContext); + effectOutBuffer.width = CGBitmapContextGetWidth(effectOutContext); + effectOutBuffer.height = CGBitmapContextGetHeight(effectOutContext); + effectOutBuffer.rowBytes = CGBitmapContextGetBytesPerRow(effectOutContext); + + if (hasBlur) { + // A description of how to compute the box kernel width from the Gaussian + // radius (aka standard deviation) appears in the SVG spec: + // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement + // + // For larger values of 's' (s >= 2.0), an approximation can be used: Three + // successive box-blurs build a piece-wise quadratic convolution kernel, which + // approximates the Gaussian kernel to within roughly 3%. + // + // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) + // + // ... if d is odd, use three box-blurs of size 'd', centered on the output pixel. + // + CGFloat inputRadius = blurRadius * [[UIScreen mainScreen] scale]; + uint32_t radius = floor(inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5); + if (radius % 2 != 1) { + radius += 1; // force radius to be odd so that the three box-blur methodology works. + } + vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend); + vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend); + vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend); + + } + BOOL effectImageBuffersAreSwapped = NO; + if (hasSaturationChange) { + CGFloat s = saturationDeltaFactor; + CGFloat floatingPointSaturationMatrix[] = { + 0.0722 + 0.9278 * s, 0.0722 - 0.0722 * s, 0.0722 - 0.0722 * s, 0, + 0.7152 - 0.7152 * s, 0.7152 + 0.2848 * s, 0.7152 - 0.7152 * s, 0, + 0.2126 - 0.2126 * s, 0.2126 - 0.2126 * s, 0.2126 + 0.7873 * s, 0, + 0, 0, 0, 1, + }; + const int32_t divisor = 256; + NSUInteger matrixSize = sizeof(floatingPointSaturationMatrix)/sizeof(floatingPointSaturationMatrix[0]); + int16_t saturationMatrix[matrixSize]; + for (NSUInteger i = 0; i < matrixSize; ++i) { + saturationMatrix[i] = (int16_t)roundf(floatingPointSaturationMatrix[i] * divisor); + } + if (hasBlur) { + vImageMatrixMultiply_ARGB8888(&effectOutBuffer, &effectInBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); + effectImageBuffersAreSwapped = YES; + } + else { + vImageMatrixMultiply_ARGB8888(&effectInBuffer, &effectOutBuffer, saturationMatrix, divisor, NULL, NULL, kvImageNoFlags); + } + } + if (!effectImageBuffersAreSwapped) + effectImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + if (effectImageBuffersAreSwapped) + effectImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + } + + // Set up output context. + UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); + CGContextRef outputContext = UIGraphicsGetCurrentContext(); + CGContextScaleCTM(outputContext, 1.0, -1.0); + CGContextTranslateCTM(outputContext, 0, -self.size.height); + + // Draw base image. + CGContextDrawImage(outputContext, imageRect, self.CGImage); + + // Draw effect image. + if (hasBlur) { + CGContextSaveGState(outputContext); + if (maskImage) { + CGContextClipToMask(outputContext, imageRect, maskImage.CGImage); + } + CGContextDrawImage(outputContext, imageRect, effectImage.CGImage); + CGContextRestoreGState(outputContext); + } + + // Add in color tint. + if (tintColor) { + CGContextSaveGState(outputContext); + CGContextSetFillColorWithColor(outputContext, tintColor.CGColor); + CGContextFillRect(outputContext, imageRect); + CGContextRestoreGState(outputContext); + } + + // Output image is ready. + UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + return outputImage; +} + +@end + +#pragma mark - Private Classes + +@interface RNCalloutItemView : UIView + +@property (nonatomic, strong) UIImageView *imageView; +@property (nonatomic, assign) NSInteger itemIndex; +@property (nonatomic, strong) UIColor *originalBackgroundColor; + +@end + +@implementation RNCalloutItemView + +- (instancetype)init { + if (self = [super init]) { + _imageView = [[UIImageView alloc] init]; + _imageView.backgroundColor = [UIColor clearColor]; + _imageView.contentMode = UIViewContentModeScaleAspectFit; + [self addSubview:_imageView]; + } + return self; +} + +- (void)layoutSubviews { + [super layoutSubviews]; + + CGFloat inset = self.bounds.size.height/2; + self.imageView.frame = CGRectMake(0, 0, inset, inset); + self.imageView.center = CGPointMake(inset, inset); +} + +- (void)setOriginalBackgroundColor:(UIColor *)originalBackgroundColor { + _originalBackgroundColor = originalBackgroundColor; + self.backgroundColor = originalBackgroundColor; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + [super touchesBegan:touches withEvent:event]; + + CGFloat r, g, b, a; + CGFloat darkenFactor = 0.3f; + UIColor *darkerColor; + if ([self.originalBackgroundColor getRed:&r green:&g blue:&b alpha:&a]) { + darkerColor = [UIColor colorWithRed:MAX(r - darkenFactor, 0.0) green:MAX(g - darkenFactor, 0.0) blue:MAX(b - darkenFactor, 0.0) alpha:a]; + } + else if ([self.originalBackgroundColor getWhite:&r alpha:&a]) { + darkerColor = [UIColor colorWithWhite:MAX(r - darkenFactor, 0.0) alpha:a]; + } + else { + @throw @"Item color should be RGBA or White/Alpha in order to darken the button color."; + } + self.backgroundColor = darkerColor; +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + [super touchesEnded:touches withEvent:event]; + self.backgroundColor = self.originalBackgroundColor; +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { + [super touchesCancelled:touches withEvent:event]; + self.backgroundColor = self.originalBackgroundColor; +} + +@end + +#pragma mark - Public Classes + +@interface RNFrostedSidebar () + +@property (nonatomic, strong) UIScrollView *contentView; +@property (nonatomic, strong) UIImageView *blurView; +@property (nonatomic, strong) UITapGestureRecognizer *tapGesture; +@property (nonatomic, strong) NSArray *images; +@property (nonatomic, strong) NSArray *borderColors; +@property (nonatomic, strong) NSMutableArray *itemViews; +@property (nonatomic, strong) NSMutableIndexSet *selectedIndices; + +@end + +static RNFrostedSidebar *rn_frostedMenu; + +@implementation RNFrostedSidebar + ++ (instancetype)visibleSidebar { + return rn_frostedMenu; +} + +- (instancetype)initWithImages:(NSArray *)images selectedIndices:(NSIndexSet *)selectedIndices borderColors:(NSArray *)colors { + if (self = [super init]) { + _isSingleSelect = NO; + _contentView = [[UIScrollView alloc] init]; + _contentView.alwaysBounceHorizontal = NO; + _contentView.alwaysBounceVertical = YES; + _contentView.bounces = YES; + _contentView.clipsToBounds = NO; + _contentView.showsHorizontalScrollIndicator = NO; + _contentView.showsVerticalScrollIndicator = NO; + + _width = 150; + _animationDuration = 0.25f; + _itemSize = CGSizeMake(_width/2, _width/2); + _itemViews = [NSMutableArray array]; + _tintColor = [UIColor colorWithWhite:0.2 alpha:0.73]; + _borderWidth = 2; + _itemBackgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.25]; + + if (colors) { + NSAssert([colors count] == [images count], @"Border color count must match images count. If you want a blank border, use [UIColor clearColor]."); + } + + _selectedIndices = [selectedIndices mutableCopy] ?: [NSMutableIndexSet indexSet]; + _borderColors = colors; + _images = images; + + [_images enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL *stop) { + RNCalloutItemView *view = [[RNCalloutItemView alloc] init]; + view.itemIndex = idx; + view.clipsToBounds = YES; + view.imageView.image = image; + [_contentView addSubview:view]; + + [_itemViews addObject:view]; + + if (_borderColors && _selectedIndices && [_selectedIndices containsIndex:idx]) { + UIColor *color = _borderColors[idx]; + view.layer.borderColor = color.CGColor; + } + else { + view.layer.borderColor = [UIColor clearColor].CGColor; + } + }]; + } + return self; +} + +- (instancetype)initWithImages:(NSArray *)images selectedIndices:(NSIndexSet *)selectedIndices { + return [self initWithImages:images selectedIndices:selectedIndices borderColors:nil]; +} + +- (instancetype)initWithImages:(NSArray *)images { + return [self initWithImages:images selectedIndices:nil borderColors:nil]; +} + +- (instancetype)init { + NSAssert(NO, @"Unable to create with plain init."); + return nil; +} + +- (void)loadView { + [super loadView]; + self.view.backgroundColor = [UIColor clearColor]; + [self.view addSubview:self.contentView]; + self.tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; + [self.view addGestureRecognizer:self.tapGesture]; +} + +- (BOOL)shouldAutorotate { + return YES; +} + +- (NSUInteger)supportedInterfaceOrientations { + return UIInterfaceOrientationMaskAll; +} + +- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { + [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; + + if ([self isViewLoaded] && self.view.window != nil) { + self.view.alpha = 0; + UIImage *blurImage = [self.parentViewController.view rn_screenshot]; + blurImage = [blurImage applyBlurWithRadius:5 tintColor:self.tintColor saturationDeltaFactor:1.8 maskImage:nil]; + self.blurView.image = blurImage; + self.view.alpha = 1; + + [self layoutSubviews]; + } +} + +#pragma mark - Show + +- (void)animateSpringWithView:(RNCalloutItemView *)view idx:(NSUInteger)idx initDelay:(CGFloat)initDelay { +#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED + [UIView animateWithDuration:0.5 + delay:(initDelay + idx*0.1f) + usingSpringWithDamping:10 + initialSpringVelocity:50 + options:0 + animations:^{ + view.layer.transform = CATransform3DIdentity; + view.alpha = 1; + } + completion:nil]; +#endif +} + +- (void)animateFauxBounceWithView:(RNCalloutItemView *)view idx:(NSUInteger)idx initDelay:(CGFloat)initDelay { + [UIView animateWithDuration:0.2 + delay:(initDelay + idx*0.1f) + options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationCurveEaseInOut + animations:^{ + view.layer.transform = CATransform3DMakeScale(1.1, 1.1, 1); + view.alpha = 1; + } + completion:^(BOOL finished) { + [UIView animateWithDuration:0.1 animations:^{ + view.layer.transform = CATransform3DIdentity; + }]; + }]; +} + +- (void)showInViewController:(UIViewController *)controller animated:(BOOL)animated { + if (rn_frostedMenu != nil) { + [rn_frostedMenu dismissAnimated:NO completion:nil]; + } + + if ([self.delegate respondsToSelector:@selector(sidebar:willShowOnScreenAnimated:)]) { + [self.delegate sidebar:self willShowOnScreenAnimated:animated]; + } + + rn_frostedMenu = self; + + UIImage *blurImage = [controller.view rn_screenshot]; + blurImage = [blurImage applyBlurWithRadius:5 tintColor:self.tintColor saturationDeltaFactor:1.8 maskImage:nil]; + + [self rn_addToParentViewController:controller callingAppearanceMethods:YES]; + self.view.frame = controller.view.bounds; + + CGFloat parentWidth = self.view.bounds.size.width; + + CGRect contentFrame = self.view.bounds; + contentFrame.origin.x = _showFromRight ? parentWidth : -_width; + contentFrame.size.width = _width; + self.contentView.frame = contentFrame; + + [self layoutItems]; + + CGRect blurFrame = CGRectMake(_showFromRight ? self.view.bounds.size.width : 0, 0, 0, self.view.bounds.size.height); + + self.blurView = [[UIImageView alloc] initWithImage:blurImage]; + self.blurView.frame = blurFrame; + self.blurView.contentMode = _showFromRight ? UIViewContentModeTopRight : UIViewContentModeTopLeft; + self.blurView.clipsToBounds = YES; + [self.view insertSubview:self.blurView belowSubview:self.contentView]; + + contentFrame.origin.x = _showFromRight ? parentWidth - _width : 0; + blurFrame.origin.x = contentFrame.origin.x; + blurFrame.size.width = _width; + + void (^animations)() = ^{ + self.contentView.frame = contentFrame; + self.blurView.frame = blurFrame; + }; + void (^completion)(BOOL) = ^(BOOL finished) { + if (finished && [self.delegate respondsToSelector:@selector(sidebar:didShowOnScreenAnimated:)]) { + [self.delegate sidebar:self didShowOnScreenAnimated:animated]; + } + }; + + if (animated) { + [UIView animateWithDuration:self.animationDuration + delay:0 + options:kNilOptions + animations:animations + completion:completion]; + } + else{ + animations(); + completion(YES); + } + + CGFloat initDelay = 0.1f; + SEL sdkSpringSelector = NSSelectorFromString(@"animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:"); + BOOL sdkHasSpringAnimation = [UIView respondsToSelector:sdkSpringSelector]; + + [self.itemViews enumerateObjectsUsingBlock:^(RNCalloutItemView *view, NSUInteger idx, BOOL *stop) { + view.layer.transform = CATransform3DMakeScale(0.3, 0.3, 1); + view.alpha = 0; + view.originalBackgroundColor = self.itemBackgroundColor; + view.layer.borderWidth = self.borderWidth; + + if (sdkHasSpringAnimation) { + [self animateSpringWithView:view idx:idx initDelay:initDelay]; + } + else { + [self animateFauxBounceWithView:view idx:idx initDelay:initDelay]; + } + }]; +} + +- (void)showAnimated:(BOOL)animated { + UIViewController *controller = [UIApplication sharedApplication].keyWindow.rootViewController; + while (controller.presentedViewController != nil) { + controller = controller.presentedViewController; + } + [self showInViewController:controller animated:animated]; +} + +- (void)show { + [self showAnimated:YES]; +} + +#pragma mark - Dismiss + +- (void)dismiss { + [self dismissAnimated:YES completion:nil]; +} + +- (void)dismissAnimated:(BOOL)animated { + [self dismissAnimated:animated completion:nil]; +} + +- (void)dismissAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion { + void (^completionBlock)(BOOL) = ^(BOOL finished){ + [self rn_removeFromParentViewControllerCallingAppearanceMethods:YES]; + + if ([self.delegate respondsToSelector:@selector(sidebar:didDismissFromScreenAnimated:)]) { + [self.delegate sidebar:self didDismissFromScreenAnimated:YES]; + } + + rn_frostedMenu = nil; + + if (completion) { + completion(finished); + } + }; + + if ([self.delegate respondsToSelector:@selector(sidebar:willDismissFromScreenAnimated:)]) { + [self.delegate sidebar:self willDismissFromScreenAnimated:YES]; + } + + if (animated) { + CGFloat parentWidth = self.view.bounds.size.width; + CGRect contentFrame = self.contentView.frame; + contentFrame.origin.x = self.showFromRight ? parentWidth : -_width; + + CGRect blurFrame = self.blurView.frame; + blurFrame.origin.x = self.showFromRight ? parentWidth : 0; + blurFrame.size.width = 0; + + [UIView animateWithDuration:self.animationDuration + delay:0 + options:UIViewAnimationOptionBeginFromCurrentState + animations:^{ + self.contentView.frame = contentFrame; + self.blurView.frame = blurFrame; + } + completion:completionBlock]; + } + else { + completionBlock(YES); + } +} + +#pragma mark - Gestures + +- (void)handleTap:(UITapGestureRecognizer *)recognizer { + CGPoint location = [recognizer locationInView:self.view]; + if (! CGRectContainsPoint(self.contentView.frame, location)) { + [self dismissAnimated:YES completion:nil]; + } + else { + NSInteger tapIndex = [self indexOfTap:[recognizer locationInView:self.contentView]]; + if (tapIndex != NSNotFound) { + [self didTapItemAtIndex:tapIndex]; + } + } +} + +#pragma mark - Private + +- (void)didTapItemAtIndex:(NSUInteger)index { + BOOL didEnable = ! [self.selectedIndices containsIndex:index]; + + if (self.borderColors) { + UIColor *stroke = self.borderColors[index]; + UIView *view = self.itemViews[index]; + + if (didEnable) { + if (_isSingleSelect){ + [self.selectedIndices removeAllIndexes]; + [self.itemViews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + UIView *aView = (UIView *)obj; + [[aView layer] setBorderColor:[[UIColor clearColor] CGColor]]; + }]; + } + view.layer.borderColor = stroke.CGColor; + + CABasicAnimation *borderAnimation = [CABasicAnimation animationWithKeyPath:@"borderColor"]; + borderAnimation.fromValue = (id)[UIColor clearColor].CGColor; + borderAnimation.toValue = (id)stroke.CGColor; + borderAnimation.duration = 0.5f; + [view.layer addAnimation:borderAnimation forKey:nil]; + + [self.selectedIndices addIndex:index]; + } + else { + if (!_isSingleSelect){ + view.layer.borderColor = [UIColor clearColor].CGColor; + [self.selectedIndices removeIndex:index]; + } + } + + CGRect pathFrame = CGRectMake(-CGRectGetMidX(view.bounds), -CGRectGetMidY(view.bounds), view.bounds.size.width, view.bounds.size.height); + UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:pathFrame cornerRadius:view.layer.cornerRadius]; + + // accounts for left/right offset and contentOffset of scroll view + CGPoint shapePosition = [self.view convertPoint:view.center fromView:self.contentView]; + + CAShapeLayer *circleShape = [CAShapeLayer layer]; + circleShape.path = path.CGPath; + circleShape.position = shapePosition; + circleShape.fillColor = [UIColor clearColor].CGColor; + circleShape.opacity = 0; + circleShape.strokeColor = stroke.CGColor; + circleShape.lineWidth = self.borderWidth; + + [self.view.layer addSublayer:circleShape]; + + CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; + scaleAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; + scaleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(2.5, 2.5, 1)]; + + CABasicAnimation *alphaAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; + alphaAnimation.fromValue = @1; + alphaAnimation.toValue = @0; + + CAAnimationGroup *animation = [CAAnimationGroup animation]; + animation.animations = @[scaleAnimation, alphaAnimation]; + animation.duration = 0.5f; + animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; + [circleShape addAnimation:animation forKey:nil]; + } + + if ([self.delegate respondsToSelector:@selector(sidebar:didTapItemAtIndex:)]) { + [self.delegate sidebar:self didTapItemAtIndex:index]; + } + if ([self.delegate respondsToSelector:@selector(sidebar:didEnable:itemAtIndex:)]) { + [self.delegate sidebar:self didEnable:didEnable itemAtIndex:index]; + } +} + +- (void)layoutSubviews { + CGFloat x = self.showFromRight ? self.parentViewController.view.bounds.size.width - _width : 0; + self.contentView.frame = CGRectMake(x, 0, _width, self.parentViewController.view.bounds.size.height); + self.blurView.frame = self.contentView.frame; + + [self layoutItems]; +} + +- (void)layoutItems { + CGFloat leftPadding = (self.width - self.itemSize.width)/2; + CGFloat topPadding = leftPadding; + [self.itemViews enumerateObjectsUsingBlock:^(RNCalloutItemView *view, NSUInteger idx, BOOL *stop) { + CGRect frame = CGRectMake(leftPadding, topPadding*idx + self.itemSize.height*idx + topPadding, self.itemSize.width, self.itemSize.height); + view.frame = frame; + view.layer.cornerRadius = frame.size.width/2.f; + }]; + + NSInteger items = [self.itemViews count]; + self.contentView.contentSize = CGSizeMake(0, items * (self.itemSize.height + topPadding) + topPadding); +} + +- (NSInteger)indexOfTap:(CGPoint)location { + __block NSUInteger index = NSNotFound; + + [self.itemViews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + if (CGRectContainsPoint(view.frame, location)) { + index = idx; + *stop = YES; + } + }]; + + return index; +} + +- (void)rn_addToParentViewController:(UIViewController *)parentViewController callingAppearanceMethods:(BOOL)callAppearanceMethods { + if (self.parentViewController != nil) { + [self rn_removeFromParentViewControllerCallingAppearanceMethods:callAppearanceMethods]; + } + + if (callAppearanceMethods) [self beginAppearanceTransition:YES animated:NO]; + [parentViewController addChildViewController:self]; + [parentViewController.view addSubview:self.view]; + [self didMoveToParentViewController:self]; + if (callAppearanceMethods) [self endAppearanceTransition]; +} + +- (void)rn_removeFromParentViewControllerCallingAppearanceMethods:(BOOL)callAppearanceMethods { + if (callAppearanceMethods) [self beginAppearanceTransition:NO animated:NO]; + [self willMoveToParentViewController:nil]; + [self.view removeFromSuperview]; + [self removeFromParentViewController]; + if (callAppearanceMethods) [self endAppearanceTransition]; +} + +@end