├── .gitignore ├── LICENSE ├── README.md ├── chapter_02 ├── 01_FirstAR │ ├── FirstAR.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── FirstAR │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.swift │ │ └── art.scnassets │ │ ├── ship.scn │ │ └── texture.png ├── 02_PlaneDetection │ ├── PlaneDetection.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── PlaneDetection │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── ViewController.swift ├── 03_VirtualObject │ ├── VirtualObject.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── VirtualObject │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── ViewController.swift ├── 04_DevMisc │ ├── ARKitDevMisc.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── ARKitDevMisc │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── ViewController.swift ├── 05_FeaturePoints │ ├── ARFeaturePoints.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── ARFeaturePoints │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── ViewController.swift ├── 06_ARInteraction │ ├── ARInteraction.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── ARInteraction │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.swift │ │ └── VirtualObjectNode.swift ├── 07_ARMeasure │ ├── ARMeasure.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── ARMeasure │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── ViewController.swift ├── 08_ARDrawing │ ├── ARDrawing.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── ARDrawing.xcworkspace │ │ └── contents.xcworkspacedata │ ├── ARDrawing │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── DynamicGeometry.swift │ │ ├── Info.plist │ │ └── ViewController.swift │ ├── Podfile │ ├── Podfile.lock │ └── Pods │ │ ├── ColorSlider │ │ ├── LICENSE.txt │ │ ├── README.md │ │ └── Sources │ │ │ └── ColorSlider.swift │ │ ├── Manifest.lock │ │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ │ └── Target Support Files │ │ ├── ColorSlider │ │ ├── ColorSlider-dummy.m │ │ ├── ColorSlider-prefix.pch │ │ ├── ColorSlider-umbrella.h │ │ ├── ColorSlider.modulemap │ │ ├── ColorSlider.xcconfig │ │ └── Info.plist │ │ └── Pods-ARDrawing │ │ ├── Info.plist │ │ ├── Pods-ARDrawing-acknowledgements.markdown │ │ ├── Pods-ARDrawing-acknowledgements.plist │ │ ├── Pods-ARDrawing-dummy.m │ │ ├── Pods-ARDrawing-frameworks.sh │ │ ├── Pods-ARDrawing-resources.sh │ │ ├── Pods-ARDrawing-umbrella.h │ │ ├── Pods-ARDrawing.debug.xcconfig │ │ ├── Pods-ARDrawing.modulemap │ │ └── Pods-ARDrawing.release.xcconfig ├── 09_ARObjectDetection │ ├── ARObjectDetection.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── ARObjectDetection │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── TagNode.swift │ │ └── ViewController.swift ├── common │ ├── ARPlaneAnchor+Visualize.swift │ ├── ARSampleCommon.swift │ ├── SceneKitUtils.swift │ └── TrackingState+Description.swift ├── mlmodels │ └── readme.md ├── models.scnassets │ └── duck │ │ ├── duck-license.txt │ │ ├── duck.scn │ │ └── textures │ │ └── duckCM.tga └── readme.md ├── chapter_03 └── samplecode │ ├── iOS │ ├── MenuPrediction │ │ ├── MenuPrediction.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── MenuPrediction.xcscheme │ │ └── MenuPrediction │ │ │ ├── AppDelegate.swift │ │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ ├── MenuPrediction.mlmodel │ │ │ └── ViewController.swift │ ├── RecChar │ │ ├── RecChar.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ └── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── RecChar.xcscheme │ │ └── RecChar │ │ │ ├── AppDelegate.swift │ │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ ├── KerasMNIST.mlmodel │ │ │ ├── MNISTLoader.swift │ │ │ ├── ViewController.swift │ │ │ ├── t10k-images-idx3-ubyte │ │ │ └── t10k-labels-idx1-ubyte │ └── UpdateModel │ │ ├── UpdateModel.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── UpdateModel.xcscheme │ │ └── UpdateModel │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── KerasMNIST.bin │ │ └── ViewController.swift │ ├── python │ ├── MachineLearning │ │ ├── .ipynb_checkpoints │ │ │ ├── MachineLearning-checkpoint.ipynb │ │ │ └── MenuPrediction-checkpoint.ipynb │ │ ├── MachineLearning.ipynb │ │ ├── cache │ │ │ ├── learningX.npy │ │ │ ├── learningY.npy │ │ │ ├── testX.npy │ │ │ └── testY.npy │ │ └── images │ │ │ └── .gitignore │ ├── MenuPrediction │ │ ├── MenuPrediction.ipynb │ │ ├── MenuPrediction.mlmodel │ │ ├── cache │ │ │ ├── sm_l.npy │ │ │ ├── sm_learnLabel.npy │ │ │ ├── sm_learnX.npy │ │ │ ├── sm_learnY.npy │ │ │ ├── sm_testLabel.npy │ │ │ ├── sm_testX.npy │ │ │ ├── sm_testY.npy │ │ │ ├── sm_x.npy │ │ │ └── sm_y.npy │ │ └── images │ │ │ └── .gitignore │ └── RecChar │ │ ├── ActivationFunction.ipynb │ │ ├── KerasMNIST.h5 │ │ ├── KerasMNIST.mlmodel │ │ └── RecChar.ipynb │ └── readme.md ├── chapter_08 └── iOS11ProgrammingAuthors │ ├── iOS11ProgrammingAuthors.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── iOS11ProgrammingAuthors │ ├── Controllers │ ├── AppDelegate.swift │ ├── AuthorListViewController.swift │ ├── BookViewController.swift │ └── CommencementTranscriptViewController.swift │ ├── Extensions │ └── UIStackView+beforeSpacing.swift │ ├── Info.plist │ ├── Resources │ └── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── book_cover.imageset │ │ ├── Contents.json │ │ └── book_cover.jpg │ │ ├── first.imageset │ │ ├── Contents.json │ │ └── first.pdf │ │ ├── ikeda.imageset │ │ ├── Contents.json │ │ └── ikeda.jpg │ │ ├── katou.imageset │ │ ├── Contents.json │ │ └── katou.png │ │ ├── kawanabe.imageset │ │ ├── Contents.json │ │ └── kawanabe.jpg │ │ ├── kishikawa.imageset │ │ ├── Contents.json │ │ └── kishikawa.jpg │ │ ├── nagano.imageset │ │ ├── Contents.json │ │ └── nagano.jpg │ │ ├── sakata.imageset │ │ ├── Contents.json │ │ └── sakata.png │ │ ├── tokoro.imageset │ │ ├── Contents.json │ │ └── tokoro.jpg │ │ ├── tsutsumi.imageset │ │ ├── Contents.json │ │ └── tsutsumi.jpg │ │ └── yoshida.imageset │ │ ├── Contents.json │ │ └── yoshida.png │ └── Views │ ├── AuthorListTableViewCell.swift │ └── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── chapter_10 ├── BookReader │ ├── .gitignore │ ├── BookReader.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── BookReader.xcscheme │ ├── BookReader │ │ ├── ActionMenuViewController.swift │ │ ├── AppDelegate.swift │ │ ├── AppearanceViewController.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── AppIcon-Notification.png │ │ │ │ ├── AppIcon-Notification@2x-1.png │ │ │ │ ├── AppIcon-Notification@2x.png │ │ │ │ ├── AppIcon-Notification@3x.png │ │ │ │ ├── AppIcon-Settings.png │ │ │ │ ├── AppIcon-Settings@2x-1.png │ │ │ │ ├── AppIcon-Settings@2x.png │ │ │ │ ├── AppIcon-Settings@3x.png │ │ │ │ ├── AppIcon-Spotlight.png │ │ │ │ ├── AppIcon-Spotlight@2x-1.png │ │ │ │ ├── AppIcon-Spotlight@2x.png │ │ │ │ ├── AppIcon-Spotlight@3x.png │ │ │ │ ├── AppIcon-iPad.png │ │ │ │ ├── AppIcon-iPad@2x.png │ │ │ │ ├── AppIcon-iPadPro@2x.png │ │ │ │ ├── AppIcon-iPhone@2x.png │ │ │ │ ├── AppIcon-iPhone@3x.png │ │ │ │ └── Contents.json │ │ │ ├── Bookmark-N.imageset │ │ │ │ ├── Bookmark-N.png │ │ │ │ ├── Bookmark-N@2x.png │ │ │ │ └── Contents.json │ │ │ ├── Bookmark-P.imageset │ │ │ │ ├── Bookmark-P.png │ │ │ │ ├── Bookmark-P@2x.png │ │ │ │ └── Contents.json │ │ │ ├── Brightness.imageset │ │ │ │ ├── Brightness.png │ │ │ │ ├── Brightness@2x.png │ │ │ │ └── Contents.json │ │ │ ├── BrightnessMax.imageset │ │ │ │ ├── BrightnessMax.png │ │ │ │ ├── BrightnessMax@2x.png │ │ │ │ └── Contents.json │ │ │ ├── BrightnessMin.imageset │ │ │ │ ├── BrightnessMin.png │ │ │ │ ├── BrightnessMin@2x.png │ │ │ │ └── Contents.json │ │ │ ├── Chevron.imageset │ │ │ │ ├── Chevron.png │ │ │ │ ├── Chevron@2x.png │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ ├── Grid.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── Grid.png │ │ │ │ └── Grid@2x.png │ │ │ ├── List.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── List.png │ │ │ │ └── List@2x.png │ │ │ ├── Search.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── Search.png │ │ │ │ └── Search@2x.png │ │ │ └── Share.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── Share.png │ │ │ │ └── Share@2x.png │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ ├── Main.storyboard │ │ │ ├── SearchResultsCell.xib │ │ │ └── ThumbnailGridCell.xib │ │ ├── BookViewController.swift │ │ ├── BookmarkViewController.swift │ │ ├── BookshelfCell.swift │ │ ├── BookshelfViewController.swift │ │ ├── Info.plist │ │ ├── OutlineCell.swift │ │ ├── OutlineViewController.swift │ │ ├── Sample.pdf │ │ ├── SearchResultsCell.swift │ │ ├── SearchViewController.swift │ │ ├── ThumbnailGridCell.swift │ │ └── ThumbnailGridViewController.swift │ ├── LICENSE │ ├── README.md │ └── Resources │ │ ├── 01_Reader.png │ │ ├── 02_Reader.png │ │ ├── 03_Thumbnail.png │ │ ├── 04_TOC.png │ │ ├── 05_OpenIn.png │ │ ├── 06_Search.png │ │ ├── 07_Search.png │ │ └── Icon.png └── PDFViewTweaks │ ├── PDFViewTweaks.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── PDFViewTweaks │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── PDFViewController.swift │ ├── ViewController.swift │ └── iOS11Programming.pdf ├── chapter_11 ├── MyQRCode │ ├── MyQRCode.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── MyQRCode.xcscheme │ │ │ ├── MyQRCodeKit.xcscheme │ │ │ └── MyQRCodeSiriKitExtension.xcscheme │ ├── MyQRCode │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── MyQRCode.entitlements │ │ ├── ViewController.swift │ │ └── VisualCodeViewController.swift │ ├── MyQRCodeKit │ │ ├── Info.plist │ │ ├── Me.swift │ │ ├── MyQRCodeKit.h │ │ └── Repository.swift │ └── MyQRCodeSiriKitExtension │ │ ├── Info.plist │ │ ├── IntentHandler.swift │ │ └── MyQRCodeSiriKitExtension.entitlements └── ToDo │ ├── ToDo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── ToDo.xcscheme │ │ ├── ToDoKit.xcscheme │ │ └── ToDoSiriKitExtension.xcscheme │ ├── ToDo │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── TaskListViewController.swift │ ├── TaskViewController.swift │ └── ToDo.entitlements │ ├── ToDoKit │ ├── Info.plist │ ├── Repository.swift │ ├── Task.swift │ ├── TaskList.swift │ └── ToDoKit.h │ └── ToDoSiriKitExtension │ ├── AddTasksHandler.swift │ ├── CreateTaskListHandler.swift │ ├── Info.plist │ ├── IntentHandler.swift │ ├── SetTaskAttributeHandler.swift │ └── ToDoSiriKitExtension.entitlements ├── chapter_12 └── HomeKitSample │ ├── .gitignore │ ├── .swiftlint.yml │ ├── App │ ├── Code │ │ ├── Controller │ │ │ ├── AccessoriesViewController.swift │ │ │ ├── AccessoryViewController.swift │ │ │ ├── ActionSetViewController.swift │ │ │ ├── ActionSetsViewController.swift │ │ │ ├── ActionsViewController.swift │ │ │ ├── AppDelegate.swift │ │ │ ├── CameraProfileViewController.swift │ │ │ ├── CharacteristicMetadataFormatsViewController.swift │ │ │ ├── CharacteristicMetadataUnitsViewController.swift │ │ │ ├── CharacteristicViewController.swift │ │ │ ├── CharacteristicWriteActionViewController.swift │ │ │ ├── CharacteristicsViewController.swift │ │ │ ├── CreateEventTriggerViewController.swift │ │ │ ├── CreateTimerTriggerViewController.swift │ │ │ ├── CreateTriggerViewController.swift │ │ │ ├── DatePickerController.swift │ │ │ ├── EventTriggerViewController.swift │ │ │ ├── EventViewController.swift │ │ │ ├── EventsViewController.swift │ │ │ ├── HomeViewController.swift │ │ │ ├── HomesViewController.swift │ │ │ ├── MainMenuViewController.swift │ │ │ ├── ProfilesViewController.swift │ │ │ ├── RoomViewController.swift │ │ │ ├── RoomsViewController.swift │ │ │ ├── SandBoxViewController.swift │ │ │ ├── ServiceGroupViewController.swift │ │ │ ├── ServiceGroupsViewController.swift │ │ │ ├── ServiceTypesViewController.swift │ │ │ ├── ServiceViewController.swift │ │ │ ├── ServicesViewController.swift │ │ │ ├── TimerTriggerViewController.swift │ │ │ ├── TriggerViewController.swift │ │ │ ├── TriggersViewController.swift │ │ │ ├── ZoneViewController.swift │ │ │ └── ZonesViewController.swift │ │ ├── Extension │ │ │ └── SafeCollection.swift │ │ ├── Lib │ │ │ ├── HasAssociatedObjects │ │ │ │ └── HasAssociatedObjects.swift │ │ │ ├── HomeKitUtils │ │ │ │ ├── AccessoryCategoryType.swift │ │ │ │ ├── ActionSetType.swift │ │ │ │ ├── CharacteristicMetadataFormat.swift │ │ │ │ ├── CharacteristicMetadataUnits.swift │ │ │ │ ├── CharacteristicType.swift │ │ │ │ ├── HMAccessory+Utils.swift │ │ │ │ ├── HMActionSet+Utils.swift │ │ │ │ ├── HMCameraAudioStreamSetting+Description.swift │ │ │ │ ├── HMCameraStreamState+Description.swift │ │ │ │ ├── HMCharacteristic+Utils.swift │ │ │ │ ├── HMEventTriggerActivationState+Description.swift │ │ │ │ ├── HMHome+Utils.swift │ │ │ │ ├── HMHomeHubState+Description.swift │ │ │ │ ├── HMHomeManager+Utils.swift │ │ │ │ ├── HMRoom+Utils.swift │ │ │ │ ├── HMServiceGroup+Utils.swift │ │ │ │ ├── HMTrigger+Utils.swift │ │ │ │ ├── HMZone+Utils.swift │ │ │ │ └── ServiceType.swift │ │ │ ├── ResponderChain │ │ │ │ └── ResponderChain.swift │ │ │ └── SegueContext │ │ │ │ ├── SegueCallback.swift │ │ │ │ └── SegueContext.swift │ │ └── Protocol │ │ │ ├── AccessoryActionHandler.swift │ │ │ ├── AccessorySelector.swift │ │ │ ├── AccessoryStore.swift │ │ │ ├── ActionActionHandler.swift │ │ │ ├── ActionSelector.swift │ │ │ ├── ActionSetActionHandler.swift │ │ │ ├── ActionSetSelector.swift │ │ │ ├── ActionSetStore.swift │ │ │ ├── ActionStore.swift │ │ │ ├── CharacteristicSelector.swift │ │ │ ├── CharacteristicStore.swift │ │ │ ├── HomeActionHandler.swift │ │ │ ├── RoomActionHandler.swift │ │ │ ├── RoomSelector.swift │ │ │ ├── RoomStore.swift │ │ │ ├── ServiceActionHandler.swift │ │ │ ├── ServiceGroupActionHandler.swift │ │ │ ├── ServiceSelector.swift │ │ │ ├── ServiceStore.swift │ │ │ ├── TriggerActionHandler.swift │ │ │ ├── TriggerSelector.swift │ │ │ └── ZoneActionHandler.swift │ ├── HomeKitSample.entitlements │ ├── Info.plist │ └── Resource │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── Image.imageset │ │ │ └── Contents.json │ │ └── Storyboard │ │ ├── Accessory.storyboard │ │ ├── Action.storyboard │ │ ├── ActionSet.storyboard │ │ ├── CameraProfile.storyboard │ │ ├── Characteristic.storyboard │ │ ├── CharacteristicMetadataFormat.storyboard │ │ ├── CharacteristicMetadataUnits.storyboard │ │ ├── CreateCharacteristicWriteAction.storyboard │ │ ├── CreateEventTrigger.storyboard │ │ ├── CreateTimerTrigger.storyboard │ │ ├── DatePicker.storyboard │ │ ├── Event.storyboard │ │ ├── Home.storyboard │ │ ├── LaunchScreen.storyboard │ │ ├── Main.storyboard │ │ ├── Profile.storyboard │ │ ├── Room.storyboard │ │ ├── SandBox.storyboard │ │ ├── SelectAccessory.storyboard │ │ ├── SelectActionSet.storyboard │ │ ├── SelectRoom.storyboard │ │ ├── SelectService.storyboard │ │ ├── Service.storyboard │ │ ├── ServiceGroup.storyboard │ │ ├── ServiceType.storyboard │ │ ├── Trigger.storyboard │ │ └── Zone.storyboard │ └── HomeKitSample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ └── contents.xcworkspacedata ├── chapter_13 ├── 01_MetalImageRender │ ├── MetalImageRender.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── MetalImageRender │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── highsierra.imageset │ │ │ ├── Contents.json │ │ │ └── highsierra@3x.jpg │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── ViewController.swift │ │ └── highsierra@3x.jpg ├── 02_MetalShaderColorFill │ ├── MetalShaderColorFill.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── MetalShaderColorFill │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── Shaders.metal │ │ ├── ViewController.swift │ │ └── highsierra@3x.jpg ├── 03_MetalShaderImageRender │ ├── MetalShaderImageRender.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── MetalShaderImageRender │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── highsierra.imageset │ │ │ ├── Contents.json │ │ │ └── highsierra@3x.jpg │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── Shaders.metal │ │ ├── ViewController.swift │ │ └── highsierra@3x.jpg ├── 04_ARMetal1 │ ├── ARMetal │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── SampleShaders.metal │ │ └── ViewController.swift │ └── ARMetal1.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── 05_ARMetal2 │ ├── ARMetal │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── MetalRenderView.swift │ │ ├── Shaders.metal │ │ └── ViewController.swift │ └── ARMetal2.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── 06_ARMetalArgumentBuffers │ ├── ARMetalArgumentBuffers.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ └── ARMetalArgumentBuffers │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ ├── MetalRenderView.swift │ │ ├── Shaders.metal │ │ └── ViewController.swift ├── common │ ├── ARPlaneAnchor+Visualize.swift │ ├── ARSampleCommon.swift │ ├── SceneKitUtils.swift │ └── TrackingState+Description.swift └── models.scnassets │ └── duck │ ├── duck-license.txt │ ├── duck.scn │ └── textures │ └── duckCM.tga └── chapter_14 ├── AVAudioEnginePlayWithReverb.playground ├── Contents.swift ├── Resources │ └── source.caf └── contents.xcplayground ├── AirPlay2 ├── AirPlay2Test.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── AirPlay2Test │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── SampleBufferAudioPlayer.swift │ ├── ViewController.swift │ └── source.caf ├── AirPlay2TestTests │ ├── AirPlay2TestTests.swift │ └── Info.plist └── AirPlay2TestUITests │ ├── AirPlay2TestUITests.swift │ └── Info.plist ├── AirPlay2_with_AVAudioEngine ├── AirPlay2Test.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── AirPlay2Test │ ├── AirPlay2Test-Bridging-Header.h │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── SampleBufferAudioPlayer.swift │ ├── ViewController.swift │ ├── mixLoop.caf │ └── podcast #012.m4a ├── AirPlay2TestTests │ ├── AirPlay2TestTests.swift │ └── Info.plist └── AirPlay2TestUITests │ ├── AirPlay2TestUITests.swift │ └── Info.plist └── AudioEngineManualRendering.playground ├── Contents.swift ├── Resources └── source.caf └── contents.xcplayground /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | .gitignore~ 6 | .DS_Store 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xccheckout 25 | *.xcscmblueprint 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | .build/ 43 | 44 | # CocoaPods 45 | # 46 | # We recommend against adding the Pods directory to your .gitignore. However 47 | # you should judge for yourself, the pros and cons are mentioned at: 48 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 49 | # 50 | # Pods/ 51 | 52 | # Carthage 53 | # 54 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 55 | # Carthage/Checkouts 56 | 57 | Carthage/Build 58 | 59 | # fastlane 60 | # 61 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 62 | # screenshots whenever they are needed. 63 | # For more information about the recommended setup visit: 64 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 65 | 66 | fastlane/report.xml 67 | fastlane/Preview.html 68 | fastlane/screenshots 69 | fastlane/test_output 70 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 peaks-cc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS 11 Programmingのサンプルコード 2 | 3 | 4 | [「iOS 11 Programming販売ページ 」](https://peaks.cc/books/iOS11) 5 | 6 | [![](https://s3-ap-northeast-1.amazonaws.com/peaks-images/ios11_book_cover_medium.jpg)](https://peaks.cc/books/iOS11) 7 | -------------------------------------------------------------------------------- /chapter_02/01_FirstAR/FirstAR.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/01_FirstAR/FirstAR/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // FirstAR 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_02/01_FirstAR/FirstAR/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter_02/01_FirstAR/FirstAR/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // FirstAR 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ARKit 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet var sceneView: ARSCNView! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | // シーンを生成してARSCNViewにセット 20 | sceneView.scene = SCNScene(named: "art.scnassets/ship.scn")! 21 | 22 | // セッションのコンフィギュレーションを生成 23 | let configuration = ARWorldTrackingConfiguration() 24 | 25 | // セッション開始 26 | sceneView.session.run(configuration) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /chapter_02/01_FirstAR/FirstAR/art.scnassets/ship.scn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_02/01_FirstAR/FirstAR/art.scnassets/ship.scn -------------------------------------------------------------------------------- /chapter_02/01_FirstAR/FirstAR/art.scnassets/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_02/01_FirstAR/FirstAR/art.scnassets/texture.png -------------------------------------------------------------------------------- /chapter_02/02_PlaneDetection/PlaneDetection.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/02_PlaneDetection/PlaneDetection/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PlaneDetetion 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_02/03_VirtualObject/VirtualObject.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/03_VirtualObject/VirtualObject/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PlaneDetetion 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_02/04_DevMisc/ARKitDevMisc.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/04_DevMisc/ARKitDevMisc/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARDebug 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_02/05_FeaturePoints/ARFeaturePoints.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/05_FeaturePoints/ARFeaturePoints/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARTapeMeasure 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /chapter_02/06_ARInteraction/ARInteraction.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/06_ARInteraction/ARInteraction/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARInteraction 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_02/06_ARInteraction/ARInteraction/VirtualObjectNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VirtualObjectNode.swift 3 | // ARInteraction 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/09/13. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import ARKit 10 | 11 | class VirtualObjectNode: SCNNode { 12 | 13 | init(anchorId: UUID) { 14 | self.anchorId = anchorId 15 | super.init() 16 | } 17 | 18 | required init?(coder aDecoder: NSCoder) { 19 | fatalError("init(coder:) has not been implemented") 20 | } 21 | 22 | let anchorId: UUID 23 | } 24 | -------------------------------------------------------------------------------- /chapter_02/07_ARMeasure/ARMeasure.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/07_ARMeasure/ARMeasure/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARTapeMeasure 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/ARDrawing.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/ARDrawing.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/ARDrawing/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARTapeMeasure 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '11.0' 2 | 3 | target 'ARDrawing' do 4 | use_frameworks! 5 | 6 | pod 'ColorSlider' 7 | 8 | end 9 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ColorSlider (3.0.1) 3 | 4 | DEPENDENCIES: 5 | - ColorSlider 6 | 7 | SPEC CHECKSUMS: 8 | ColorSlider: fe0a511351837848076c30417522ab175ab8fea9 9 | 10 | PODFILE CHECKSUM: 662245b6f8fd1d83667edaecc484ae0ea9f85480 11 | 12 | COCOAPODS: 1.3.1 13 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/ColorSlider/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-Present Sachin Patel (http://gizmosachin.com/) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ColorSlider (3.0.1) 3 | 4 | DEPENDENCIES: 5 | - ColorSlider 6 | 7 | SPEC CHECKSUMS: 8 | ColorSlider: fe0a511351837848076c30417522ab175ab8fea9 9 | 10 | PODFILE CHECKSUM: 662245b6f8fd1d83667edaecc484ae0ea9f85480 11 | 12 | COCOAPODS: 1.3.1 13 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/ColorSlider/ColorSlider-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_ColorSlider : NSObject 3 | @end 4 | @implementation PodsDummy_ColorSlider 5 | @end 6 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/ColorSlider/ColorSlider-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/ColorSlider/ColorSlider-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double ColorSliderVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char ColorSliderVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/ColorSlider/ColorSlider.modulemap: -------------------------------------------------------------------------------- 1 | framework module ColorSlider { 2 | umbrella header "ColorSlider-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/ColorSlider/ColorSlider.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/ColorSlider 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_LDFLAGS = -framework "CoreGraphics" -framework "Foundation" -framework "QuartzCore" -framework "UIKit" 5 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/ColorSlider 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/ColorSlider/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 3.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/Pods-ARDrawing/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/Pods-ARDrawing/Pods-ARDrawing-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## ColorSlider 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2016-Present Sachin Patel (http://gizmosachin.com/) 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | Generated by CocoaPods - https://cocoapods.org 29 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/Pods-ARDrawing/Pods-ARDrawing-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ARDrawing : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ARDrawing 5 | @end 6 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/Pods-ARDrawing/Pods-ARDrawing-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_ARDrawingVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_ARDrawingVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/Pods-ARDrawing/Pods-ARDrawing.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/ColorSlider" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ColorSlider/ColorSlider.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "ColorSlider" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/Pods-ARDrawing/Pods-ARDrawing.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ARDrawing { 2 | umbrella header "Pods-ARDrawing-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /chapter_02/08_ARDrawing/Pods/Target Support Files/Pods-ARDrawing/Pods-ARDrawing.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/ColorSlider" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ColorSlider/ColorSlider.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "ColorSlider" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /chapter_02/09_ARObjectDetection/ARObjectDetection.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_02/09_ARObjectDetection/ARObjectDetection/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARInteraction 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_02/09_ARObjectDetection/ARObjectDetection/TagNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TagAnchor.swift 3 | // ARObjectDetection 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/09/07. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import SceneKit 10 | import Vision 11 | 12 | class TagNode: SCNNode { 13 | 14 | var classificationObservation: VNClassificationObservation? { 15 | didSet { 16 | addTextNode() 17 | } 18 | } 19 | 20 | private func addTextNode() { 21 | guard let text = classificationObservation?.identifier else {return} 22 | let shorten = text.components(separatedBy: ", ").first! 23 | let textNode = SCNNode.textNode(text: shorten) 24 | DispatchQueue.main.async(execute: { 25 | self.addChildNode(textNode) 26 | }) 27 | addSphereNode(color: UIColor.green) 28 | } 29 | 30 | private func addSphereNode(color: UIColor) { 31 | DispatchQueue.main.async(execute: { 32 | let sphereNode = SCNNode.sphereNode(color: color) 33 | self.addChildNode(sphereNode) 34 | }) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /chapter_02/common/SceneKitUtils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneKitUtils.swift 3 | // 4 | // Created by Shuichi Tsutsumi on 2017/09/04. 5 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 6 | // 7 | 8 | import SceneKit 9 | 10 | func + (left: SCNVector3, right: SCNVector3) -> SCNVector3 { 11 | return SCNVector3Make(left.x + right.x, left.y + right.y, left.z + right.z) 12 | } 13 | 14 | func += (left: inout SCNVector3, right: SCNVector3) { 15 | left = left + right 16 | } 17 | 18 | func - (left: SCNVector3, right: SCNVector3) -> SCNVector3 { 19 | return SCNVector3Make(left.x - right.x, left.y - right.y, left.z - right.z) 20 | } 21 | 22 | func * (vector: SCNVector3, scalar: Float) -> SCNVector3 { 23 | return SCNVector3Make(vector.x * scalar, vector.y * scalar, vector.z * scalar) 24 | } 25 | 26 | func / (left: SCNVector3, right: Float) -> SCNVector3 { 27 | return SCNVector3Make(left.x / right, left.y / right, left.z / right) 28 | } 29 | 30 | func /= (left: inout SCNVector3, right: Float) { 31 | left = left / right 32 | } 33 | 34 | extension SCNVector3 { 35 | func length() -> Float { 36 | return sqrtf(x * x + y * y + z * z) 37 | } 38 | } 39 | 40 | extension matrix_float4x4 { 41 | func position() -> SCNVector3 { 42 | let mat = SCNMatrix4(self) 43 | return SCNVector3(mat.m41, mat.m42, mat.m43) 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /chapter_02/common/TrackingState+Description.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TrackingState+Description.swift 3 | // 4 | // Created by Shuichi Tsutsumi on 2017/08/25. 5 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 6 | // 7 | 8 | import ARKit 9 | 10 | extension ARCamera.TrackingState { 11 | public var description: String { 12 | switch self { 13 | case .notAvailable: 14 | return "TRACKING UNAVAILABLE" 15 | case .normal: 16 | return "TRACKING NORMAL" 17 | case .limited(let reason): 18 | switch reason { 19 | case .excessiveMotion: 20 | return "TRACKING LIMITED\nToo much camera movement" 21 | case .insufficientFeatures: 22 | return "TRACKING LIMITED\nNot enough surface detail" 23 | case .initializing: 24 | return "Tracking LIMITED\nInitialization in progress." 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /chapter_02/mlmodels/readme.md: -------------------------------------------------------------------------------- 1 | https://developer.apple.com/machine-learning/ 2 | 3 | から`Inceptionv3.mlmodel`をダウンロードし、ここに置いてください 4 | -------------------------------------------------------------------------------- /chapter_02/models.scnassets/duck/duck-license.txt: -------------------------------------------------------------------------------- 1 | ---UPDATED 2/21/2007 2 | Scaled down the duck to a more reasonable size, removed physics scene, removed extra "dummy" transforms and pivot points, added camera and light. 3 | --- 4 | 5 | This model is a typical bathtub rubber duck. It uses a single texture. 6 | 7 | One version uses a polylist the other is triangles only. 8 | 9 | The model has been stripped of all tags and should be COLLADA 1.4.1 compliant. 10 | 11 | For additional information post messages on www.collada.org or mail collada@collada.org 12 | 13 | These models are Copyright 2006 Sony Computer Entertainment Inc. and are distributed under the terms of the SCEA Shared Source License, available at http://research.scea.com/scea_shared_source_license.html -------------------------------------------------------------------------------- /chapter_02/models.scnassets/duck/duck.scn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_02/models.scnassets/duck/duck.scn -------------------------------------------------------------------------------- /chapter_02/models.scnassets/duck/textures/duckCM.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_02/models.scnassets/duck/textures/duckCM.tga -------------------------------------------------------------------------------- /chapter_02/readme.md: -------------------------------------------------------------------------------- 1 | 一部サンプルはモデルファイルのダウンロードが必要です。 2 | 3 | `mlmodels/readme.md` を参照してください。 -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/MenuPrediction/MenuPrediction.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/MenuPrediction/MenuPrediction/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/MenuPrediction/MenuPrediction/MenuPrediction.mlmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/iOS/MenuPrediction/MenuPrediction/MenuPrediction.mlmodel -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/MenuPrediction/MenuPrediction/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // MenuPrediction 4 | // 5 | // Created by sonson on 2017/08/04. 6 | // Copyright © 2017年 sonson. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreML 11 | 12 | class ViewController: UIViewController { 13 | let model = MenuPrediction() 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | // Do any additional setup after loading the view, typically from a nib. 18 | do { 19 | let x1 = Double(18); 20 | let x2 = x1 * x1; 21 | let x3 = x1 * x1 * x1; 22 | let result = try model.prediction(x1: x1, x2: x2, x3: x3) 23 | print(result) 24 | print(result.label) 25 | print(result.classProbability) 26 | } catch { 27 | print(error) 28 | } 29 | } 30 | 31 | override func didReceiveMemoryWarning() { 32 | super.didReceiveMemoryWarning() 33 | // Dispose of any resources that can be recreated. 34 | } 35 | 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/RecChar/RecChar.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/RecChar/RecChar/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/RecChar/RecChar/KerasMNIST.mlmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/iOS/RecChar/RecChar/KerasMNIST.mlmodel -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/RecChar/RecChar/t10k-images-idx3-ubyte: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/iOS/RecChar/RecChar/t10k-images-idx3-ubyte -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/UpdateModel/UpdateModel.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/UpdateModel/UpdateModel/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/UpdateModel/UpdateModel/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/UpdateModel/UpdateModel/KerasMNIST.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/iOS/UpdateModel/UpdateModel/KerasMNIST.bin -------------------------------------------------------------------------------- /chapter_03/samplecode/iOS/UpdateModel/UpdateModel/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // UpdateModel 4 | // 5 | // Created by sonson on 2017/09/18. 6 | // Copyright © 2017年 sonson. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CoreML 11 | 12 | class ViewController: UIViewController { 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | // Do any additional setup after loading the view, typically from a nib. 17 | 18 | do { 19 | guard let url = Bundle.main.url(forResource: "KerasMNIST", withExtension: "bin") else { return } 20 | let compiledURL = try MLModel.compileModel(at: url) 21 | print(compiledURL) 22 | 23 | let model = try MLModel(contentsOf: compiledURL) 24 | print(model) 25 | } catch { 26 | print(error) 27 | } 28 | 29 | } 30 | 31 | override func didReceiveMemoryWarning() { 32 | super.didReceiveMemoryWarning() 33 | // Dispose of any resources that can be recreated. 34 | } 35 | 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MachineLearning/cache/learningX.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MachineLearning/cache/learningX.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MachineLearning/cache/learningY.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MachineLearning/cache/learningY.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MachineLearning/cache/testX.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MachineLearning/cache/testX.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MachineLearning/cache/testY.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MachineLearning/cache/testY.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MachineLearning/images/.gitignore: -------------------------------------------------------------------------------- 1 | *.eps 2 | *.png 3 | -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/MenuPrediction.mlmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/MenuPrediction.mlmodel -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_l.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_l.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_learnLabel.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_learnLabel.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_learnX.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_learnX.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_learnY.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_learnY.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_testLabel.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_testLabel.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_testX.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_testX.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_testY.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_testY.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_x.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_x.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/cache/sm_y.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/MenuPrediction/cache/sm_y.npy -------------------------------------------------------------------------------- /chapter_03/samplecode/python/MenuPrediction/images/.gitignore: -------------------------------------------------------------------------------- 1 | *.eps 2 | *.png 3 | -------------------------------------------------------------------------------- /chapter_03/samplecode/python/RecChar/KerasMNIST.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/RecChar/KerasMNIST.h5 -------------------------------------------------------------------------------- /chapter_03/samplecode/python/RecChar/KerasMNIST.mlmodel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_03/samplecode/python/RecChar/KerasMNIST.mlmodel -------------------------------------------------------------------------------- /chapter_03/samplecode/readme.md: -------------------------------------------------------------------------------- 1 | ## 概要 2 | 3 | Pythonのコードは,すべてのJupyter Notebook向けに書いています. 4 | このため,Pythonのコードを動作させるためにまず,Jupyter Notebookをインストールしてください. 5 | 6 | ## Core ML Tools インストール 7 | 8 | `pip`でまずCore ML Toolsをインストールする. 9 | 10 | ``` 11 | pip install -U coremltools 12 | ``` 13 | 14 | # Jupyter Notebook(for Mac) 15 | 16 | Linuxの場合は,そのまま,パッケージマネージャでインストールするとよいと思います. 17 | 18 | 19 | 20 | ### 日本語フォントのためにライブラリをインストールする 21 | 22 | [https://gcc.gnu.org/wiki/GFortranBinaries](https://gcc.gnu.org/wiki/GFortranBinaries)から,gfortranをセットします. 23 | 次に,freetypeをbrewでインストールします. 24 | 25 | ``` 26 | brew install freetype 27 | ``` 28 | 29 | ### Jupyter Notebookのインストール 30 | 31 | ``` 32 | pip install scikit-learn numpy scipy matplotlib cython jupyter 33 | ``` 34 | 35 | 36 | ### 日本語フォント 37 | 38 | Jupyter Notebookで日本語を表示するために,IPAフォントをセットアップします. 39 | フォントは,[ここ](https://ja.osdn.net/projects/ipafonts/releases/47610)からダウンロードし,`~/Library/Fonts/`にコピーしてください. 40 | これでJupyter Notebookで日本語がレンダリングできるはずです.うまくいかないときは,`~/.matplotlib/fontList.cache`を削除して,Jupyter Notebookをリロードするとよいです. 41 | 42 | -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Controllers/BookViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BookViewController.swift 3 | // iOS11ProgrammingAuthors 4 | // 5 | // Created by Yusuke Kawanabe on 7/18/17. 6 | // Copyright © 2017 Yusuke Kawanabe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BookViewController: UIViewController { 12 | @IBOutlet weak var detailLabel: UILabel! 13 | 14 | @IBOutlet var additionalView: UIView! 15 | @IBOutlet weak var stackView: UIStackView! 16 | @IBOutlet weak var bookImageView: UIImageView! 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | let bodyFont = UIFontMetrics.default.scaledFont(for: UIFont(name: "HiraKakuProN-W6", size: 14)!) 21 | detailLabel.font = bodyFont 22 | 23 | configureStackViewSpacing() 24 | } 25 | 26 | private func configureStackViewSpacing() { 27 | stackView.setCustomSpacing(30, after: bookImageView) 28 | } 29 | 30 | private func showAdditionalView() { 31 | additionalView.frame = view.frame 32 | view.addSubview(additionalView) 33 | } 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Controllers/CommencementTranscriptViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CommencementTranscriptViewController.swift 3 | // iOS11ProgrammingAuthors 4 | // 5 | // Created by Yusuke Kawanabe on 8/19/17. 6 | // Copyright © 2017 Yusuke Kawanabe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CommencementTranscriptViewController: UIViewController { 12 | 13 | @IBOutlet var transcriptLabel: UILabel! 14 | @IBOutlet weak var scrollView: UIScrollView! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | scrollView.addSubview(transcriptLabel) 20 | transcriptLabel.translatesAutoresizingMaskIntoConstraints = false 21 | NSLayoutConstraint.activate([ 22 | scrollView.layoutMarginsGuide.leadingAnchor.constraint(equalTo: transcriptLabel.leadingAnchor), 23 | scrollView.layoutMarginsGuide.trailingAnchor.constraint(equalTo: transcriptLabel.trailingAnchor), 24 | scrollView.contentLayoutGuide.topAnchor.constraint(equalTo: transcriptLabel.topAnchor), 25 | scrollView.contentLayoutGuide.bottomAnchor.constraint(equalTo: transcriptLabel.bottomAnchor) 26 | ]) 27 | 28 | let titleLabel = UILabel() 29 | titleLabel.text = "Steve Jobs" 30 | titleLabel.translatesAutoresizingMaskIntoConstraints = false 31 | scrollView.addSubview(titleLabel) 32 | 33 | NSLayoutConstraint.activate([ 34 | scrollView.frameLayoutGuide.trailingAnchor.constraint(equalTo: titleLabel.trailingAnchor), 35 | scrollView.safeAreaLayoutGuide.topAnchor.constraint(equalTo: titleLabel.topAnchor) 36 | ]) 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Extensions/UIStackView+beforeSpacing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIStackView+beforeSpacing.swift 3 | // iOS11ProgrammingAuthors 4 | // 5 | // Created by Yusuke Kawanabe on 8/27/17. 6 | // Copyright © 2017 Yusuke Kawanabe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIStackView { 12 | func setCustomSpacing(_ spacing: CGFloat, before arrangedSubview: UIView) { 13 | let index = self.subviews.index(of: arrangedSubview) 14 | if let index = index, 15 | index > 1 { 16 | let view = self.subviews[index - 1] 17 | self.setCustomSpacing(12, after: view) 18 | } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/book_cover.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "book_cover.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/book_cover.imageset/book_cover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/book_cover.imageset/book_cover.jpg -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/first.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "first.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/first.imageset/first.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/first.imageset/first.pdf -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/ikeda.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ikeda.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/ikeda.imageset/ikeda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/ikeda.imageset/ikeda.jpg -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/katou.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "katou.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/katou.imageset/katou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/katou.imageset/katou.png -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/kawanabe.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "kawanabe.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | }, 21 | "properties" : { 22 | "preserves-vector-representation" : true 23 | } 24 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/kawanabe.imageset/kawanabe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/kawanabe.imageset/kawanabe.jpg -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/kishikawa.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "kishikawa.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/kishikawa.imageset/kishikawa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/kishikawa.imageset/kishikawa.jpg -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/nagano.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "nagano.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/nagano.imageset/nagano.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/nagano.imageset/nagano.jpg -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/sakata.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "sakata.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/sakata.imageset/sakata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/sakata.imageset/sakata.png -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/tokoro.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tokoro.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/tokoro.imageset/tokoro.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/tokoro.imageset/tokoro.jpg -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/tsutsumi.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "tsutsumi.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/tsutsumi.imageset/tsutsumi.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/tsutsumi.imageset/tsutsumi.jpg -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/yoshida.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "yoshida.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/yoshida.imageset/yoshida.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Resources/Assets.xcassets/yoshida.imageset/yoshida.png -------------------------------------------------------------------------------- /chapter_08/iOS11ProgrammingAuthors/iOS11ProgrammingAuthors/Views/AuthorListTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AuthorListTableViewCell.swift 3 | // iOS11ProgrammingAuthors 4 | // 5 | // Created by Yusuke Kawanabe on 8/21/17. 6 | // Copyright © 2017 Yusuke Kawanabe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class AuthorListTableViewCell: UITableViewCell { 12 | 13 | @IBOutlet weak var profileImageView: UIImageView! 14 | @IBOutlet weak var titleLabel: UILabel! 15 | 16 | func configure(with author: Author) { 17 | let name = "\(author.name) (\(author.twitter))" 18 | let title = author.isFavorite ? "⭐️" + name : name 19 | titleLabel.text = title 20 | profileImageView.image = author.image 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /chapter_10/BookReader/.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/ActionMenuViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionMenuViewController.swift 3 | // BookReader 4 | // 5 | // Created by Kishikawa Katsumi on 2017/07/04. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ActionMenuViewController: UITableViewController { 12 | weak var delegate: ActionMenuViewControllerDelegate? 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | tableView.isScrollEnabled = false 17 | tableView.separatorInset = .zero 18 | } 19 | 20 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 21 | if indexPath.row == 0 { 22 | delegate?.actionMenuViewControllerShareDocument(self) 23 | } else if indexPath.row == 1 { 24 | delegate?.actionMenuViewControllerPrintDocument(self) 25 | } 26 | tableView.deselectRow(at: indexPath, animated: true) 27 | } 28 | } 29 | 30 | protocol ActionMenuViewControllerDelegate: class { 31 | func actionMenuViewControllerShareDocument(_ actionMenuViewController: ActionMenuViewController) 32 | func actionMenuViewControllerPrintDocument(_ actionMenuViewController: ActionMenuViewController) 33 | } 34 | -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/AppearanceViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppearanceViewController.swift 3 | // BookReader 4 | // 5 | // Created by Kishikawa Katsumi on 2017/07/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class AppearanceViewController: UIViewController { 12 | @IBOutlet weak var brightnessSlider: UISlider! 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | brightnessSlider.value = Float(UIScreen.main.brightness) 17 | brightnessSlider.addTarget(self, action: #selector(sliderValueChanged(_:)), for: .valueChanged) 18 | } 19 | 20 | @objc func sliderValueChanged(_ sender: UISlider) { 21 | UIScreen.main.brightness = CGFloat(brightnessSlider.value) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Notification.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Notification@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Notification@2x-1.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Notification@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Notification@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Notification@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Notification@3x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Settings.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Settings@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Settings@2x-1.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Settings@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Settings@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Settings@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Settings@3x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Spotlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Spotlight.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Spotlight@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Spotlight@2x-1.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Spotlight@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Spotlight@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Spotlight@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-Spotlight@3x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPad.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPad@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPadPro@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPadPro@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPhone@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPhone@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPhone@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/AppIcon.appiconset/AppIcon-iPhone@3x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-N.imageset/Bookmark-N.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-N.imageset/Bookmark-N.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-N.imageset/Bookmark-N@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-N.imageset/Bookmark-N@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-N.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Bookmark-N.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Bookmark-N@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-P.imageset/Bookmark-P.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-P.imageset/Bookmark-P.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-P.imageset/Bookmark-P@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-P.imageset/Bookmark-P@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Bookmark-P.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Bookmark-P.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Bookmark-P@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Brightness.imageset/Brightness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Brightness.imageset/Brightness.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Brightness.imageset/Brightness@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Brightness.imageset/Brightness@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Brightness.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Brightness.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Brightness@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMax.imageset/BrightnessMax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMax.imageset/BrightnessMax.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMax.imageset/BrightnessMax@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMax.imageset/BrightnessMax@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMax.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "BrightnessMax.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "BrightnessMax@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMin.imageset/BrightnessMin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMin.imageset/BrightnessMin.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMin.imageset/BrightnessMin@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMin.imageset/BrightnessMin@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/BrightnessMin.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "BrightnessMin.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "BrightnessMin@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Chevron.imageset/Chevron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Chevron.imageset/Chevron.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Chevron.imageset/Chevron@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Chevron.imageset/Chevron@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Chevron.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Chevron.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Chevron@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Grid.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Grid.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Grid@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Grid.imageset/Grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Grid.imageset/Grid.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Grid.imageset/Grid@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Grid.imageset/Grid@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/List.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "List.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "List@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/List.imageset/List.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/List.imageset/List.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/List.imageset/List@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/List.imageset/List@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Search.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Search.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Search@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Search.imageset/Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Search.imageset/Search.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Search.imageset/Search@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Search.imageset/Search@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Share.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "Share.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "Share@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Share.imageset/Share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Share.imageset/Share.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Assets.xcassets/Share.imageset/Share@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Assets.xcassets/Share.imageset/Share@2x.png -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/BookshelfCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BookshelfCell.swift 3 | // BookReader 4 | // 5 | // Created by Kishikawa Katsumi on 2017/07/04. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BookshelfCell: UITableViewCell { 12 | var thumbnail: UIImage? = nil { 13 | didSet { 14 | thumbnailImageView.image = thumbnail 15 | } 16 | } 17 | var title: String = "No title" { 18 | didSet { 19 | titleLabel.text = title 20 | } 21 | } 22 | var author: String = "" { 23 | didSet { 24 | authorLabel.text = author 25 | } 26 | } 27 | var url: NSURL? 28 | 29 | @IBOutlet private weak var thumbnailImageView: UIImageView! 30 | @IBOutlet private weak var titleLabel: UILabel! 31 | @IBOutlet private weak var authorLabel: UILabel! 32 | 33 | override func awakeFromNib() { 34 | super.awakeFromNib() 35 | titleLabel.font = UIFont.preferredFont(forTextStyle: .headline) 36 | authorLabel.font = UIFont.preferredFont(forTextStyle: .caption1) 37 | authorLabel.textColor = .gray 38 | 39 | titleLabel.text = title 40 | authorLabel.text = author 41 | } 42 | 43 | override func prepareForReuse() { 44 | thumbnailImageView.image = nil 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/OutlineCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OutlineCell.swift 3 | // BookReader 4 | // 5 | // Created by Kishikawa Katsumi on 2017/07/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class OutlineCell: UITableViewCell { 12 | var label: String? = nil { 13 | didSet { 14 | titleLabel.text = label 15 | } 16 | } 17 | var pageLabel: String? = nil { 18 | didSet { 19 | pageNumberLabel.text = pageLabel 20 | } 21 | } 22 | @IBOutlet private weak var titleLabel: UILabel! 23 | @IBOutlet private weak var pageNumberLabel: UILabel! 24 | @IBOutlet private weak var indentationConstraint: NSLayoutConstraint! 25 | 26 | override func awakeFromNib() { 27 | super.awakeFromNib() 28 | pageNumberLabel.textColor = .gray 29 | pageNumberLabel.font = UIFont.preferredFont(forTextStyle: .subheadline) 30 | } 31 | 32 | override func updateConstraints() { 33 | super.updateConstraints() 34 | indentationConstraint.constant = CGFloat(15 + 10 * indentationLevel) 35 | } 36 | 37 | override func layoutSubviews() { 38 | super.layoutSubviews() 39 | 40 | if indentationLevel == 0 { 41 | titleLabel.font = UIFont.preferredFont(forTextStyle: .headline) 42 | } else { 43 | titleLabel.font = UIFont.preferredFont(forTextStyle: .body) 44 | } 45 | 46 | separatorInset = UIEdgeInsets(top: 0, left: safeAreaInsets.right + indentationConstraint.constant, bottom: 0, right: 0) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/Sample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/BookReader/Sample.pdf -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/SearchResultsCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SearchResultsCell.swift 3 | // BookReader 4 | // 5 | // Created by Kishikawa Katsumi on 2017/07/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SearchResultsCell: UITableViewCell { 12 | var section: String? = nil { 13 | didSet { 14 | sectionLabel.text = section 15 | } 16 | } 17 | var page: String? = nil { 18 | didSet { 19 | pageNumberLabel.text = page 20 | } 21 | } 22 | var resultText: String? = nil 23 | var searchText: String? = nil 24 | 25 | @IBOutlet private weak var sectionLabel: UILabel! 26 | @IBOutlet private weak var pageNumberLabel: UILabel! 27 | @IBOutlet private weak var resultTextLabel: UILabel! 28 | 29 | override func awakeFromNib() { 30 | super.awakeFromNib() 31 | sectionLabel.font = UIFont.preferredFont(forTextStyle: .headline) 32 | pageNumberLabel.textColor = .gray 33 | pageNumberLabel.font = UIFont.preferredFont(forTextStyle: .subheadline) 34 | resultTextLabel.font = UIFont.preferredFont(forTextStyle: .body) 35 | } 36 | 37 | override func layoutSubviews() { 38 | super.layoutSubviews() 39 | 40 | let highlightRange = (resultText! as NSString).range(of: searchText!, options: .caseInsensitive) 41 | let attributedString = NSMutableAttributedString(string: resultText!) 42 | attributedString.addAttributes([.font: UIFont.boldSystemFont(ofSize: resultTextLabel.font.pointSize)], range: highlightRange) 43 | resultTextLabel.attributedText = attributedString 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /chapter_10/BookReader/BookReader/ThumbnailGridCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ThumbnailGridCell.swift 3 | // BookReader 4 | // 5 | // Created by Kishikawa Katsumi on 2017/07/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ThumbnailGridCell: UICollectionViewCell { 12 | override var isHighlighted: Bool { 13 | didSet { 14 | imageView.alpha = isHighlighted ? 0.8 : 1 15 | } 16 | } 17 | var image: UIImage? = nil { 18 | didSet { 19 | imageView.image = image 20 | } 21 | } 22 | var pageNumber = 0 { 23 | didSet { 24 | pageNumberLabel.text = String(pageNumber) 25 | } 26 | } 27 | @IBOutlet private weak var imageView: UIImageView! 28 | @IBOutlet private weak var pageNumberLabel: UILabel! 29 | 30 | override func awakeFromNib() { 31 | super.awakeFromNib() 32 | pageNumberLabel.isHidden = true 33 | } 34 | 35 | override func prepareForReuse() { 36 | imageView.image = nil 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /chapter_10/BookReader/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kishikawa Katsumi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /chapter_10/BookReader/README.md: -------------------------------------------------------------------------------- 1 | # BookReader 2 | Sample code for PDFKit on iOS 11, clone of iBooks.app built on top of PDFKit. 3 | 4 | ---------------- 5 | 6 |  
7 |   8 |
9 |   10 | 11 | 12 | ## Requirements 13 | iOS 11.0 and Xcode 9 14 | 15 | ## Usage 16 | ### Import Your Own PDFs 17 | 18 | The easiest way to import your PDFs is to email your PDF file to your iOS device. Navigate to the email and ensure that the attachment is there. Tap and hold the document attachment icon. This should open a popover on the iPad, or an action sheet on the iPhone, that shows all of the apps that open your document type. BookReader app should show up in the list. Tap BookReader app icon and BookReader app should launch and receive the document from the email. 19 | 20 | 21 | 22 | ## Author 23 | Kishikawa Katsumi, kishikawakatsumi@mac.com 24 | 25 | ## License 26 | BookReader is available under the MIT license. See the LICENSE file for more info. 27 | -------------------------------------------------------------------------------- /chapter_10/BookReader/Resources/01_Reader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/Resources/01_Reader.png -------------------------------------------------------------------------------- /chapter_10/BookReader/Resources/02_Reader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/Resources/02_Reader.png -------------------------------------------------------------------------------- /chapter_10/BookReader/Resources/03_Thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/Resources/03_Thumbnail.png -------------------------------------------------------------------------------- /chapter_10/BookReader/Resources/04_TOC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/Resources/04_TOC.png -------------------------------------------------------------------------------- /chapter_10/BookReader/Resources/05_OpenIn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/Resources/05_OpenIn.png -------------------------------------------------------------------------------- /chapter_10/BookReader/Resources/06_Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/Resources/06_Search.png -------------------------------------------------------------------------------- /chapter_10/BookReader/Resources/07_Search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/Resources/07_Search.png -------------------------------------------------------------------------------- /chapter_10/BookReader/Resources/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/BookReader/Resources/Icon.png -------------------------------------------------------------------------------- /chapter_10/PDFViewTweaks/PDFViewTweaks.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_10/PDFViewTweaks/PDFViewTweaks/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PDFViewTweaks 4 | // 5 | // Created by Kishikawa Katsumi on 2017/10/25. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | var window: UIWindow? 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 16 | return true 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter_10/PDFViewTweaks/PDFViewTweaks/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /chapter_10/PDFViewTweaks/PDFViewTweaks/iOS11Programming.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_10/PDFViewTweaks/PDFViewTweaks/iOS11Programming.pdf -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCode.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCode/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MyQRCode 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/04. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Intents 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | if case INPreferences.siriAuthorizationStatus() = INSiriAuthorizationStatus.notDetermined { 18 | INPreferences.requestSiriAuthorization { status in 19 | switch status { 20 | case .authorized: 21 | print("authorized") 22 | case .denied, .restricted, .notDetermined: 23 | print("not authorized") 24 | } 25 | } 26 | } 27 | 28 | return true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCode/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | NSSiriUsageDescription 24 | Can we use Siri to show your contact information? 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCode/MyQRCode.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.siri 6 | 7 | com.apple.security.application-groups 8 | 9 | group.com.kishikawakatsumi.myqrcode 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCode/VisualCodeViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VisualCodeViewController.swift 3 | // MyQRCode 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/04. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class VisualCodeViewController: UIViewController { 12 | var visualCodeImage: UIImage? 13 | @IBOutlet private weak var imageView: UIImageView! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | imageView.image = visualCodeImage 18 | } 19 | 20 | @IBAction func done(_ sender: UIBarButtonItem) { 21 | dismiss(animated: true, completion: nil) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCodeKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCodeKit/MyQRCodeKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyQRCodeKit.h 3 | // MyQRCodeKit 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/04. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | FOUNDATION_EXPORT double MyQRCodeKitVersionNumber; 12 | FOUNDATION_EXPORT const unsigned char MyQRCodeKitVersionString[]; 13 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCodeKit/Repository.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Repository.swift 3 | // MyQRCodeKit 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/04. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public final class Repository { 12 | public static let shared = Repository() 13 | 14 | private var userDefaults: UserDefaults { 15 | get { 16 | return UserDefaults(suiteName: "group.com.kishikawakatsumi.myqrcode")! 17 | } 18 | } 19 | private let key = "me" 20 | 21 | public func save(me: Me) { 22 | userDefaults.set(try! PropertyListEncoder().encode(me), forKey: key) 23 | } 24 | 25 | public func load() -> Me? { 26 | if let data = userDefaults.object(forKey: key) as? Data { 27 | return try? PropertyListDecoder().decode(Me.self, from: data) 28 | } 29 | return nil 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCodeSiriKitExtension/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | MyQRCodeSiriKitExtension 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | XPC! 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | NSExtension 24 | 25 | NSExtensionAttributes 26 | 27 | IntentsRestrictedWhileLocked 28 | 29 | IntentsSupported 30 | 31 | INGetVisualCodeIntent 32 | 33 | 34 | NSExtensionPointIdentifier 35 | com.apple.intents-service 36 | NSExtensionPrincipalClass 37 | $(PRODUCT_MODULE_NAME).IntentHandler 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /chapter_11/MyQRCode/MyQRCodeSiriKitExtension/MyQRCodeSiriKitExtension.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.application-groups 6 | 7 | group.com.kishikawakatsumi.myqrcode 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ToDo 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Intents 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | if case INPreferences.siriAuthorizationStatus() = INSiriAuthorizationStatus.notDetermined { 18 | INPreferences.requestSiriAuthorization { status in 19 | switch status { 20 | case .authorized: 21 | print("authorized") 22 | case .denied, .restricted, .notDetermined: 23 | print("not authorized") 24 | } 25 | } 26 | } 27 | 28 | return true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDo/ToDo.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.siri 6 | 7 | com.apple.security.application-groups 8 | 9 | group.com.kishikawakatsumi.todo 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoKit/Task.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Task.swift 3 | // ToDoKit 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct Task: Codable { 12 | public let title: String 13 | public var isCompleted: Bool 14 | 15 | public init(title: String, isCompleted: Bool = false) { 16 | self.title = title 17 | self.isCompleted = isCompleted 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoKit/TaskList.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TaskList.swift 3 | // ToDoKit 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public final class TaskList: Codable { 12 | public let title: String 13 | public var tasks: [Task] { 14 | didSet { 15 | Repository.shared.save() 16 | } 17 | } 18 | 19 | public init(title: String, tasks: [Task] = [Task]()) { 20 | self.title = title 21 | self.tasks = tasks 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoKit/ToDoKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // ToDoKit.h 3 | // ToDoKit 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | FOUNDATION_EXPORT double ToDoKitVersionNumber; 12 | FOUNDATION_EXPORT const unsigned char ToDoKitVersionString[]; 13 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoSiriKitExtension/AddTasksHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddTasksHandler.swift 3 | // ToDoSiriKitExtension 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/04. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Intents 11 | import ToDoKit 12 | 13 | class AddTasksHandler: NSObject, INAddTasksIntentHandling { 14 | func handle(intent: INAddTasksIntent, completion: @escaping (INAddTasksIntentResponse) -> Void) { 15 | guard let targetTaskList = intent.targetTaskList, 16 | let taskList = Repository.shared.taskList(for: targetTaskList.title.spokenPhrase), 17 | let taskTitles = intent.taskTitles else { 18 | let response = INAddTasksIntentResponse(code: .failureRequiringAppLaunch, userActivity: nil) 19 | completion(response) 20 | return 21 | } 22 | 23 | taskTitles.forEach { taskList.tasks.append(Task(title: $0.spokenPhrase)) } 24 | 25 | let response = INAddTasksIntentResponse(code: .success, userActivity: nil) 26 | completion(response) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoSiriKitExtension/CreateTaskListHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CreateTaskListHandler.swift 3 | // ToDoSiriKitExtension 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Intents 11 | import ToDoKit 12 | 13 | class CreateTaskListHandler: NSObject, INCreateTaskListIntentHandling { 14 | func handle(intent: INCreateTaskListIntent, completion: @escaping (INCreateTaskListIntentResponse) -> Void) { 15 | guard let title = intent.title else { 16 | let response = INCreateTaskListIntentResponse(code: .failureRequiringAppLaunch, userActivity: nil) 17 | completion(response) 18 | return 19 | } 20 | if let taskTitles = intent.taskTitles, !taskTitles.isEmpty { 21 | Repository.shared.addTaskList(title: title.spokenPhrase, tasks: taskTitles.map { Task(title: $0.spokenPhrase) }) 22 | } else { 23 | Repository.shared.addTaskList(title: title.spokenPhrase) 24 | } 25 | let response = INCreateTaskListIntentResponse(code: .success, userActivity: nil) 26 | completion(response) 27 | } 28 | 29 | func resolveTitle(for intent: INCreateTaskListIntent, with completion: @escaping (INSpeakableStringResolutionResult) -> Void) { 30 | if let title = intent.title { 31 | completion(.success(with: title)) 32 | } else { 33 | completion(INSpeakableStringResolutionResult.needsValue()) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoSiriKitExtension/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | ToDoSiriKitExtension 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | XPC! 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | NSExtension 24 | 25 | NSExtensionAttributes 26 | 27 | IntentsRestrictedWhileLocked 28 | 29 | IntentsSupported 30 | 31 | INCreateTaskListIntent 32 | INAddTasksIntent 33 | INSetTaskAttributeIntent 34 | 35 | 36 | NSExtensionPointIdentifier 37 | com.apple.intents-service 38 | NSExtensionPrincipalClass 39 | $(PRODUCT_MODULE_NAME).IntentHandler 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoSiriKitExtension/IntentHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IntentHandler.swift 3 | // ToDoSiriKitExtension 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/03. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import Intents 10 | 11 | class IntentHandler: INExtension { 12 | override func handler(for intent: INIntent) -> Any? { 13 | switch intent { 14 | case is INCreateTaskListIntent: 15 | return CreateTaskListHandler() 16 | case is INAddTasksIntent: 17 | return AddTasksHandler() 18 | case is INSetTaskAttributeIntent: 19 | return SetTaskAttributeHandler() 20 | default: 21 | return nil 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoSiriKitExtension/SetTaskAttributeHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SetTaskAttributeHandler.swift 3 | // ToDoSiriKitExtension 4 | // 5 | // Created by Kishikawa Katsumi on 2017/09/04. 6 | // Copyright © 2017 Kishikawa Katsumi. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Intents 11 | import ToDoKit 12 | 13 | class SetTaskAttributeHandler: NSObject, INSetTaskAttributeIntentHandling { 14 | func handle(intent: INSetTaskAttributeIntent, completion: @escaping (INSetTaskAttributeIntentResponse) -> Void) { 15 | guard let title = intent.targetTask?.title else { 16 | let response = INSetTaskAttributeIntentResponse(code: .failureRequiringAppLaunch, userActivity: nil) 17 | completion(response) 18 | return 19 | } 20 | 21 | if Repository.shared.setComplete(for: title.spokenPhrase) { 22 | let response = INSetTaskAttributeIntentResponse(code: .success, userActivity: nil) 23 | completion(response) 24 | } else { 25 | let response = INSetTaskAttributeIntentResponse(code: .failureRequiringAppLaunch, userActivity: nil) 26 | completion(response) 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /chapter_11/ToDo/ToDoSiriKitExtension/ToDoSiriKitExtension.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.application-groups 6 | 7 | group.com.kishikawakatsumi.todo 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/.gitignore: -------------------------------------------------------------------------------- 1 | # Added by gemignore. Snippet 'Swift' 2 | # Xcode 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | Pods/ 26 | /*.xcworkspace 27 | 28 | # Carthage 29 | # 30 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 31 | # Carthage/Checkouts 32 | Carthage/Build 33 | 34 | # Added by gemignore. Snippet 'Global/OSX' 35 | .DS_Store 36 | .AppleDouble 37 | .LSOverride 38 | 39 | # Icon must end with two \r 40 | Icon 41 | 42 | # Thumbnails 43 | ._* 44 | 45 | # Files that might appear in the root of a volume 46 | .DocumentRevisions-V100 47 | .fseventsd 48 | .Spotlight-V100 49 | .TemporaryItems 50 | .Trashes 51 | .VolumeIcon.icns 52 | 53 | # Directories potentially created on remote AFP share 54 | .AppleDB 55 | .AppleDesktop 56 | Network Trash Folder 57 | Temporary Items 58 | .apdisk 59 | 60 | # fastlane 61 | .bundle 62 | fastlane/report.xml 63 | *.dSYM.zip 64 | /vendor 65 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/.swiftlint.yml: -------------------------------------------------------------------------------- 1 | line_length: 2 | - 150 3 | type_body_length: 4 | - 250 5 | function_body_length: 6 | - 120 7 | cyclomatic_complexity: 8 | - 120 9 | type_name: 10 | max_length: 11 | - 50 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // 4 | // Created by ToKoRo on 2017-08-18. 5 | // 6 | 7 | import UIKit 8 | 9 | @UIApplicationMain 10 | class AppDelegate: UIResponder, UIApplicationDelegate { 11 | var window: UIWindow? 12 | 13 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 14 | return true 15 | } 16 | 17 | func applicationWillResignActive(_ application: UIApplication) { 18 | } 19 | 20 | func applicationDidEnterBackground(_ application: UIApplication) { 21 | } 22 | 23 | func applicationWillEnterForeground(_ application: UIApplication) { 24 | } 25 | 26 | func applicationDidBecomeActive(_ application: UIApplication) { 27 | } 28 | 29 | func applicationWillTerminate(_ application: UIApplication) { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/CharacteristicMetadataFormatsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CharacteristicMetadataFormatsViewController.swift 3 | // 4 | // Created by ToKoRo on 2017-08-28. 5 | // 6 | 7 | import UIKit 8 | import HomeKit 9 | 10 | class CharacteristicMetadataFormatsViewController: UITableViewController { 11 | lazy var formats: [CharacteristicMetadataFormat] = CharacteristicMetadataFormat.all 12 | 13 | override func viewWillAppear(_ animated: Bool) { 14 | super.viewWillAppear(animated) 15 | 16 | refresh() 17 | } 18 | 19 | func refresh() { 20 | DispatchQueue.main.async { 21 | self.tableView.reloadData() 22 | } 23 | } 24 | 25 | func format(at indexPath: IndexPath) -> CharacteristicMetadataFormat? { 26 | return formats.safe[indexPath.row] 27 | } 28 | } 29 | 30 | // MARK: - UITableViewDataSource 31 | 32 | extension CharacteristicMetadataFormatsViewController { 33 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 34 | return formats.count 35 | } 36 | 37 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 38 | let cell = tableView.dequeueReusableCell(withIdentifier: "CharacteristicMetadataFormat", for: indexPath) 39 | if let format = format(at: indexPath) { 40 | cell.textLabel?.text = format.description 41 | } 42 | return cell 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/CharacteristicMetadataUnitsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CharacteristicMetadataUnitsViewController.swift 3 | // 4 | // Created by ToKoRo on 2017-08-29. 5 | // 6 | 7 | import UIKit 8 | import HomeKit 9 | 10 | class CharacteristicMetadataUnitsViewController: UITableViewController { 11 | lazy var units: [CharacteristicMetadataUnits] = CharacteristicMetadataUnits.all 12 | 13 | override func viewWillAppear(_ animated: Bool) { 14 | super.viewWillAppear(animated) 15 | 16 | refresh() 17 | } 18 | 19 | func refresh() { 20 | DispatchQueue.main.async { 21 | self.tableView.reloadData() 22 | } 23 | } 24 | 25 | func unit(at indexPath: IndexPath) -> CharacteristicMetadataUnits? { 26 | return units.safe[indexPath.row] 27 | } 28 | } 29 | 30 | // MARK: - UITableViewDataSource 31 | 32 | extension CharacteristicMetadataUnitsViewController { 33 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 34 | return units.count 35 | } 36 | 37 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 38 | let cell = tableView.dequeueReusableCell(withIdentifier: "CharacteristicMetadataUnits", for: indexPath) 39 | if let unit = unit(at: indexPath) { 40 | cell.textLabel?.text = unit.description 41 | } 42 | return cell 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/CreateEventTriggerViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CreateEventTriggerViewController.swift 3 | // 4 | // Created by ToKoRo on 2017-10-19. 5 | // 6 | 7 | import UIKit 8 | import HomeKit 9 | 10 | class CreateEventTriggerViewController: CreateTriggerViewController { 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/CreateTimerTriggerViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CreateTimerTriggerViewController.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import UIKit 8 | import HomeKit 9 | 10 | class CreateTimerTriggerViewController: CreateTriggerViewController { 11 | @IBOutlet weak var fireDatePicker: UIDatePicker? 12 | 13 | lazy var calendar: Calendar = Calendar(identifier: .gregorian) 14 | 15 | var newFireDate: Date? { 16 | guard let date = fireDatePicker?.date else { 17 | return nil 18 | } 19 | 20 | let comp = calendar.dateComponents([.minute, .hour, .day, .month, .year, .era], from: date) 21 | let fireDate = calendar.date(from: comp) 22 | return fireDate 23 | } 24 | 25 | var newTimeZone: TimeZone? { 26 | return fireDatePicker?.timeZone 27 | } 28 | 29 | override func createTrigger() -> HMTrigger? { 30 | guard 31 | let name = newName, 32 | let fireDate = newFireDate 33 | else { 34 | return nil 35 | } 36 | 37 | return HMTimerTrigger( 38 | name: name, 39 | fireDate: fireDate, 40 | timeZone: newTimeZone, 41 | recurrence: nil, 42 | recurrenceCalendar: nil 43 | ) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/CreateTriggerViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CreateTriggerViewController.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import UIKit 8 | import HomeKit 9 | 10 | class CreateTriggerViewController: UITableViewController { 11 | @IBOutlet weak var nameField: UITextField? 12 | 13 | var newName: String? { 14 | return nameField?.text 15 | } 16 | 17 | func createTriggerAndSend() { 18 | guard let trigger = createTrigger() else { 19 | dismiss(animated: true) 20 | return 21 | } 22 | 23 | ResponderChain(from: self).send(trigger, protocol: TriggerSelector.self) { trigger, handler in 24 | handler.selectTrigger(trigger) 25 | } 26 | dismiss(animated: true) 27 | } 28 | 29 | func createTrigger() -> HMTrigger? { 30 | return nil 31 | } 32 | 33 | @IBAction func doneButtonDidTap(sender: AnyObject) { 34 | createTriggerAndSend() 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/DatePickerController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DatePickerController.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import UIKit 8 | 9 | class DatePickerController: UITableViewController, ContextHandler, HasCallback { 10 | typealias ContextType = Date 11 | typealias CallbackType = Date 12 | 13 | @IBOutlet weak var datePicker: UIDatePicker? 14 | 15 | var defaultDate: Date? { return context } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | if let defaultDate = defaultDate { 21 | datePicker?.date = defaultDate 22 | } 23 | } 24 | 25 | @IBAction func okButtonDidTap(sender: AnyObject) { 26 | ok() 27 | } 28 | 29 | @IBAction func cancelButtonDidTap(sender: AnyObject) { 30 | cancel() 31 | } 32 | } 33 | 34 | // MARK: - Private 35 | 36 | private extension DatePickerController { 37 | func ok() { 38 | guard let date = datePicker?.date else { 39 | dismiss(animated: true) 40 | return 41 | } 42 | 43 | callback?(date) 44 | 45 | dismiss(animated: true) 46 | } 47 | 48 | func cancel() { 49 | dismiss(animated: true) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/EventViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EventViewController.swift 3 | // 4 | // Created by ToKoRo on 2017-09-04. 5 | // 6 | 7 | import UIKit 8 | import HomeKit 9 | 10 | class EventViewController: UITableViewController, ContextHandler { 11 | typealias ContextType = HMEvent 12 | 13 | @IBOutlet weak var uniqueIdentifierLabel: UILabel? 14 | @IBOutlet weak var typeLabel: UILabel? 15 | 16 | var event: HMEvent { return context! } 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | refresh() 22 | } 23 | 24 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 25 | switch segue.identifier { 26 | case "ActionSet"?: 27 | sendContext(event, to: segue.destination) 28 | default: 29 | break 30 | } 31 | } 32 | 33 | func refresh() { 34 | uniqueIdentifierLabel?.text = event.uniqueIdentifier.uuidString 35 | typeLabel?.text = String(describing: type(of: event)) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Controller/MainMenuViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainMenuViewController.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import UIKit 8 | import HomeKit 9 | 10 | class MainMenuViewController: UITableViewController { 11 | lazy var homeManager: HMHomeManager = HMHomeManager.shared 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | print("# homeManager: \(homeManager)") 17 | } 18 | 19 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 20 | switch segue.identifier { 21 | case "PrimaryHome"?: 22 | sendContext(homeManager.primaryHome, to: segue.destination) 23 | default: 24 | break 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Extension/SafeCollection.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SafeCollection.swift 3 | // 4 | // Created by ToKoRo on 2017-08-18. 5 | // 6 | 7 | /** 8 | * ref: https://medium.com/@jegnux/safe-collection-subsripting-in-swift-3771f16f883 9 | */ 10 | 11 | import Foundation 12 | 13 | public struct SafeCollection { 14 | private var _base: Base 15 | 16 | public init(_ base: Base) { 17 | _base = base 18 | } 19 | 20 | private func distance(from startIndex: Base.Index) -> Base.IndexDistance { 21 | return _base.distance(from: startIndex, to: _base.endIndex) 22 | } 23 | 24 | private func distance(to endIndex: Base.Index) -> Base.IndexDistance { 25 | return _base.distance(from: _base.startIndex, to: endIndex) 26 | } 27 | 28 | public subscript(index: Base.Index) -> Base.Iterator.Element? { 29 | if distance(to: index) >= 0 && distance(from: index) > 0 { 30 | return _base[index] 31 | } 32 | return nil 33 | } 34 | 35 | public subscript(bounds: Range) -> Base.SubSequence? { 36 | if distance(to: bounds.lowerBound) >= 0 && distance(from: bounds.upperBound) >= 0 { 37 | return _base[bounds] 38 | } 39 | return nil 40 | } 41 | 42 | public subscript(bounds: ClosedRange) -> Base.SubSequence? { 43 | if distance(to: bounds.lowerBound) >= 0 && distance(from: bounds.upperBound) > 0 { 44 | return _base[bounds] 45 | } 46 | return nil 47 | } 48 | } 49 | 50 | public extension Collection { 51 | var safe: SafeCollection { 52 | return SafeCollection(self) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HasAssociatedObjects/HasAssociatedObjects.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HasAssociatedObjects.swift 3 | // 4 | // Created by ToKoRo on 2017-08-18. 5 | // 6 | 7 | import Foundation 8 | 9 | public class AssociatedObjects: NSObject { 10 | public var dictionary: [String: Any] = [:] 11 | 12 | public var value: Any? { 13 | get { 14 | return self.dictionary[""] 15 | } 16 | set { 17 | self.dictionary[""] = newValue ?? "" 18 | } 19 | } 20 | 21 | public subscript(key: String) -> Any? { 22 | get { 23 | return self.dictionary[key] 24 | } 25 | set { 26 | self.dictionary[key] = newValue 27 | } 28 | } 29 | 30 | public func removeAll() { 31 | self.dictionary.removeAll() 32 | } 33 | 34 | } 35 | 36 | public protocol HasAssociatedObjects { 37 | var associatedObjects: AssociatedObjects { get } 38 | } 39 | 40 | private var associatedObjectsKey: UInt8 = 0 41 | 42 | public extension HasAssociatedObjects where Self: AnyObject { 43 | var associatedObjects: AssociatedObjects { 44 | guard let associatedObjects = objc_getAssociatedObject(self, &associatedObjectsKey) as? AssociatedObjects else { 45 | let associatedObjects = AssociatedObjects() 46 | objc_setAssociatedObject(self, &associatedObjectsKey, associatedObjects, .OBJC_ASSOCIATION_RETAIN) 47 | return associatedObjects 48 | } 49 | return associatedObjects 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/ActionSetType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSetType.swift 3 | // 4 | // Created by ToKoRo on 2017-08-22. 5 | // 6 | 7 | import HomeKit 8 | 9 | enum ActionSetType { 10 | case unknown 11 | 12 | case homeArrival 13 | case homeDeparture 14 | case sleep 15 | case triggerOwned 16 | case userDefined 17 | case wakeUp 18 | 19 | init(typeString: String) { 20 | switch typeString { 21 | case HMActionSetTypeHomeArrival: self = .homeArrival 22 | case HMActionSetTypeHomeDeparture: self = .homeDeparture 23 | case HMActionSetTypeSleep: self = .sleep 24 | case HMActionSetTypeTriggerOwned: self = .triggerOwned 25 | case HMActionSetTypeUserDefined: self = .userDefined 26 | case HMActionSetTypeWakeUp: self = .wakeUp 27 | default: self = .unknown 28 | } 29 | } 30 | } 31 | 32 | extension ActionSetType: CustomStringConvertible { 33 | var description: String { 34 | switch self { 35 | case .unknown: return "UNKNOWN" 36 | case .homeArrival: return "homeArrival" 37 | case .homeDeparture: return "homeDeparture" 38 | case .sleep: return "sleep" 39 | case .triggerOwned: return "triggerOwned" 40 | case .userDefined: return "userDefined" 41 | case .wakeUp: return "wakeUp" 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMAccessory+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMAccessory+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMAccessory { 10 | var home: HMHome? { 11 | let homeManager = HMHomeManager.shared 12 | for home in homeManager.homes where home.accessories.contains(self) { 13 | return home 14 | } 15 | return nil 16 | } 17 | 18 | var allCharacteristics: [HMCharacteristic] { 19 | return services.flatMap { $0.characteristics } 20 | } 21 | 22 | var allReadableCharacteristics: [HMCharacteristic] { 23 | return allCharacteristics.filter { $0.isReadable } 24 | } 25 | 26 | var allWritableCharacteristics: [HMCharacteristic] { 27 | return allCharacteristics.filter { $0.isWritable } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMActionSet+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMActionSet+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMActionSet { 10 | var home: HMHome? { 11 | let homeManager = HMHomeManager.shared 12 | for home in homeManager.homes where home.actionSets.contains(self) { 13 | return home 14 | } 15 | return nil 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMCameraAudioStreamSetting+Description.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMCameraAudioStreamSetting+Description.swift 3 | // 4 | // Created by ToKoRo on 2017-09-12. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMCameraAudioStreamSetting: CustomStringConvertible { 10 | public var description: String { 11 | switch self { 12 | case .bidirectionalAudioAllowed: return "bidirectionalAudioAllowed" 13 | case .incomingAudioAllowed: return "incomingAudioAllowed" 14 | case .muted: return "muted" 15 | } 16 | } 17 | 18 | static var all: [HMCameraAudioStreamSetting] { 19 | return [ 20 | .bidirectionalAudioAllowed, 21 | .incomingAudioAllowed, 22 | .muted 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMCameraStreamState+Description.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMCameraStreamState+Description.swift 3 | // 4 | // Created by ToKoRo on 2017-09-12. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMCameraStreamState: CustomStringConvertible { 10 | public var description: String { 11 | switch self { 12 | case .notStreaming: return "notStreaming" 13 | case .starting: return "starting" 14 | case .stopping: return "stopping" 15 | case .streaming: return "streaming" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMCharacteristic+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMCharacteristic+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMCharacteristic { 10 | var isReadable: Bool { 11 | return properties.contains(HMCharacteristicPropertyReadable) 12 | } 13 | 14 | var isWritable: Bool { 15 | return properties.contains(HMCharacteristicPropertyWritable) 16 | } 17 | 18 | var isHidden: Bool { 19 | return properties.contains(HMCharacteristicPropertyHidden) 20 | } 21 | 22 | var supportsEvent: Bool { 23 | return properties.contains(Notification.Name.HMCharacteristicPropertySupportsEvent.rawValue) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMEventTriggerActivationState+Description.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMEventTriggerActivationState+Description.swift 3 | // 4 | // Created by ToKoRo on 2017-09-04. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMEventTriggerActivationState: CustomStringConvertible { 10 | public var description: String { 11 | switch self { 12 | case .disabled: return "disabled" 13 | case .disabledNoCompatibleHomeHub: return "disabledNoCompatibleHomeHub" 14 | case .disabledNoHomeHub: return "disabledNoHomeHub" 15 | case .disabledNoLocationServicesAuthorization: return "disabledNoLocationServicesAuthorization" 16 | case .enabled: return "enabled" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMHome+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMHome+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMHome { 10 | var allServices: [HMService] { 11 | return accessories.flatMap { $0.services } 12 | } 13 | 14 | var allCharacteristics: [HMCharacteristic] { 15 | return allServices.flatMap { $0.characteristics } 16 | } 17 | 18 | var allReadableCharacteristics: [HMCharacteristic] { 19 | return allCharacteristics.filter { $0.isReadable } 20 | } 21 | 22 | var allWritableCharacteristics: [HMCharacteristic] { 23 | return allCharacteristics.filter { $0.isWritable } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMHomeHubState+Description.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMHomeHubState+Description.swift 3 | // 4 | // Created by ToKoRo on 2017-08-21. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMHomeHubState: CustomStringConvertible { 10 | public var description: String { 11 | switch self { 12 | case .connected: return "connected" 13 | case .disconnected: return "disconnected" 14 | case .notAvailable: return "notAvailable" 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMHomeManager+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMHomeManager+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMHomeManager { 10 | static let shared = HMHomeManager() 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMRoom+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMRoom+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMRoom { 10 | var home: HMHome? { 11 | let homeManager = HMHomeManager.shared 12 | for home in homeManager.homes where home.rooms.contains(self) { 13 | return home 14 | } 15 | return nil 16 | } 17 | 18 | var zone: HMZone? { 19 | guard let home = home else { 20 | return nil 21 | } 22 | for zone in home.zones where zone.rooms.contains(self) { 23 | return zone 24 | } 25 | return nil 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMServiceGroup+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMServiceGroup+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMServiceGroup { 10 | var home: HMHome? { 11 | let homeManager = HMHomeManager.shared 12 | for home in homeManager.homes where home.serviceGroups.contains(self) { 13 | return home 14 | } 15 | return nil 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMTrigger+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMTrigger+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMTrigger { 10 | var home: HMHome? { 11 | let homeManager = HMHomeManager.shared 12 | for home in homeManager.homes where home.triggers.contains(self) { 13 | return home 14 | } 15 | return nil 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/HomeKitUtils/HMZone+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HMZone+Utils.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | extension HMZone { 10 | var home: HMHome? { 11 | let homeManager = HMHomeManager.shared 12 | for home in homeManager.homes where home.zones.contains(self) { 13 | return home 14 | } 15 | return nil 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/ResponderChain/ResponderChain.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ResponderChain.swift 3 | // 4 | // Created by ToKoRo on 2017-08-19. 5 | // 6 | 7 | import UIKit 8 | 9 | struct ResponderChain { 10 | let from: UIResponder 11 | 12 | func send(_ value: V, protocol: P.Type, adopter: (V, P) -> Void) { 13 | from.next?.relayValue(value, protocol: `protocol`, adopter: adopter, from: from) 14 | } 15 | } 16 | 17 | // MARK: - UIResponder 18 | 19 | extension UIResponder { 20 | fileprivate func relayValue(_ value: V, protocol: P.Type, adopter: (V, P) -> Void, from: UIResponder) { 21 | if let impl = findProtocolImplementation(`protocol`, from: from) { 22 | adopter(value, impl) 23 | return 24 | } 25 | 26 | next?.relayValue(value, protocol: `protocol`, adopter: adopter, from: from) 27 | } 28 | 29 | private func findProtocolImplementation

(_ protocol: P.Type, from: UIResponder) -> P? { 30 | switch self { 31 | case let navi as UINavigationController: 32 | for viewController in navi.viewControllers where viewController != from { 33 | guard let impl = viewController as? P else { 34 | continue 35 | } 36 | return impl 37 | } 38 | return self as? P 39 | case let tab as UITabBarController: 40 | for viewController in tab.viewControllers ?? [] where viewController != from { 41 | guard let impl = viewController as? P else { 42 | continue 43 | } 44 | return impl 45 | } 46 | return self as? P 47 | default: 48 | return self as? P 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/SegueContext/SegueCallback.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SegueCallback.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import UIKit 8 | 9 | // MARK: - HasCallback 10 | 11 | protocol HasCallback { 12 | associatedtype CallbackType 13 | typealias Callback = (CallbackType) -> Void 14 | 15 | var callback: Callback? { get } 16 | } 17 | 18 | // MARK: - UIResponder 19 | 20 | extension UIResponder { 21 | fileprivate var callbackKey: String { return #function } 22 | } 23 | 24 | extension HasCallback where Self: UIResponder { 25 | var callback: Callback? { 26 | return associatedObjects[callbackKey] as? Callback 27 | } 28 | } 29 | 30 | extension UIResponder { 31 | func bindCallback(type: V.Type, to responder: UIResponder?, callback newCallback: @escaping (V) -> Void) { 32 | switch responder { 33 | case let navi as UINavigationController: 34 | for viewController in navi.viewControllers { 35 | bindCallback(type: type, to: viewController, callback: newCallback) 36 | } 37 | case let tab as UITabBarController: 38 | for viewController in tab.viewControllers ?? [] { 39 | bindCallback(type: type, to: viewController, callback: newCallback) 40 | } 41 | default: 42 | responder?.associatedObjects[callbackKey] = newCallback 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Lib/SegueContext/SegueContext.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SegueContext.swift 3 | // 4 | // Created by ToKoRo on 2017-08-18. 5 | // 6 | 7 | import UIKit 8 | 9 | // MARK: - ContextHandler 10 | 11 | protocol ContextHandler { 12 | associatedtype ContextType 13 | 14 | var context: ContextType? { get } 15 | var contextSender: UIResponder? { get } 16 | } 17 | 18 | // MARK: - UIResponder 19 | 20 | extension UIResponder: HasAssociatedObjects { 21 | fileprivate var contextKey: String { return #function } 22 | fileprivate var contextSenderKey: String { return #function } 23 | } 24 | 25 | extension ContextHandler where Self: UIResponder { 26 | var context: ContextType? { 27 | return associatedObjects[contextKey] as? ContextType 28 | } 29 | 30 | var contextSender: UIResponder? { 31 | return associatedObjects[contextSenderKey] as? UIResponder 32 | } 33 | } 34 | 35 | extension UIResponder { 36 | func sendContext(_ context: Any?, to handler: UIResponder?) { 37 | switch handler { 38 | case let navi as UINavigationController: 39 | for viewController in navi.viewControllers { 40 | sendContext(context, to: viewController) 41 | } 42 | case let tab as UITabBarController: 43 | for viewController in tab.viewControllers ?? [] { 44 | sendContext(context, to: viewController) 45 | } 46 | default: 47 | handler?.associatedObjects[contextSenderKey] = self 48 | handler?.associatedObjects[contextKey] = context 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/AccessoryActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AccessoryActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol AccessoryActionHandler { 10 | func handleRemove(_ accessory: HMAccessory) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/AccessorySelector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AccessorySelector.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol AccessorySelector { 10 | func selectAccessory(_ accessory: HMAccessory) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/AccessoryStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AccessoryStore.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol AccessoryStore { 10 | var accessoryStoreKind: AccessoryStoreKind { get } 11 | var accessories: [HMAccessory] { get } 12 | } 13 | 14 | enum AccessoryStoreKind { 15 | case home(HMHome) 16 | case room(HMRoom) 17 | case identifiers(AccessoryIdentifiers) 18 | } 19 | 20 | // MARK: - HMHome 21 | 22 | extension HMHome: AccessoryStore { 23 | var accessoryStoreKind: AccessoryStoreKind { return .home(self) } 24 | } 25 | 26 | // MARK: - HMRoom 27 | 28 | extension HMRoom: AccessoryStore { 29 | var accessoryStoreKind: AccessoryStoreKind { return .room(self) } 30 | } 31 | 32 | // MARK: - AccessoryIdentifiers 33 | 34 | struct AccessoryIdentifiers { 35 | let identifiers: [UUID] 36 | } 37 | 38 | extension AccessoryIdentifiers: AccessoryStore { 39 | var accessoryStoreKind: AccessoryStoreKind { return .identifiers(self) } 40 | 41 | var accessories: [HMAccessory] { 42 | var accessories: [HMAccessory] = [] 43 | let homeManager = HMHomeManager.shared 44 | for home in homeManager.homes { 45 | for accessory in home.accessories where identifiers.contains(accessory.uniqueIdentifier) { 46 | accessories.append(accessory) 47 | } 48 | } 49 | return accessories 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ActionActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ActionActionHandler { 10 | func handleRemove(_ action: HMAction) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ActionSelector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSelector.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ActionSelector { 10 | func selectAction(_ action: HMAction) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ActionSetActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSetActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ActionSetActionHandler { 10 | func handleExecute(_ actionSet: HMActionSet) 11 | func handleRemove(_ actionSet: HMActionSet) 12 | } 13 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ActionSetSelector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSetSelector.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ActionSetSelector { 10 | func selectActionSet(_ actionSet: HMActionSet) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ActionSetStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSetStore.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ActionSetStore { 10 | var actionSetStoreKind: ActionSetStoreKind { get } 11 | var actionSets: [HMActionSet] { get } 12 | } 13 | 14 | enum ActionSetStoreKind { 15 | case home(HMHome) 16 | case trigger(HMTrigger) 17 | } 18 | 19 | // MARK: - HMHome 20 | 21 | extension HMHome: ActionSetStore { 22 | var actionSetStoreKind: ActionSetStoreKind { return .home(self) } 23 | } 24 | 25 | // MARK: - HMTrigger 26 | 27 | extension HMTrigger: ActionSetStore { 28 | var actionSetStoreKind: ActionSetStoreKind { return .trigger(self) } 29 | } 30 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ActionStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ActionStore.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ActionStore { 10 | var actionStoreKind: ActionStoreKind { get } 11 | var actions: Set { get } 12 | } 13 | 14 | enum ActionStoreKind { 15 | case actionSet(HMActionSet) 16 | } 17 | 18 | // MARK: - HMActionSet 19 | 20 | extension HMActionSet: ActionStore { 21 | var actionStoreKind: ActionStoreKind { return .actionSet(self) } 22 | } 23 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/CharacteristicSelector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CharacteristicSelector.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol CharacteristicSelector { 10 | func selectCharacteristic(_ characteristic: HMCharacteristic) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/CharacteristicStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CharacteristicStore.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol CharacteristicStore { 10 | var characteristicStoreKind: CharacteristicStoreKind { get } 11 | var characteristics: [HMCharacteristic] { get } 12 | } 13 | 14 | enum CharacteristicStoreKind { 15 | case service(HMService) 16 | case accessory(HMAccessory) 17 | case home(HMHome) 18 | } 19 | 20 | // MARK: - HMService 21 | 22 | extension HMService: CharacteristicStore { 23 | var characteristicStoreKind: CharacteristicStoreKind { return .service(self) } 24 | } 25 | 26 | // MARK: - HMAccessory 27 | 28 | extension HMAccessory: CharacteristicStore { 29 | var characteristicStoreKind: CharacteristicStoreKind { return .accessory(self) } 30 | var characteristics: [HMCharacteristic] { return allWritableCharacteristics } 31 | } 32 | 33 | // MARK: - HMHome 34 | 35 | extension HMHome: CharacteristicStore { 36 | var characteristicStoreKind: CharacteristicStoreKind { return .home(self) } 37 | var characteristics: [HMCharacteristic] { return allWritableCharacteristics } 38 | } 39 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/HomeActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HomeActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-08-20. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol HomeActionHandler { 10 | func handleRemove(_ home: HMHome) 11 | func handleMakePrimary(_ home: HMHome) 12 | } 13 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/RoomActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RoomActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol RoomActionHandler { 10 | func handleRemove(_ room: HMRoom) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/RoomSelector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RoomSelector.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol RoomSelector { 10 | func selectRoom(_ room: HMRoom) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/RoomStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RoomStore.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol RoomStore { 10 | var roomStoreKind: RoomStoreKind { get } 11 | var rooms: [HMRoom] { get } 12 | } 13 | 14 | enum RoomStoreKind { 15 | case home(HMHome) 16 | case zone(HMZone) 17 | } 18 | 19 | // MARK: - HMHome 20 | 21 | extension HMHome: RoomStore { 22 | var roomStoreKind: RoomStoreKind { return .home(self) } 23 | } 24 | 25 | // MARK: - HMZone 26 | 27 | extension HMZone: RoomStore { 28 | var roomStoreKind: RoomStoreKind { return .zone(self) } 29 | } 30 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ServiceActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ServiceActionHandler { 10 | func handleRemove(_ service: HMService) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ServiceGroupActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceGroupActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ServiceGroupActionHandler { 10 | func handleRemove(_ serviceGroup: HMServiceGroup) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ServiceSelector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceSelector.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ServiceSelector { 10 | func selectService(_ service: HMService) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ServiceStore.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceStore.swift 3 | // 4 | // Created by ToKoRo on 2017-09-02. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ServiceStore { 10 | var serviceStoreKind: ServiceStoreKind { get } 11 | var services: [HMService] { get } 12 | var isServiceAddable: Bool { get } 13 | var isServiceRemovable: Bool { get } 14 | } 15 | 16 | enum ServiceStoreKind { 17 | case accessory(HMAccessory) 18 | case serviceGroup(HMServiceGroup) 19 | case home(HMHome) 20 | } 21 | 22 | // MARK: - HMAccessory 23 | 24 | extension HMAccessory: ServiceStore { 25 | var serviceStoreKind: ServiceStoreKind { return .accessory(self) } 26 | var isServiceAddable: Bool { return false } 27 | var isServiceRemovable: Bool { return false } 28 | } 29 | 30 | // MARK: - HMServiceGroup 31 | 32 | extension HMServiceGroup: ServiceStore { 33 | var serviceStoreKind: ServiceStoreKind { return .serviceGroup(self) } 34 | var isServiceAddable: Bool { return true } 35 | var isServiceRemovable: Bool { return true } 36 | } 37 | 38 | // MARK: - HMHome 39 | 40 | extension HMHome: ServiceStore { 41 | var serviceStoreKind: ServiceStoreKind { return .home(self) } 42 | var isServiceAddable: Bool { return false } 43 | var isServiceRemovable: Bool { return false } 44 | var services: [HMService] { return allServices } 45 | } 46 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/TriggerActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TriggerActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol TriggerActionHandler { 10 | func handleRemove(_ trigger: HMTrigger) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/TriggerSelector.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TriggerSelector.swift 3 | // 4 | // Created by ToKoRo on 2017-09-03. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol TriggerSelector { 10 | func selectTrigger(_ trigger: HMTrigger) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Code/Protocol/ZoneActionHandler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZoneActionHandler.swift 3 | // 4 | // Created by ToKoRo on 2017-08-27. 5 | // 6 | 7 | import HomeKit 8 | 9 | protocol ZoneActionHandler { 10 | func handleRemove(_ zone: HMZone) 11 | } 12 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/HomeKitSample.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.developer.homekit 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Resource/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/App/Resource/Assets.xcassets/Image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x" 14 | } 15 | ], 16 | "info" : { 17 | "version" : 1, 18 | "author" : "xcode" 19 | } 20 | } -------------------------------------------------------------------------------- /chapter_12/HomeKitSample/HomeKitSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_13/01_MetalImageRender/MetalImageRender.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_13/01_MetalImageRender/MetalImageRender/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MetalImageRender 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/09/10. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /chapter_13/01_MetalImageRender/MetalImageRender/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /chapter_13/01_MetalImageRender/MetalImageRender/Assets.xcassets/highsierra.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "filename" : "highsierra@3x.jpg", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_13/01_MetalImageRender/MetalImageRender/Assets.xcassets/highsierra.imageset/highsierra@3x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/01_MetalImageRender/MetalImageRender/Assets.xcassets/highsierra.imageset/highsierra@3x.jpg -------------------------------------------------------------------------------- /chapter_13/01_MetalImageRender/MetalImageRender/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarHidden 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /chapter_13/01_MetalImageRender/MetalImageRender/highsierra@3x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/01_MetalImageRender/MetalImageRender/highsierra@3x.jpg -------------------------------------------------------------------------------- /chapter_13/02_MetalShaderColorFill/MetalShaderColorFill.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MetalShaderColorFill 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/09/10. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarHidden 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/Shaders.metal: -------------------------------------------------------------------------------- 1 | // 2 | // Shaders.metal 3 | // MetalShaderColorFill 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/09/23. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct ColorInOut 13 | { 14 | float4 position [[ position ]]; 15 | }; 16 | 17 | vertex ColorInOut vertexShader(device float4 *positions [[ buffer(0) ]], 18 | uint vid [[ vertex_id ]]) 19 | { 20 | ColorInOut out; 21 | out.position = positions[vid]; 22 | return out; 23 | } 24 | 25 | fragment float4 fragmentShader(ColorInOut in [[ stage_in ]]) 26 | { 27 | return float4(1,0,0,1); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/highsierra@3x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/02_MetalShaderColorFill/MetalShaderColorFill/highsierra@3x.jpg -------------------------------------------------------------------------------- /chapter_13/03_MetalShaderImageRender/MetalShaderImageRender.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MetalShaderImageRender 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/09/10. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Assets.xcassets/highsierra.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "filename" : "highsierra@3x.jpg", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Assets.xcassets/highsierra.imageset/highsierra@3x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Assets.xcassets/highsierra.imageset/highsierra@3x.jpg -------------------------------------------------------------------------------- /chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarHidden 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/Shaders.metal: -------------------------------------------------------------------------------- 1 | // 2 | // Shaders.metal 3 | // MetalShaderImageRender 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/09/23. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | #include 10 | using namespace metal; 11 | 12 | struct ColorInOut 13 | { 14 | float4 position [[ position ]]; 15 | float2 texCoords; 16 | }; 17 | 18 | vertex ColorInOut vertexShader(device float4 *positions [[ buffer(0) ]], 19 | device float2 *texCoords [[ buffer(1) ]], 20 | uint vid [[ vertex_id ]]) 21 | { 22 | ColorInOut out; 23 | out.position = positions[vid]; 24 | out.texCoords = texCoords[vid]; 25 | return out; 26 | } 27 | 28 | fragment float4 fragmentShader(ColorInOut in [[ stage_in ]], 29 | texture2d texture [[ texture(0) ]]) 30 | { 31 | constexpr sampler colorSampler; 32 | float4 color = texture.sample(colorSampler, in.texCoords); 33 | return color; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/highsierra@3x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/03_MetalShaderImageRender/MetalShaderImageRender/highsierra@3x.jpg -------------------------------------------------------------------------------- /chapter_13/04_ARMetal1/ARMetal/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARMetal1 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_13/04_ARMetal1/ARMetal1.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_13/05_ARMetal2/ARMetal/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARMetal2 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_13/05_ARMetal2/ARMetal2.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_13/06_ARMetalArgumentBuffers/ARMetalArgumentBuffers.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_13/06_ARMetalArgumentBuffers/ARMetalArgumentBuffers/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ARMetalArgumentBuffers 4 | // 5 | // Created by Shuichi Tsutsumi on 2017/07/17. 6 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /chapter_13/common/SceneKitUtils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneKitUtils.swift 3 | // 4 | // Created by Shuichi Tsutsumi on 2017/09/04. 5 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 6 | // 7 | 8 | import SceneKit 9 | 10 | func + (left: SCNVector3, right: SCNVector3) -> SCNVector3 { 11 | return SCNVector3Make(left.x + right.x, left.y + right.y, left.z + right.z) 12 | } 13 | 14 | func += (left: inout SCNVector3, right: SCNVector3) { 15 | left = left + right 16 | } 17 | 18 | func - (left: SCNVector3, right: SCNVector3) -> SCNVector3 { 19 | return SCNVector3Make(left.x - right.x, left.y - right.y, left.z - right.z) 20 | } 21 | 22 | func * (vector: SCNVector3, scalar: Float) -> SCNVector3 { 23 | return SCNVector3Make(vector.x * scalar, vector.y * scalar, vector.z * scalar) 24 | } 25 | 26 | func / (left: SCNVector3, right: Float) -> SCNVector3 { 27 | return SCNVector3Make(left.x / right, left.y / right, left.z / right) 28 | } 29 | 30 | func /= (left: inout SCNVector3, right: Float) { 31 | left = left / right 32 | } 33 | 34 | extension SCNVector3 { 35 | func length() -> Float { 36 | return sqrtf(x * x + y * y + z * z) 37 | } 38 | } 39 | 40 | extension matrix_float4x4 { 41 | func position() -> SCNVector3 { 42 | let mat = SCNMatrix4(self) 43 | return SCNVector3(mat.m41, mat.m42, mat.m43) 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /chapter_13/common/TrackingState+Description.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TrackingState+Description.swift 3 | // 4 | // Created by Shuichi Tsutsumi on 2017/08/25. 5 | // Copyright © 2017 Shuichi Tsutsumi. All rights reserved. 6 | // 7 | 8 | import ARKit 9 | 10 | extension ARCamera.TrackingState { 11 | public var description: String { 12 | switch self { 13 | case .notAvailable: 14 | return "TRACKING UNAVAILABLE" 15 | case .normal: 16 | return "TRACKING NORMAL" 17 | case .limited(let reason): 18 | switch reason { 19 | case .excessiveMotion: 20 | return "TRACKING LIMITED\nToo much camera movement" 21 | case .insufficientFeatures: 22 | return "TRACKING LIMITED\nNot enough surface detail" 23 | case .initializing: 24 | return "Tracking LIMITED\nInitialization in progress." 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /chapter_13/models.scnassets/duck/duck-license.txt: -------------------------------------------------------------------------------- 1 | ---UPDATED 2/21/2007 2 | Scaled down the duck to a more reasonable size, removed physics scene, removed extra "dummy" transforms and pivot points, added camera and light. 3 | --- 4 | 5 | This model is a typical bathtub rubber duck. It uses a single texture. 6 | 7 | One version uses a polylist the other is triangles only. 8 | 9 | The model has been stripped of all tags and should be COLLADA 1.4.1 compliant. 10 | 11 | For additional information post messages on www.collada.org or mail collada@collada.org 12 | 13 | These models are Copyright 2006 Sony Computer Entertainment Inc. and are distributed under the terms of the SCEA Shared Source License, available at http://research.scea.com/scea_shared_source_license.html -------------------------------------------------------------------------------- /chapter_13/models.scnassets/duck/duck.scn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/models.scnassets/duck/duck.scn -------------------------------------------------------------------------------- /chapter_13/models.scnassets/duck/textures/duckCM.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_13/models.scnassets/duck/textures/duckCM.tga -------------------------------------------------------------------------------- /chapter_14/AVAudioEnginePlayWithReverb.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | import AVFoundation 2 | import PlaygroundSupport 3 | 4 | let sourceFileURL = Bundle.main.url(forResource: "source", withExtension: "caf")! 5 | let sourceFile = try! AVAudioFile(forReading: sourceFileURL) 6 | let format = sourceFile.processingFormat 7 | 8 | let engine = AVAudioEngine() 9 | 10 | //Nodeを準備する 11 | let player = AVAudioPlayerNode() 12 | let reverb = AVAudioUnitReverb() 13 | 14 | //AVAudioEngineに関連付けする 15 | engine.attach(player) 16 | engine.attach(reverb) 17 | 18 | // リバーブのパラメーターをセットする。ここでは中規模ホールの残響のプリセットを読み込んでいる 19 | reverb.loadFactoryPreset(.mediumHall) 20 | reverb.wetDryMix = 50 21 | 22 | // Audio Unit(のNode)を接続する。 23 | // player -> reverb -> mainMixer の順に接続している 24 | engine.connect(player, to: reverb, format: format) 25 | engine.connect(reverb, to: engine.mainMixerNode, format: format) 26 | 27 | // 再生するオーディオファイルをセット 28 | player.scheduleFile(sourceFile, at: nil) 29 | 30 | // 再生を開始 31 | try! engine.start() 32 | player.play() 33 | 34 | PlaygroundPage.current.needsIndefiniteExecution = true 35 | -------------------------------------------------------------------------------- /chapter_14/AVAudioEnginePlayWithReverb.playground/Resources/source.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AVAudioEnginePlayWithReverb.playground/Resources/source.caf -------------------------------------------------------------------------------- /chapter_14/AVAudioEnginePlayWithReverb.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2/AirPlay2Test.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2/AirPlay2Test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2/AirPlay2Test/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // AirPlay2Test 4 | // 5 | // Created by 7gano on 2017/07/25. 6 | // Copyright © 2017 ROLLCAKE. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AVKit 11 | 12 | class ViewController: UIViewController { 13 | 14 | let sampleBufferAudioPlayer = SampleBufferAudioPlayer() 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | do { 20 | let audioSession = AVAudioSession.sharedInstance() 21 | try audioSession.setCategory(AVAudioSessionCategoryPlayback, 22 | mode: AVAudioSessionModeDefault, 23 | routeSharingPolicy: .longForm) 24 | 25 | try audioSession.setActive(true) 26 | } catch { 27 | fatalError("\(error)") 28 | } 29 | 30 | let routePickerView = AVRoutePickerView() 31 | self.view.addSubview(routePickerView) 32 | routePickerView.translatesAutoresizingMaskIntoConstraints = false 33 | routePickerView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true 34 | routePickerView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true 35 | 36 | sampleBufferAudioPlayer.play() 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2/AirPlay2Test/source.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AirPlay2/AirPlay2Test/source.caf -------------------------------------------------------------------------------- /chapter_14/AirPlay2/AirPlay2TestTests/AirPlay2TestTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AirPlay2TestTests.swift 3 | // AirPlay2TestTests 4 | // 5 | // Created by 7gano on 2017/07/25. 6 | // Copyright © 2017 ROLLCAKE. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import AirPlay2Test 11 | 12 | class AirPlay2TestTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2/AirPlay2TestTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2/AirPlay2TestUITests/AirPlay2TestUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AirPlay2TestUITests.swift 3 | // AirPlay2TestUITests 4 | // 5 | // Created by 7gano on 2017/07/25. 6 | // Copyright © 2017 ROLLCAKE. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class AirPlay2TestUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // 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. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2/AirPlay2TestUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/AirPlay2Test-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | 6 | #import "Utility.h" 7 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // AirPlay2Test 4 | // 5 | // Created by 7gano on 2017/07/25. 6 | // Copyright © 2017 ROLLCAKE. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AVKit 11 | 12 | class ViewController: UIViewController { 13 | 14 | let sampleBufferAudioPlayer = SampleBufferAudioPlayer() 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | do { 20 | let audioSession = AVAudioSession.sharedInstance() 21 | try audioSession.setCategory(AVAudioSessionCategoryPlayback, 22 | mode: AVAudioSessionModeDefault, 23 | routeSharingPolicy: .longForm) 24 | 25 | try audioSession.setActive(true) 26 | } catch { 27 | fatalError("\(error)") 28 | } 29 | 30 | let routePickerView = AVRoutePickerView() 31 | self.view.addSubview(routePickerView) 32 | routePickerView.translatesAutoresizingMaskIntoConstraints = false 33 | routePickerView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true 34 | routePickerView.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true 35 | 36 | sampleBufferAudioPlayer.play() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/mixLoop.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/mixLoop.caf -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/podcast #012.m4a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2Test/podcast #012.m4a -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2TestTests/AirPlay2TestTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AirPlay2TestTests.swift 3 | // AirPlay2TestTests 4 | // 5 | // Created by 7gano on 2017/07/25. 6 | // Copyright © 2017 ROLLCAKE. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import AirPlay2Test 11 | 12 | class AirPlay2TestTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2TestTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2TestUITests/AirPlay2TestUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AirPlay2TestUITests.swift 3 | // AirPlay2TestUITests 4 | // 5 | // Created by 7gano on 2017/07/25. 6 | // Copyright © 2017 ROLLCAKE. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class AirPlay2TestUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // 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. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /chapter_14/AirPlay2_with_AVAudioEngine/AirPlay2TestUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter_14/AudioEngineManualRendering.playground/Resources/source.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peaks-cc/iOS11samplecode/ce8c8e8932d7a0124d30b781773ae02cba54c949/chapter_14/AudioEngineManualRendering.playground/Resources/source.caf -------------------------------------------------------------------------------- /chapter_14/AudioEngineManualRendering.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | --------------------------------------------------------------------------------