├── .DS_Store
├── .gitattributes
├── 001. NNObserver
├── NNObserver.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ ├── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── yizhilu.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── liupengkun.xcuserdatad
│ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── yizhilu.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNObserver
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNFirstViewController.h
│ ├── NNFirstViewController.m
│ ├── NNObserver.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNObserver.xcdatamodel
│ │ │ └── contents
│ ├── NNSecondViewController.h
│ ├── NNSecondViewController.m
│ ├── NNThirdViewController.h
│ ├── NNThirdViewController.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── NNObserverTests
│ ├── Info.plist
│ └── NNObserverTests.m
└── README.md
├── 002. NNRuntimeTest
├── NNRuntimeTest.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ ├── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── pengqianqian.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── liupengkun.xcuserdatad
│ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── pengqianqian.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNRuntimeTest
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNHomeTableView.h
│ ├── NNHomeTableView.m
│ ├── NNHomeViewController.h
│ ├── NNHomeViewController.m
│ ├── NNRuntimeTest.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNRuntimeTest.xcdatamodel
│ │ │ └── contents
│ ├── NNRuntimeTest
│ │ ├── Category
│ │ │ ├── NSObject+NNAddAttribute.h
│ │ │ ├── NSObject+NNAddAttribute.m
│ │ │ ├── NSObject+NNKeyValues.h
│ │ │ └── NSObject+NNKeyValues.m
│ │ ├── Controller
│ │ │ ├── NNBaseViewController.h
│ │ │ ├── NNBaseViewController.m
│ │ │ ├── NNEighthViewController.h
│ │ │ ├── NNEighthViewController.m
│ │ │ ├── NNFifthViewController.h
│ │ │ ├── NNFifthViewController.m
│ │ │ ├── NNFirstViewController.h
│ │ │ ├── NNFirstViewController.m
│ │ │ ├── NNFourthViewController.h
│ │ │ ├── NNFourthViewController.m
│ │ │ ├── NNSecondViewController.h
│ │ │ ├── NNSecondViewController.m
│ │ │ ├── NNSeventhViewController.h
│ │ │ ├── NNSeventhViewController.m
│ │ │ ├── NNSixthViewController.h
│ │ │ ├── NNSixthViewController.m
│ │ │ ├── NNThirdViewController.h
│ │ │ └── NNThirdViewController.m
│ │ ├── Model
│ │ │ ├── NNCoding.h
│ │ │ ├── NNCoding.m
│ │ │ ├── NNLibrary.h
│ │ │ ├── NNLibrary.m
│ │ │ ├── NNPerson.h
│ │ │ └── NNPerson.m
│ │ └── View
│ │ │ ├── NNCountButton.h
│ │ │ └── NNCountButton.m
│ └── main.m
├── NNRuntimeTestTests
│ ├── Info.plist
│ └── NNRuntimeTestTests.m
└── README.md
├── 003. NNAlgorithm
├── NNAlgorithm.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNAlgorithm
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNAlgorithm.cpp
│ ├── NNAlgorithm.hpp
│ ├── NNAlgorithm.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNAlgorithm.xcdatamodel
│ │ │ └── contents
│ ├── NNAlgorithm
│ │ ├── NNAlgorithm.h
│ │ └── NNAlgorithm.m
│ ├── ViewController.h
│ ├── ViewController.mm
│ └── main.m
├── NNAlgorithmTests
│ ├── Info.plist
│ └── NNAlgorithmTests.m
└── README.md
├── 004. NNLayerTest
├── NNLayerTest.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ ├── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── yizhilu.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── yizhilu.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNLayerTest
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── header.imageset
│ │ │ ├── Contents.json
│ │ │ └── header.jpg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNLayerTest.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNLayerTest.xcdatamodel
│ │ │ └── contents
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── NNLayerTestTests
│ ├── Info.plist
│ └── NNLayerTestTests.m
└── README.md
├── 005. NNStackView
├── Demo figure
│ └── figure.png
├── NNStackView.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ ├── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── yizhilu.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── yizhilu.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNStackView
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNStackView.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNStackView.xcdatamodel
│ │ │ └── contents
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── NNStackViewTests
│ ├── Info.plist
│ └── NNStackViewTests.m
└── README.md
├── 006. NNSortDescriptor
├── NNSortDescriptor.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ ├── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── yizhilu.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ ├── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── yizhilu.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNSortDescriptor
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNDevelopers.h
│ ├── NNDevelopers.m
│ ├── NNSortDescriptor.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNSortDescriptor.xcdatamodel
│ │ │ └── contents
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── NNSortDescriptorTests
│ ├── Info.plist
│ └── NNSortDescriptorTests.m
└── README.md
├── 007.iOS 奇技淫巧总结
└── README.md
├── 008.MVVMDemo
├── MVVMDemo.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── MVVMDemo
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── MVVMDemo.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── MVVMDemo.xcdatamodel
│ │ │ └── contents
│ ├── NNModel.h
│ ├── NNModel.m
│ ├── NNView.h
│ ├── NNView.m
│ ├── NNViewController.h
│ ├── NNViewController.m
│ ├── NNViewModel.h
│ ├── NNViewModel.m
│ └── main.m
├── MVVMDemoTests
│ ├── Info.plist
│ └── MVVMDemoTests.m
└── README.md
├── 009.MVCDemo
├── MVCDemo.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── MVCDemo
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── MVCDemo.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── MVCDemo.xcdatamodel
│ │ │ └── contents
│ ├── NNDataModel.h
│ ├── NNDataModel.m
│ ├── NNModel.h
│ ├── NNModel.m
│ ├── NNView.h
│ ├── NNView.m
│ ├── NNViewController.h
│ ├── NNViewController.m
│ └── main.m
├── MVCDemoTests
│ ├── Info.plist
│ └── MVCDemoTests.m
└── README.md
├── 010.NNLoad
├── NNLoad.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNLoad
│ ├── .DS_Store
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNParentClassView+extension.h
│ ├── NNParentClassView+extension.m
│ ├── NNParentClassView.h
│ ├── NNParentClassView.m
│ ├── NNSubViewController+extension.h
│ ├── NNSubViewController+extension.m
│ ├── NNSubViewController.h
│ ├── NNSubViewController.m
│ ├── NNSubclassView+extension.h
│ ├── NNSubclassView+extension.m
│ ├── NNSubclassView.h
│ ├── NNSubclassView.m
│ ├── ViewController+extension.h
│ ├── ViewController+extension.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
└── README.md
├── 011.NN_GCDPractice
├── NN_GCDPractice.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NN_GCDPractice
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
└── README.md
├── 012.NN_NSOperationPractice
├── NN_ NSOperationPractice.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NN_ NSOperationPractice
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNNSOperation.h
│ ├── NNNSOperation.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
└── README.md
├── 013.NN_NSThreadPractice
├── NN_NSThreadPractice.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NN_NSThreadPractice
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
└── README.md
├── 014.NNMultipleDelegate
├── NNMultipleDelegate.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNMultipleDelegate
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── dog01.imageset
│ │ │ ├── Contents.json
│ │ │ └── dog01.jpg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNLabel.h
│ ├── NNLabel.m
│ ├── NNMultipleDelegate
│ │ ├── NNMultipleDelegateHelper.h
│ │ └── NNMultipleDelegateHelper.m
│ ├── NNStretchHeaderView.h
│ ├── NNStretchHeaderView.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
└── README.md
├── 015.NN_UIViewAnimationPractice
├── .DS_Store
├── NN_UIViewAnimationPractice.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NN_UIViewAnimationPractice
│ ├── .DS_Store
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── header.imageset
│ │ │ ├── Contents.json
│ │ │ └── header.jpeg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNViewController.h
│ ├── NNViewController.m
│ ├── UIViewAnimationPractice
│ │ ├── .DS_Store
│ │ ├── Controllers
│ │ │ ├── NNAlphaAnimationViewController.h
│ │ │ ├── NNAlphaAnimationViewController.m
│ │ │ ├── NNBackgroundAnimationViewController.h
│ │ │ ├── NNBackgroundAnimationViewController.m
│ │ │ ├── NNBaseViewController.h
│ │ │ ├── NNBaseViewController.m
│ │ │ ├── NNFrameAnimationController.h
│ │ │ ├── NNFrameAnimationController.m
│ │ │ ├── NNSpringAnimationController.h
│ │ │ ├── NNSpringAnimationController.m
│ │ │ ├── NNTransformController.h
│ │ │ ├── NNTransformController.m
│ │ │ ├── NNTransitionAnimationController.h
│ │ │ └── NNTransitionAnimationController.m
│ │ └── Views
│ │ │ ├── NNBottomView.h
│ │ │ ├── NNBottomView.m
│ │ │ ├── NNView.h
│ │ │ └── NNView.m
│ └── main.m
└── README.md
├── 016.NNCoreAnimation
├── .DS_Store
├── NNCoreAnimation.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── liupengkun.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── liupengkun.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNCoreAnimation
│ ├── .DS_Store
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── header.imageset
│ │ │ ├── Contents.json
│ │ │ └── header.jpeg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Controllers
│ │ ├── .DS_Store
│ │ ├── NNBaseViewController.h
│ │ ├── NNBaseViewController.m
│ │ ├── NNOthersViewController.h
│ │ ├── NNOthersViewController.m
│ │ ├── NNPositionViewController.h
│ │ ├── NNPositionViewController.m
│ │ ├── NNRotationViewController.h
│ │ ├── NNRotationViewController.m
│ │ ├── NNScaleViewController.h
│ │ └── NNScaleViewController.m
│ ├── Info.plist
│ ├── ViewController.h
│ ├── ViewController.m
│ ├── Views
│ │ ├── NNBottomView.h
│ │ ├── NNBottomView.m
│ │ ├── NNView.h
│ │ └── NNView.m
│ └── main.m
└── README.md
├── 017.NN_UIViewAnimationPractice_swift
├── NN_UIViewAnimationPractice_swift.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── DJ.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── DJ.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NN_UIViewAnimationPractice_swift
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── header.imageset
│ │ │ ├── Contents.json
│ │ │ └── header.jpeg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NN_UIViewAnimationPractice_swift.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NN_UIViewAnimationPractice_swift.xcdatamodel
│ │ │ └── contents
│ ├── UIViewAnimationPractice
│ │ ├── Controllers
│ │ │ ├── NNAlphaAnimationViewController.swift
│ │ │ ├── NNBackgroundAnimationViewController.swift
│ │ │ ├── NNBaseViewController.swift
│ │ │ ├── NNFrameAnimationController.swift
│ │ │ ├── NNSpringAnimationController.swift
│ │ │ ├── NNTransformController.swift
│ │ │ └── NNTransitionAnimationController.swift
│ │ └── Views
│ │ │ ├── NNBottomView.swift
│ │ │ └── NNView.swift
│ └── ViewController.swift
├── NN_UIViewAnimationPractice_swiftTests
│ ├── Info.plist
│ └── NN_UIViewAnimationPractice_swiftTests.swift
├── NN_UIViewAnimationPractice_swiftUITests
│ ├── Info.plist
│ └── NN_UIViewAnimationPractice_swiftUITests.swift
└── README.md
├── 018.NNCoreAnimation_swift
├── NNCoreAnimation_swift.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── DJ.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── DJ.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNCoreAnimation_swift
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── header.imageset
│ │ │ ├── Contents.json
│ │ │ └── header.jpeg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNCoreAnimation_swift.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNCoreAnimation_swift.xcdatamodel
│ │ │ └── contents
│ ├── NNCoreAnimation_swift
│ │ ├── Controllers
│ │ │ ├── NNBaseViewController.swift
│ │ │ ├── NNOthersViewController.swift
│ │ │ ├── NNPositionViewController.swift
│ │ │ ├── NNRotationViewController.swift
│ │ │ └── NNScaleViewController.swift
│ │ └── Views
│ │ │ ├── NNBottomView.swift
│ │ │ └── NNView.swift
│ └── ViewController.swift
├── NNCoreAnimation_swiftTests
│ ├── Info.plist
│ └── NNCoreAnimation_swiftTests.swift
├── NNCoreAnimation_swiftUITests
│ ├── Info.plist
│ └── NNCoreAnimation_swiftUITests.swift
└── README.md
├── 019.NNResponderTest
├── NNResponderTest.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── DJ.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── DJ.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNResponderTest
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ ├── Contents.json
│ │ └── header.imageset
│ │ │ ├── Contents.json
│ │ │ └── header.jpeg
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNResponderTest.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNResponderTest.xcdatamodel
│ │ │ └── contents
│ ├── NNTableView.h
│ ├── NNTableView.m
│ ├── NNTableViewCell.h
│ ├── NNTableViewCell.m
│ ├── NNTableViewCell.xib
│ ├── UIResponder+responder.h
│ ├── UIResponder+responder.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
├── NNResponderTestTests
│ ├── Info.plist
│ └── NNResponderTestTests.m
├── NNResponderTestUITests
│ ├── Info.plist
│ └── NNResponderTestUITests.m
└── README.md
├── 020.NNSwiftOCProgram
├── NNSwiftOCProgram.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── DJ.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── DJ.xcuserdatad
│ │ ├── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
├── NNSwiftOCProgram
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── Info.plist
│ ├── NNSwiftOCProgram-Bridging-Header.h
│ ├── NNSwiftOCProgram.xcdatamodeld
│ │ ├── .xccurrentversion
│ │ └── NNSwiftOCProgram.xcdatamodel
│ │ │ └── contents
│ ├── NNView.swift
│ ├── NNViewController.h
│ ├── NNViewController.m
│ └── ViewController.swift
├── NNSwiftOCProgramTests
│ ├── Info.plist
│ └── NNSwiftOCProgramTests.swift
├── NNSwiftOCProgramUITests
│ ├── Info.plist
│ └── NNSwiftOCProgramUITests.swift
└── README.md
├── LICENSE
└── README.md
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/.DS_Store
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/001. NNObserver/NNObserver.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/001. NNObserver/NNObserver.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNObserver.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver.xcodeproj/xcuserdata/yizhilu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver.xcodeproj/xcuserdata/yizhilu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNObserver.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNObserver
4 | //
5 | // Created by yizhilu on 2018/6/20.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/NNFirstViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNFirstViewController.h
3 | // NNObserver
4 | //
5 | // Created by yizhilu on 2018/6/20.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNFirstViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/NNObserver.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNObserver.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/NNObserver.xcdatamodeld/NNObserver.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/NNSecondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSecondViewController.h
3 | // NNObserver
4 | //
5 | // Created by yizhilu on 2018/6/20.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNSecondViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/NNThirdViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNThirdViewController.h
3 | // NNObserver
4 | //
5 | // Created by yizhilu on 2018/6/20.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNThirdViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNObserver
4 | //
5 | // Created by yizhilu on 2018/6/20.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // NNObserver
4 | //
5 | // Created by yizhilu on 2018/6/20.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | }
20 |
21 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
22 | UIViewController *vc = [NSClassFromString(@"NNFirstViewController") new];
23 | [self.navigationController pushViewController:vc animated:YES];
24 | }
25 |
26 | - (void)didReceiveMemoryWarning {
27 | [super didReceiveMemoryWarning];
28 | // Dispose of any resources that can be recreated.
29 | }
30 |
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserver/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNObserver
4 | //
5 | // Created by yizhilu on 2018/6/20.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserverTests/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 |
--------------------------------------------------------------------------------
/001. NNObserver/NNObserverTests/NNObserverTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNObserverTests.m
3 | // NNObserverTests
4 | //
5 | // Created by yizhilu on 2018/6/20.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNObserverTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NNObserverTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/001. NNObserver/README.md:
--------------------------------------------------------------------------------
1 | ### 练习观察者模式中的 `NSNotificationCenter` 与 `KVO`, 对比两者之间的区别与联系;
2 |
3 | #### NSNotificationCenter
4 |
5 | - 观察者 Observer,通过 NSNotificationCenter 的`addObserver:selector:name:object` 接口来注册对某一类型通知感兴趣。在注册时候一定要注意,NSNotificationCenter 不会对观察者进行引用计数 +1 的操作,我们在程序中释放观察者的时候,一定要去报从 Center 中将其注销了。
6 | - 通知中心 NSNotificationCenter,通知的枢纽。
7 | - 被观察的对象,通过 `postNotificationName:object:userInfo:` 发送某一类型通知,广播改变。
8 | - 通知对象 NSNotification,当有通知来的时候,Center 会调用观察者注册的接口来广播通知,同时传递存储着更改内容的 NSNotification 对象。
9 |
10 |
11 | #### KVO
12 |
13 | > KVO 的全称是 `Key-Value Observer`,即键值观察。是一种没有中心枢纽的观察者模式的实现方式。一个主题对象管理所有依赖于它的观察者对象,并且在自身状态发生改变的时候主动通知观察者对象。
14 |
15 | - 注册观察者 `[object addObserver:self forKeyPath:property options:NSKeyValueObservingOptionNew context:]。`
16 | - 更改主题对象属性的值,即触发发送更改的通知。
17 | - 在制定的回调函数中,处理收到的更改通知。
18 | - 注销观察者 `[object removeObserver:self forKeyPath:property]。`
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/002. NNRuntimeTest/NNRuntimeTest.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest.xcodeproj/project.xcworkspace/xcuserdata/pengqianqian.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/002. NNRuntimeTest/NNRuntimeTest.xcodeproj/project.xcworkspace/xcuserdata/pengqianqian.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNRuntimeTest.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest.xcodeproj/xcuserdata/pengqianqian.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNRuntimeTest.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNHomeTableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNHomeTableView.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol NNHomeTableViewDelegate
12 | @optional
13 | - (void)didSelectRowWithController:(UIViewController *)controller;
14 |
15 | @end
16 |
17 | @interface NNHomeTableView : UITableView
18 |
19 | @property (nonatomic, weak) id homeTableViewDelegate;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNHomeViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNHomeViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNHomeViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNHomeViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNHomeViewController.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNHomeViewController.h"
10 | #import "NNHomeTableView.h"
11 |
12 | @interface NNHomeViewController ()
13 |
14 | @property (nonatomic, strong) NNHomeTableView *homeTableView;
15 |
16 | @end
17 |
18 | @implementation NNHomeViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | self.view.backgroundColor = [UIColor whiteColor];
23 | [self.view addSubview:self.homeTableView];
24 | }
25 |
26 | #pragma mark - 代理区域
27 | - (void)didSelectRowWithController:(UIViewController *)controller {
28 | [self.navigationController pushViewController:controller animated:YES];
29 | }
30 |
31 | #pragma mark - 懒加载区域
32 | - (NNHomeTableView *)homeTableView {
33 | if (!_homeTableView) {
34 | _homeTableView = [[NNHomeTableView alloc] initWithFrame:self.view.frame];
35 | _homeTableView.homeTableViewDelegate = self;
36 | }
37 | return _homeTableView;
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNRuntimeTest.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest.xcdatamodeld/NNRuntimeTest.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Category/NSObject+NNAddAttribute.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+NNAddAttribute.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NSObject (NNAddAttribute)
12 |
13 | @property (nonatomic, copy) NSString *name;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Category/NSObject+NNAddAttribute.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+NNAddAttribute.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NSObject+NNAddAttribute.h"
10 | #import
11 |
12 | @implementation NSObject (NNAddAttribute)
13 |
14 | - (void)setName:(NSString *)name {
15 | objc_setAssociatedObject(self, @"name", name, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
16 | }
17 |
18 | - (NSString *)name {
19 | return objc_getAssociatedObject(self, @"name");
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Category/NSObject+NNKeyValues.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSObject+NNKeyValues.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/22.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol ModelDelegate
12 | @optional
13 | // 用在三级数组转换
14 | + (NSDictionary *)arrayContainModelClass;
15 |
16 | @end
17 |
18 | @interface NSObject (NNKeyValues)
19 |
20 | /** 字典转模型 **/
21 | + (instancetype)modelWithDict:(NSDictionary *)dict;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNBaseViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNBaseViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface NNBaseViewController : UIViewController
13 | /**
14 | * 初始化View
15 | */
16 | - (void)initView;
17 |
18 | /**
19 | * 按钮的数组元素
20 | *
21 | * @return 数组
22 | */
23 | - (NSArray *)buttonTitleArray;
24 |
25 | /**
26 | * 按钮的点击事件
27 | */
28 | - (void)buttonClick:(UIButton *)sender;
29 |
30 | /**
31 | * 标签的显示文本
32 | */
33 | @property (nonatomic, copy) NSString *testLabelText;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNEighthViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNEighthViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNEighthViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNFifthViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNFifthViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNFifthViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNFifthViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNFifthViewController.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNFifthViewController.h"
10 | #import "NNPerson.h"
11 | #import "NNLibrary.h"
12 |
13 | @interface NNFifthViewController ()
14 |
15 | @property (nonatomic, strong) NNPerson *person;
16 |
17 | @property (nonatomic, strong) NNLibrary *library;
18 |
19 | @end
20 |
21 | @implementation NNFifthViewController
22 |
23 | - (void)initView {
24 | [super initView];
25 | _person = [NNPerson new];
26 | _library = [NNLibrary new];
27 | self.testLabelText = [_library libraryMethod];
28 | Method oriMethod = class_getInstanceMethod(_person.class, @selector(changeMethod));
29 | Method curMethod = class_getInstanceMethod(_library.class, @selector(libraryMethod));
30 | method_exchangeImplementations(oriMethod, curMethod);
31 | }
32 |
33 | - (void)buttonClick:(UIButton *)sender {
34 | self.testLabelText = [_library libraryMethod];
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNFirstViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNFirstViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNFirstViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNFirstViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNFirstViewController.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNFirstViewController.h"
10 | #import "NNPerson.h"
11 |
12 | @interface NNFirstViewController ()
13 |
14 | @property (nonatomic, strong) NNPerson *person;
15 |
16 | @end
17 |
18 | @implementation NNFirstViewController
19 |
20 | - (void)initView {
21 | [super initView];
22 | _person = [NNPerson new];
23 | }
24 |
25 | - (void)buttonClick:(UIButton *)sender {
26 | unsigned int count = 0;
27 | // 动态获取类中的所有属性(包括私有)
28 | Ivar *ivar = class_copyIvarList(_person.class, &count);
29 | // 遍历属性找到对应字段
30 | for (int i = 0; i < count; i ++) {
31 | Ivar tempIvar = ivar[i];
32 | const char *varChar = ivar_getName(tempIvar);
33 | NSString *varString = [NSString stringWithUTF8String:varChar];
34 | if ([varString isEqualToString:@"_name"]) {
35 | // 修改对应的字段值
36 | object_setIvar(_person, tempIvar, @"更改属性值成功");
37 | break;
38 | }
39 | }
40 | free(ivar);
41 | self.testLabelText = _person.name.length ? _person.name : @"更改属性值失败";
42 | }
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNFourthViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNFourthViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNFourthViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNFourthViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNFourthViewController.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNFourthViewController.h"
10 | #import "NNPerson.h"
11 |
12 | @interface NNFourthViewController ()
13 |
14 | @property (nonatomic, strong) NNPerson *person;
15 |
16 | @end
17 |
18 | @implementation NNFourthViewController
19 |
20 | - (void)initView {
21 | [super initView];
22 | _person = [NNPerson new];
23 | NSLog(@"%@",_person.coding);
24 | NSLog(@"%@",_person.eating);
25 | Method oriMethod = class_getInstanceMethod(_person.class, @selector(coding));
26 | Method curMethod = class_getInstanceMethod(_person.class, @selector(eating));
27 | method_exchangeImplementations(oriMethod, curMethod);
28 | }
29 |
30 | - (NSArray *)buttonTitleArray {
31 | return @[@"coding", @"eating"];
32 | }
33 |
34 | - (void)buttonClick:(UIButton *)sender {
35 | if (sender.tag == 0) {
36 | self.testLabelText = [_person coding];
37 | } else {
38 | self.testLabelText = [_person eating];
39 | }
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNSecondViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSecondViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNSecondViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNSecondViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNSecondViewController.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNSecondViewController.h"
10 | #import "NSObject+NNAddAttribute.h"
11 |
12 | @interface NNSecondViewController ()
13 |
14 | @property (nonatomic, strong) NSObject *person;
15 |
16 | @end
17 |
18 | @implementation NNSecondViewController
19 |
20 | - (void)initView {
21 | [super initView];
22 | _person = [NSObject new];
23 | _person.name = @"添加属性成功";
24 | }
25 |
26 | - (void)buttonClick:(UIButton *)sender {
27 | self.testLabelText = _person.name.length ? _person.name : @"添加属性失败";
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNSeventhViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSeventhViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNSeventhViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNSeventhViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNSeventhViewController.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNSeventhViewController.h"
10 | #import "NNCoding.h"
11 |
12 | @interface NNSeventhViewController ()
13 |
14 | @end
15 |
16 | @implementation NNSeventhViewController
17 |
18 | - (void)initView {
19 | [super initView];
20 | NNCoding *coding = [NNCoding new];
21 | coding.coderID = @"100";
22 | coding.nickName = @"以梦为马";
23 | coding.phoneNumber = @"110";
24 |
25 | NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject;
26 | path = [path stringByAppendingPathComponent:@"123"];
27 | [NSKeyedArchiver archiveRootObject:coding toFile:path];
28 | self.testLabelText = @"归档成功, 点击按钮取出模型中对应的值";
29 | }
30 |
31 | - (void)buttonClick:(UIButton *)sender {
32 | NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject;
33 | path = [path stringByAppendingPathComponent:@"123"];
34 | NNCoding *coding = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
35 | if (sender.tag == 0) {
36 | self.testLabelText = coding.coderID;
37 | } else if (sender.tag == 1) {
38 | self.testLabelText = coding.nickName;
39 | } else {
40 | self.testLabelText = coding.phoneNumber;
41 | }
42 | }
43 |
44 | - (NSArray *)buttonTitleArray {
45 | return @[@"ID", @"昵称", @"手机号"];
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNSixthViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSixthViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNSixthViewController : NNBaseViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNSixthViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNSixthViewController.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNSixthViewController.h"
10 | #import "NNCountButton.h"
11 |
12 | @interface NNSixthViewController ()
13 |
14 | @property (nonatomic, strong) NNCountButton *testButton;
15 |
16 | @end
17 |
18 | @implementation NNSixthViewController
19 |
20 | - (void)initView {
21 | [super initView];
22 | [self.view addSubview:self.testButton];
23 | }
24 |
25 | - (NSArray *)buttonTitleArray{
26 | return @[@"这", @"几", @"个", @"按", @"钮", @"不", @"统", @"计"];
27 | }
28 |
29 | - (void)buttonClick:(UIButton *)sender {
30 | self.testLabelText = @"此按钮不统计点击次数";
31 | }
32 |
33 | - (void)countButtonClick:(UIButton *)sender {
34 | self.testLabelText = [NSString stringWithFormat:@"点击 %ld 次了", self.testButton.count];
35 | }
36 |
37 | #pragma mark - 懒加载
38 | - (NNCountButton *)testButton {
39 | if (!_testButton) {
40 | _testButton = [NNCountButton buttonWithType:UIButtonTypeCustom];
41 | [_testButton addTarget:self action:@selector(countButtonClick:) forControlEvents:UIControlEventTouchUpInside];
42 | [_testButton setTitle:@"统计此按钮的点击数量" forState:UIControlStateNormal];
43 | _testButton.frame = CGRectMake(20, self.view.center.y + 100, [UIScreen mainScreen].bounds.size.width - 40, 30);
44 | _testButton.backgroundColor = [UIColor redColor];
45 | }
46 | return _testButton;
47 | }
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNThirdViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNThirdViewController.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNThirdViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Controller/NNThirdViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNThirdViewController.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNThirdViewController.h"
10 | #import "NNPerson.h"
11 |
12 | @interface NNThirdViewController ()
13 |
14 | @property (nonatomic, strong) NNPerson *person;
15 |
16 | @end
17 |
18 | @implementation NNThirdViewController
19 |
20 | - (void)initView {
21 | [super initView];
22 | _person = [NNPerson new];
23 | }
24 |
25 | - (void)buttonClick:(UIButton *)sender {
26 | /*
27 | 动态添加 coding 方法
28 | (IMP)codingOC 意思是 codingOC 的地址指针;
29 | "v@:" 意思是,v 代表无返回值 void,如果是 i 则代表 int;@代表 id sel; : 代表 SEL _cmd;
30 | “v@:@@” 意思是,两个参数的没有返回值。
31 | */
32 | class_addMethod([_person class], @selector(coding), (IMP)codingOC, "v@:");
33 | // 调用 coding 方法响应事件
34 | if ([_person respondsToSelector:@selector(coding)]) {
35 | [_person performSelector:@selector(coding)];
36 | self.testLabelText = @"添加方法成功";
37 | } else {
38 | self.testLabelText = @"添加方法失败";
39 | }
40 | }
41 |
42 | // 编写 codingOC 的实现
43 | void codingOC(id self,SEL _cmd) {
44 | NSLog(@"添加方法成功");
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Model/NNCoding.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNCoding.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/22.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NSObject+NNKeyValues.h"
11 | #import "NNPerson.h"
12 |
13 | @interface NNCoding : NSObject
14 |
15 | @property (nonatomic, strong) NNPerson *person;
16 |
17 | @property (nonatomic, copy) NSString *coderID;
18 | @property (nonatomic, copy) NSString *nickName;
19 | @property (nonatomic, copy) NSString *phoneNumber;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Model/NNLibrary.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNLibrary.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNLibrary : NSObject
12 |
13 | - (NSString *)libraryMethod;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Model/NNLibrary.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNLibrary.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNLibrary.h"
10 |
11 | @implementation NNLibrary
12 |
13 | - (NSString *)libraryMethod {
14 | return @"开源库出现 bug, 点击按钮替换此方法";
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Model/NNPerson.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNPerson.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNPerson : NSObject
12 |
13 | /** 姓名 **/
14 | @property (nonatomic, copy) NSString *name;
15 | /** 性别 **/
16 | @property (nonatomic, copy) NSString *sex;
17 |
18 | - (NSString *)coding;
19 | - (NSString *)eating;
20 | - (NSString *)changeMethod;
21 | @end
22 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/Model/NNPerson.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNPerson.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNPerson.h"
10 |
11 | @implementation NNPerson
12 |
13 | - (NSString *)coding {
14 | return @"coding";
15 | }
16 |
17 | - (NSString *)eating {
18 | return @"eating";
19 | }
20 |
21 | - (NSString *)changeMethod {
22 | return @"方法已被拦截并替换";
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/NNRuntimeTest/View/NNCountButton.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNCountButton.h
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNCountButton : UIButton
12 |
13 | @property (nonatomic, assign) NSInteger count;
14 |
15 | @end
16 |
17 |
18 | @interface NNClickCount : NSObject
19 |
20 | + (instancetype)sharedInstance;
21 |
22 | - (NSInteger)clickCount;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTest/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNRuntimeTest
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTestTests/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 |
--------------------------------------------------------------------------------
/002. NNRuntimeTest/NNRuntimeTestTests/NNRuntimeTestTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNRuntimeTestTests.m
3 | // NNRuntimeTestTests
4 | //
5 | // Created by liupengkun on 2018/6/21.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNRuntimeTestTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NNRuntimeTestTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/003. NNAlgorithm/NNAlgorithm.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNAlgorithm.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNAlgorithm
4 | //
5 | // Created by liupengkun on 2018/7/13.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/NNAlgorithm.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // NNAlgorithm.cpp
3 | // NNAlgorithm
4 | //
5 | // Created by liupengkun on 2018/7/13.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #include "NNAlgorithm.hpp"
10 |
11 | void LiveClass::SendData(void *rtmp){
12 | printf("OC 调用 C++\n");
13 | }
14 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/NNAlgorithm.hpp:
--------------------------------------------------------------------------------
1 | //
2 | // NNAlgorithm.hpp
3 | // NNAlgorithm
4 | //
5 | // Created by liupengkun on 2018/7/13.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #ifndef NNAlgorithm_hpp
10 | #define NNAlgorithm_hpp
11 |
12 | #include
13 |
14 | class LiveClass {
15 | public:
16 | static void SendData(void *);
17 | };
18 |
19 | #endif /* NNAlgorithm_hpp */
20 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/NNAlgorithm.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNAlgorithm.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/NNAlgorithm.xcdatamodeld/NNAlgorithm.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/NNAlgorithm/NNAlgorithm.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNAlgorithm.h
3 | // NNAlgorithm
4 | //
5 | // Created by liupengkun on 2018/7/14.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNAlgorithm : NSObject
12 |
13 | /** 1-n 阶乘之和 */
14 | - (NSInteger)factorialWithNumber:(NSInteger)number;
15 |
16 | /** 跳台阶问题 */
17 | - (NSInteger)jumpFloor:(NSInteger)number;
18 |
19 | /** 变态跳台阶问题 */
20 | - (NSInteger)jumpFloorII:(NSInteger)number;
21 |
22 | /** 求1+2+3+...+n */
23 | - (NSInteger)sum_Solution:(NSInteger)number;
24 |
25 | /** 不用加减乘除做加法 */
26 | - (NSInteger)sumA:(NSInteger)a b:(NSInteger)b;
27 |
28 | /** 圆圈中最后剩下的数 */
29 | - (NSInteger)lastRemaining_Solution:(NSInteger)n m:(NSInteger)m;
30 |
31 | /** 从 1 到 n 整数中 1 出现的次数 */
32 | - (NSInteger)numberOf1Between1AndN:(NSInteger)n;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNAlgorithm
4 | //
5 | // Created by liupengkun on 2018/7/13.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithm/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNAlgorithm
4 | //
5 | // Created by liupengkun on 2018/7/13.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithmTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | CFBundleIdentifier
7 | $(PRODUCT_BUNDLE_IDENTIFIER)
8 | CFBundleInfoDictionaryVersion
9 | 6.0
10 | CFBundleExecutable
11 | $(EXECUTABLE_NAME)
12 | CFBundleName
13 | $(PRODUCT_NAME)
14 | CFBundleDevelopmentRegion
15 | $(DEVELOPMENT_LANGUAGE)
16 | CFBundleShortVersionString
17 | 1.0
18 | CFBundleVersion
19 | 1
20 | CFBundlePackageType
21 | BNDL
22 |
23 |
24 |
--------------------------------------------------------------------------------
/003. NNAlgorithm/NNAlgorithmTests/NNAlgorithmTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNAlgorithmTests.m
3 | // NNAlgorithmTests
4 | //
5 | // Created by liupengkun on 2018/7/13.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNAlgorithmTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NNAlgorithmTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/004. NNLayerTest/NNLayerTest.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/004. NNLayerTest/NNLayerTest.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNLayerTest.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest.xcodeproj/xcuserdata/yizhilu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest.xcodeproj/xcuserdata/yizhilu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNLayerTest.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNLayerTest
4 | //
5 | // Created by yizhilu on 2018/5/29.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest/Assets.xcassets/header.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "header.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest/Assets.xcassets/header.imageset/header.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/004. NNLayerTest/NNLayerTest/Assets.xcassets/header.imageset/header.jpg
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest/NNLayerTest.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNLayerTest.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest/NNLayerTest.xcdatamodeld/NNLayerTest.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNLayerTest
4 | //
5 | // Created by yizhilu on 2018/5/29.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTest/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNLayerTest
4 | //
5 | // Created by yizhilu on 2018/5/29.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTestTests/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 |
--------------------------------------------------------------------------------
/004. NNLayerTest/NNLayerTestTests/NNLayerTestTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNLayerTestTests.m
3 | // NNLayerTestTests
4 | //
5 | // Created by yizhilu on 2018/5/29.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNLayerTestTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NNLayerTestTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/005. NNStackView/Demo figure/figure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/005. NNStackView/Demo figure/figure.png
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/005. NNStackView/NNStackView.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/005. NNStackView/NNStackView.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNStackView.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView.xcodeproj/xcuserdata/yizhilu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNStackView.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNStackView
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView/NNStackView.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNStackView.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView/NNStackView.xcdatamodeld/NNStackView.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNStackView
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // NNStackView
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view, typically from a nib.
20 | }
21 |
22 |
23 | - (void)didReceiveMemoryWarning {
24 | [super didReceiveMemoryWarning];
25 | // Dispose of any resources that can be recreated.
26 | }
27 |
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackView/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNStackView
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackViewTests/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 |
--------------------------------------------------------------------------------
/005. NNStackView/NNStackViewTests/NNStackViewTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNStackViewTests.m
3 | // NNStackViewTests
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNStackViewTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NNStackViewTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/005. NNStackView/README.md:
--------------------------------------------------------------------------------
1 | ### 用 `UIStackView` 给控件添加约束, 我这里直接在 `Main.storyboard` 中操作了, 原理同代码一样. 有童鞋觉得 `UIStackView` 是鸡肋, 这个确实很少用, 但了解一下还是可以的, 而且体验感还是挺棒的 !
2 |
3 | 
4 |
5 | 想看代码方面的, 可以读下这篇文章: https://www.jianshu.com/p/213702004d0d
6 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/project.xcworkspace/xcuserdata/yizhilu.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNSortDescriptor.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/xcuserdata/yizhilu.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor.xcodeproj/xcuserdata/yizhilu.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNSortDescriptor.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNSortDescriptor
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor/NNDevelopers.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNDevelopers.h
3 | // NNSortDescriptor
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNDevelopers : NSObject
12 |
13 | /** ID */
14 | @property (nonatomic, assign) NSInteger ID;
15 | /** 姓名 */
16 | @property (nonatomic, copy) NSString *name;
17 | /** 性别 */
18 | @property (nonatomic, assign) BOOL sex;
19 | /** 身高 */
20 | @property (nonatomic, assign) double height;
21 | /** 年龄 */
22 | @property (nonatomic, assign) NSInteger age;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor/NNDevelopers.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNDevelopers.m
3 | // NNSortDescriptor
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import "NNDevelopers.h"
10 |
11 | @implementation NNDevelopers
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor/NNSortDescriptor.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNSortDescriptor.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor/NNSortDescriptor.xcdatamodeld/NNSortDescriptor.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNSortDescriptor
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptor/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNSortDescriptor
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptorTests/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 |
--------------------------------------------------------------------------------
/006. NNSortDescriptor/NNSortDescriptorTests/NNSortDescriptorTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNSortDescriptorTests.m
3 | // NNSortDescriptorTests
4 | //
5 | // Created by yizhilu on 2018/6/5.
6 | // Copyright © 2018年 LiuPengKun. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNSortDescriptorTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NNSortDescriptorTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/008.MVVMDemo/MVVMDemo.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | MVVMDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // MVVMDemo
4 | //
5 | // Created by liupengkun on 2018/7/7.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/MVVMDemo.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | MVVMDemo.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/MVVMDemo.xcdatamodeld/MVVMDemo.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/NNModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNModel.h
3 | // MVVMDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNModel : NSObject
12 |
13 | @property (nonatomic, copy) NSString *nickName;
14 |
15 | @property (nonatomic, assign) NSInteger age;
16 |
17 | @property (nonatomic, assign) NSInteger height;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/NNModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNModel.m
3 | // MVVMDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNModel.h"
10 |
11 | @implementation NNModel
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/NNView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNView.h
3 | // MVVMDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | @class NNViewModel;
11 |
12 | @interface NNView : UIView
13 |
14 | - (instancetype)initWithFrame:(CGRect)frame viewModel:(NNViewModel *)viewModel;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/NNViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNViewController.h
3 | // MVVMDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/NNViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNViewController.m
3 | // MVVMDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNViewController.h"
10 | #import "NNViewModel.h"
11 | #import "NNView.h"
12 |
13 |
14 | @interface NNViewController ()
15 |
16 | @property (nonatomic, strong) NNView *nnView;
17 | @property (nonatomic, strong) NNViewModel *nnViewModel;
18 |
19 | @end
20 |
21 | @implementation NNViewController
22 |
23 | - (void)viewDidLoad {
24 | [super viewDidLoad];
25 | [self.view addSubview:self.nnView];
26 | // 模拟请求数据
27 | [self.nnViewModel requestData];
28 | }
29 |
30 | #pragma mark - 懒加载区域
31 | - (NNViewModel *)nnViewModel {
32 | if (!_nnViewModel) {
33 | _nnViewModel = [[NNViewModel alloc] init];
34 | }
35 | return _nnViewModel;
36 | }
37 |
38 | - (NNView *)nnView {
39 | if (!_nnView) {
40 | _nnView = [[NNView alloc] initWithFrame:self.view.frame viewModel:self.nnViewModel];
41 | }
42 | return _nnView;
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/NNViewModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNViewModel.h
3 | // MVVMDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNViewModel : NSObject
12 |
13 | - (void)requestData;
14 |
15 | @property (nonatomic, copy) NSString *contentString;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // MVVMDemo
4 | //
5 | // Created by liupengkun on 2018/7/7.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemoTests/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 |
--------------------------------------------------------------------------------
/008.MVVMDemo/MVVMDemoTests/MVVMDemoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // MVVMDemoTests.m
3 | // MVVMDemoTests
4 | //
5 | // Created by liupengkun on 2018/7/7.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MVVMDemoTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation MVVMDemoTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/008.MVVMDemo/README.md:
--------------------------------------------------------------------------------
1 | ### MVVM 设计模式练习
2 |
3 | > 各家各法, 各马各扎, 一份代码, 不同玩法.
4 |
5 | 最近读了一些架构及设计模式方面的文章, 对 MVC 及 MVVM 设计模式有了更深一点的理解;
6 |
7 | MVVM 是为了解决 Controller 代码臃肿而出现的, 当我们使用 MVVM 时, 我们通常还会利用双向绑定机制, 使得 Model 变化时,ViewModel 会自动更新,而 ViewModel 变化时,View 也会自动变化; 我们可以使用 KVO 或 Notification 技术达到这种效果.
8 |
9 | 双向绑定使得控制器中的代码量大大减少, 但双向绑定也带来了两大痛点:
10 |
11 | - 数据绑定使得 Bug 很难被调试。
12 |
13 | - 对于过大的项目, 数据绑定需要花费更多的内存。
14 |
15 | 我这里写了一份 MVVM 模式的简单代码, 利用 Notification 技术使 Model 与 View 相绑定, 详情请见 demo.
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/009.MVCDemo/MVCDemo.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | MVCDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // MVCDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/MVCDemo.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | MVCDemo.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/MVCDemo.xcdatamodeld/MVCDemo.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/NNDataModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNDataModel.h
3 | // MVCDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNDataModel : NSObject
12 |
13 | - (void)requestData:(void (^)(id object))complete;
14 |
15 | @property (nonatomic, copy) NSString *contentString;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/NNModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNModel.h
3 | // MVCDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNModel : NSObject
12 |
13 | @property (nonatomic, copy) NSString *nickName;
14 |
15 | @property (nonatomic, assign) NSInteger age;
16 |
17 | @property (nonatomic, assign) NSInteger height;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/NNModel.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNModel.m
3 | // MVCDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNModel.h"
10 |
11 | @implementation NNModel
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/NNView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNView.h
3 | // MVCDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | @class NNDataModel;
11 |
12 | @protocol NNViewDelegate
13 | @optional
14 | - (void)nnButtonClicked;
15 | @end
16 |
17 | @interface NNView : UIView
18 |
19 | @property (nonatomic, weak) id delegate;
20 |
21 | /** 网络请求成功后刷新数据 */
22 | - (void)refreshViewWithModel:(NNDataModel *)dataModel;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/NNViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNViewController.h
3 | // MVCDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/NNViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNViewController.m
3 | // MVCDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import "NNViewController.h"
10 | #import "NNDataModel.h"
11 | #import "NNView.h"
12 |
13 | @interface NNViewController ()
14 | @property (nonatomic, strong) NNView *nnView;
15 | @property (nonatomic, strong) NNDataModel *nnViewModel;
16 | @end
17 |
18 | @implementation NNViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | [self.view addSubview:self.nnView];
23 | // 模拟请求数据
24 | [self requestData];
25 | }
26 |
27 | #pragma mark - 网络请求区域
28 | - (void)requestData {
29 | __weak typeof(self) weakSelf = self;
30 | [self.nnViewModel requestData:^(id object) {
31 | [weakSelf.nnView refreshViewWithModel:weakSelf.nnViewModel];
32 | }];
33 | }
34 |
35 | #pragma mark - 代理区域
36 | - (void)nnButtonClicked {
37 | [self requestData];
38 | }
39 |
40 | #pragma mark - 懒加载区域
41 | - (NNDataModel *)nnViewModel {
42 | if (!_nnViewModel) {
43 | _nnViewModel = [[NNDataModel alloc] init];
44 | }
45 | return _nnViewModel;
46 | }
47 |
48 | - (NNView *)nnView {
49 | if (!_nnView) {
50 | _nnView = [[NNView alloc] initWithFrame:self.view.frame];
51 | _nnView.delegate = self;
52 | }
53 | return _nnView;
54 | }
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // MVCDemo
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemoTests/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 |
--------------------------------------------------------------------------------
/009.MVCDemo/MVCDemoTests/MVCDemoTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // MVCDemoTests.m
3 | // MVCDemoTests
4 | //
5 | // Created by liupengkun on 2018/7/16.
6 | // Copyright © 2018年 以梦为马. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface MVCDemoTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation MVCDemoTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/009.MVCDemo/README.md:
--------------------------------------------------------------------------------
1 | ### MVC 设计模式练习
2 |
3 | > 各家各法, 各马各扎, 一份代码, 不同玩法.
4 |
5 | 巧神有一篇文章, 介绍了如何给 ViewController 瘦身的问题, [被误解的 MVC 和被神化的 MVVM.](http://blog.devtang.com/2015/11/02/mvc-and-mvvm/)
6 |
7 | #### 如何对 ViewController 瘦身?
8 |
9 | - 将网络请求抽象到单独的类中
10 |
11 | - 将界面的拼装抽象到专门的类中
12 |
13 | - 构造 ViewModel
14 |
15 | - 专门构造存储类
16 |
17 | 我这里写了一份给 ViewController 瘦身后的 MVC 模式的简单代码.
18 |
19 | #### demo 分为四大部分:
20 |
21 | ##### NNViewController
22 |
23 | - 负责显示 View(数据展示在视图上), 负责交互事件;
24 | - 数据⽅面, 只引用 "NNDataModel" 这⼀个类, 所有数据都从 "NNDataModel" 中拿取, "NNDataModel" 负责所有的数据处理包括网络请求字典模型转换等;
25 | - 视图⽅面, View 内部的实现在其⾃定义视图中完成, 控制器中直接 addSubview, 并将拿到的数据传给 View;
26 |
27 | ##### NNDataModel
28 |
29 | - 负责所有的数据处理. 数据相关的 (包括⽹络请求, 数据处理以及⼀些数据⽅方⾯的属性), 全部放在 NNDataModel 里, 基本上以 NS 开头的属性, 都放在 NNDataModel 中, 外界(控制器器)只管调用, 不⽤管其实现.
30 |
31 | ##### NNModel
32 |
33 | - Model 层的代码, 基本上只在 NNDataModel 中引⽤, 或在 View 中赋值使⽤用;
34 |
35 | ##### NNView
36 | - 自定义子视图负责视图的内部实现(如果是 UITableView, 则设置其代理);
37 |
38 |
39 | (PS: 其实还想用另一种方式, 不在自定义子视图里面设置代理, 直接在 NNView 这个类里面, 用 dataModel 调用请求网络的方法, 然后通过 block 将请求结果传过来然后刷新界面......瘦控制器的方法很多......)
40 |
41 |
42 | 欢迎提建议或意见🙂
43 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/010.NNLoad/NNLoad.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNLoad.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/010.NNLoad/NNLoad/.DS_Store
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/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 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNParentClassView+extension.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNParentClassView+extension.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNParentClassView.h"
10 |
11 | @interface NNParentClassView (extension)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNParentClassView+extension.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNParentClassView+extension.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNParentClassView+extension.h"
10 |
11 | @implementation NNParentClassView (extension)
12 |
13 | + (void)load {
14 | NSLog(@"父类分类:%@", NSStringFromClass(self));
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNParentClassView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNParentClassView.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNParentClassView : UIView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNParentClassView.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNParentClassView.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNParentClassView.h"
10 |
11 | @implementation NNParentClassView
12 |
13 | + (void)load {
14 | NSLog(@"父类:%@", NSStringFromClass(self));
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNSubViewController+extension.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSubViewController+extension.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNSubViewController.h"
10 |
11 | @interface NNSubViewController (extension)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNSubViewController+extension.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNSubViewController+extension.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNSubViewController+extension.h"
10 |
11 | @implementation NNSubViewController (extension)
12 |
13 | + (void)load {
14 | NSLog(@"子类分类:%@", NSStringFromClass(self));
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNSubViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSubViewController.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface NNSubViewController : ViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNSubViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNSubViewController.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNSubViewController.h"
10 |
11 | @interface NNSubViewController ()
12 |
13 | @end
14 |
15 | @implementation NNSubViewController
16 |
17 | + (void)load {
18 | NSLog(@"子类:%@", NSStringFromClass([self class]));
19 | }
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 | // Do any additional setup after loading the view.
24 | }
25 |
26 | - (void)didReceiveMemoryWarning {
27 | [super didReceiveMemoryWarning];
28 | // Dispose of any resources that can be recreated.
29 | }
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNSubclassView+extension.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSubclassView+extension.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNSubclassView.h"
10 |
11 | @interface NNSubclassView (extension)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNSubclassView+extension.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNSubclassView+extension.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNSubclassView+extension.h"
10 |
11 | @implementation NNSubclassView (extension)
12 |
13 | + (void)load {
14 | NSLog(@"子类分类:%@", NSStringFromClass(self));
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNSubclassView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSubclassView.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNParentClassView.h"
11 |
12 | @interface NNSubclassView : NNParentClassView
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/NNSubclassView.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNSubclassView.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNSubclassView.h"
10 |
11 | @implementation NNSubclassView
12 |
13 | + (void)load {
14 | NSLog(@"子类:%@", NSStringFromClass(self));
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/ViewController+extension.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController+extension.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController (extension)
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/ViewController+extension.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController+extension.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "ViewController+extension.h"
10 |
11 | @implementation ViewController (extension)
12 |
13 | + (void)load {
14 | NSLog(@"父类分类:%@", NSStringFromClass(self));
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 |
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | + (void)load {
18 | NSLog(@"父类:%@", NSStringFromClass([self class]));
19 | }
20 |
21 | - (void)viewDidLoad {
22 | [super viewDidLoad];
23 | }
24 |
25 | - (void)didReceiveMemoryWarning {
26 | [super didReceiveMemoryWarning];
27 | // Dispose of any resources that can be recreated.
28 | }
29 |
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/010.NNLoad/NNLoad/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNLoad
4 | //
5 | // Created by 刘朋坤 on 2018/7/26.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/010.NNLoad/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## load 方法调用顺序
3 | ```
4 | 父类:ViewController
5 | 父类:NNParentClassView
6 | 子类:NNSubclassView
7 | 子类:NNSubViewController
8 | 子类分类:NNSubclassView
9 | 子类分类:NNSubViewController
10 | 父类分类:ViewController
11 | 父类分类:NNParentClassView
12 | ```
13 |
14 | - 这里有一篇文章,可以加深对 load 方法的了解:[你真的了解 load 方法么?](https://github.com/Draveness/analyze/blob/master/contents/objc/你真的了解%20load%20方法么?.md)
15 |
--------------------------------------------------------------------------------
/011.NN_GCDPractice/NN_GCDPractice.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/011.NN_GCDPractice/NN_GCDPractice.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/011.NN_GCDPractice/NN_GCDPractice.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/011.NN_GCDPractice/NN_GCDPractice.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/011.NN_GCDPractice/NN_GCDPractice.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NN_GCDPractice.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/011.NN_GCDPractice/NN_GCDPractice/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NN_GCDPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/8.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/011.NN_GCDPractice/NN_GCDPractice/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/011.NN_GCDPractice/NN_GCDPractice/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NN_GCDPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/8.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/011.NN_GCDPractice/NN_GCDPractice/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NN_GCDPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/8.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/011.NN_GCDPractice/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## iOS 开发多线程 GCD 的练习,10 种常用场景
3 |
4 | - dispatch_async (异步函数)
5 |
6 | - dispatch_sync (同步函数)
7 |
8 | - 在主队列中的应用
9 |
10 | - dispatch_group_async(创建队列组)
11 |
12 | - dispatch_barrier_async (栅栏的使用)
13 |
14 | - dispatch_apply(重复执行某处代码)
15 |
16 | - dispatch_once_t(单例)
17 |
18 | - dispatch_after(延迟执行)
19 |
20 | - dispatch_time_t(定时器)
21 |
22 | - GCD 线程间的通信
23 |
24 |
25 |
26 | #### demo 中写有详细注释,欢迎讨论
27 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/012.NN_NSOperationPractice/NN_ NSOperationPractice.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NN_ NSOperationPractice.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NN_ NSOperationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/9.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice/NNNSOperation.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNNSOperation.h
3 | // NN_ NSOperationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/9.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNNSOperation : NSOperation
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice/NNNSOperation.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNNSOperation.m
3 | // NN_ NSOperationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/9.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNNSOperation.h"
10 |
11 | @implementation NNNSOperation
12 |
13 | /** 自定义 NSOperation 子类需要重写 - (void)main方法 */
14 | // 非并行
15 | - (void)main {
16 | // 新建一个自动释放池,如果是异步执行操作,那么将无法访问到主线程的自动释放池
17 | @autoreleasepool {
18 | for (NSInteger i = 0; i<100; i++) {
19 | NSLog(@"1 - %ld - %@", i, [NSThread currentThread]);
20 | }
21 | // 检测操作是否被取消,对取消做出响应
22 | if (self.isCancelled) return;
23 |
24 | for (NSInteger i = 0; i<100; i++) {
25 | NSLog(@"2 - %ld - %@", i, [NSThread currentThread]);
26 | }
27 | if (self.isCancelled) return;
28 |
29 | for (NSInteger i = 0; i<100; i++) {
30 | NSLog(@"3 - %ld - %@", i, [NSThread currentThread]);
31 | }
32 | if (self.isCancelled) return;
33 | }
34 | }
35 |
36 | /**
37 | 自定义并行的 NSOperation 需要重写以下几个方法:
38 |
39 | start: 所有并行的 Operations 都必须重写这个方法,然后在你想要执行的线程中手动调用这个方法
40 | main: 在 start 方法中调用
41 | isExecuting: 是否执行中
42 | isFinished: 是否已完成
43 | isConcurrent: 该方法现在已经由 isAsynchronous 方法代替
44 | isAsynchronous: 该方法默认返回 NO ,表示非并发执行。并发执行需要自定义并且返回 YES
45 | */
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NN_ NSOperationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/9.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/NN_ NSOperationPractice/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NN_ NSOperationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/9.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/012.NN_NSOperationPractice/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## iOS开发之多线程 NSOperation 练习,几种常用场景
3 |
4 | - 创建线程的三种方式(分为三种: NSInvocationOperation; NSBlockOperation; 自定义 NSOperation 子类)
5 |
6 | - NSOperationQueue 创建(分为两种: `addOperation:` 方式; `addOperationWithBlock:` 方式)
7 |
8 | - NSOperation 中的操作依赖
9 |
10 | - 线程间的通信
11 |
12 |
13 | #### 其它常用方法:
14 |
15 | ```
16 | // 取消单个操作
17 | [operation1 cancel];
18 | // 会阻塞当前线程,等到某个operation执行完毕
19 | [operation2 waitUntilFinished];
20 |
21 | // 取消queue中所有的操作
22 | [queue cancelAllOperations];
23 | // 设置队列的最大并发操作数量
24 | queue.maxConcurrentOperationCount = 1;
25 | // 暂停 queue YES代表暂停队列,NO代表恢复队列
26 | [queue setSuspended:YES];
27 | // 阻塞当前线程,等待queue的所有操作执行完毕
28 | [queue waitUntilAllOperationsAreFinished];
29 | ```
30 |
31 | #### demo 中写有详细注释,欢迎讨论
32 |
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/NN_NSThreadPractice.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/NN_NSThreadPractice.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/NN_NSThreadPractice.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/013.NN_NSThreadPractice/NN_NSThreadPractice.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/NN_NSThreadPractice.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NN_NSThreadPractice.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/NN_NSThreadPractice/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NN_NSThreadPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/10.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/NN_NSThreadPractice/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/NN_NSThreadPractice/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NN_NSThreadPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/10.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/NN_NSThreadPractice/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NN_NSThreadPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/10.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/013.NN_NSThreadPractice/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## iOS开发之多线程 NSThread 练习,几种常用场景
3 |
4 | - 创建线程的三种方式(分为三种: 动态方法; 静态方法; 隐式创建线程)
5 |
6 | - 线程间的通信
7 |
8 |
9 | #### 其它常用方法:
10 |
11 | ```
12 | // 获得主线程
13 | + (NSThread *)mainThread;
14 |
15 | // 判断是否为主线程
16 | - (BOOL)isMainThread;
17 | + (BOOL)isMainThread;
18 |
19 | // 获得当前线程
20 | NSThread *current = [NSThread currentThread];
21 |
22 | // 线程的名字
23 | - (void)setName:(NSString *)name;
24 | - (NSString *)name;
25 |
26 | // 线程进入就绪状态 -> 运行状态
27 | - (void)start;
28 |
29 | // 睡眠,相当于暂停
30 | + (void)sleepUntilDate:(NSDate *)date;
31 | + (void)sleepForTimeInterval:(NSTimeInterval)ti;
32 |
33 | // 线程销毁
34 | + (void)exit;
35 | ```
36 |
37 | #### demo 中写有详细注释,欢迎讨论
38 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/014.NNMultipleDelegate/NNMultipleDelegate.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNMultipleDelegate.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNMultipleDelegate
4 | //
5 | // Created by 刘朋坤 on 2018/8/17.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/Assets.xcassets/dog01.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "dog01.jpg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/Assets.xcassets/dog01.imageset/dog01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/014.NNMultipleDelegate/NNMultipleDelegate/Assets.xcassets/dog01.imageset/dog01.jpg
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/NNLabel.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNLabel.h
3 | // NNMultipleDelegate
4 | //
5 | // Created by 刘朋坤 on 2018/8/17.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNLabel : UILabel
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/NNLabel.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNLabel.m
3 | // NNMultipleDelegate
4 | //
5 | // Created by 刘朋坤 on 2018/8/17.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNLabel.h"
10 | @interface NNLabel()
11 |
12 | @end
13 |
14 | @implementation NNLabel
15 |
16 | - (instancetype)initWithFrame:(CGRect)frame {
17 | if (self = [super initWithFrame:frame]) {
18 | self.backgroundColor = [UIColor redColor];
19 | self.textAlignment = NSTextAlignmentCenter;
20 | self.text = 0;
21 | }
22 | return self;
23 | }
24 |
25 | #pragma mark - 代理区域
26 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
27 | self.text = [NSString stringWithFormat:@"%.2f", scrollView.contentOffset.y];
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/NNMultipleDelegate/NNMultipleDelegateHelper.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNMultipleDelegateHelper.h
3 | // NNMultipleDelegate
4 | //
5 | // Created by 刘朋坤 on 2018/8/17.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNMultipleDelegateHelper : NSObject
12 |
13 | @property (nonatomic, strong, nonnull) NSArray *delegateArray;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/NNStretchHeaderView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNStretchHeaderView.h
3 | // NNMultipleDelegate
4 | //
5 | // Created by 刘朋坤 on 2018/8/17.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNStretchHeaderView : UIView
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNMultipleDelegate
4 | //
5 | // Created by 刘朋坤 on 2018/8/17.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/NNMultipleDelegate/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNMultipleDelegate
4 | //
5 | // Created by 刘朋坤 on 2018/8/17.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/014.NNMultipleDelegate/README.md:
--------------------------------------------------------------------------------
1 | ## 利用OC的消息转发机制实现多重代理
2 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/015.NN_UIViewAnimationPractice/.DS_Store
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NN_UIViewAnimationPractice.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/.DS_Store
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/10.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/Assets.xcassets/header.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "header.jpeg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/Assets.xcassets/header.imageset/header.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/Assets.xcassets/header.imageset/header.jpeg
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/NNViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNViewController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/.DS_Store
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNAlphaAnimationViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNAlphaAnimationViewController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNBaseViewController.h"
11 |
12 | @interface NNAlphaAnimationViewController : NNBaseViewController
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNAlphaAnimationViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNAlphaAnimationViewController.m
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNAlphaAnimationViewController.h"
10 |
11 | @interface NNAlphaAnimationViewController ()
12 |
13 | @end
14 |
15 | @implementation NNAlphaAnimationViewController
16 |
17 | - (NSArray *)buttonTitleArray {
18 | return @[@"Alpha"];
19 | }
20 |
21 | #pragma mark - 处理事件区域
22 | - (void)buttonClick:(UIButton *)sender {
23 | [self changeAlpha];
24 | }
25 |
26 | - (void)changeAlpha {
27 | [UIView animateWithDuration:1.5 animations:^{
28 | self.nnView.headerImage.alpha = 0.2;
29 | } completion:^(BOOL finished) {
30 | [UIView animateWithDuration:1.5 animations:^{
31 | self.nnView.headerImage.alpha = 1;
32 | }];
33 | }];
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNBackgroundAnimationViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNBackgroundAnimationViewController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNBaseViewController.h"
11 |
12 | @interface NNBackgroundAnimationViewController : NNBaseViewController
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNBaseViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNBaseViewController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNView.h"
11 |
12 | @interface NNBaseViewController : UIViewController
13 |
14 | @property (nonatomic, strong) NNView *nnView;
15 |
16 | - (void)buttonClick:(UIButton *)sender;
17 |
18 | - (NSArray *)buttonTitleArray;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNBaseViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNBaseViewController.m
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNBaseViewController ()
12 |
13 | /** 按钮的数组元素 **/
14 | @property (nonatomic, copy) NSArray *buttonTitleArray;
15 |
16 | @end
17 |
18 | @implementation NNBaseViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | [self initData];
23 | [self.view addSubview:self.nnView];
24 | }
25 |
26 | - (void)initData {
27 | _buttonTitleArray = [self buttonTitleArray];
28 | }
29 |
30 | #pragma mark - 处理事件区域
31 | - (void)buttonClick:(UIButton *)sender {
32 |
33 | }
34 |
35 | #pragma mark - 懒加载区域
36 | - (NNView *)nnView {
37 | if (!_nnView) {
38 | _nnView = [[NNView alloc] initWithFrame:self.view.frame buttonTitleArray:_buttonTitleArray];
39 | __weak typeof(self) weakSelf = self;
40 | _nnView.actionBlock = ^(id param) {
41 | UIButton *sender = param;
42 | [weakSelf buttonClick:sender];
43 | };
44 | }
45 | return _nnView;
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNFrameAnimationController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNFrameAnimationController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNBaseViewController.h"
11 |
12 | @interface NNFrameAnimationController : NNBaseViewController
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNSpringAnimationController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNSpringAnimationController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNBaseViewController.h"
11 |
12 | @interface NNSpringAnimationController : NNBaseViewController
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNTransformController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNTransformController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNBaseViewController.h"
11 |
12 | @interface NNTransformController : NNBaseViewController
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Controllers/NNTransitionAnimationController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNTransformAnimationController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNBaseViewController.h"
11 |
12 | @interface NNTransitionAnimationController : NNBaseViewController
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Views/NNBottomView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNBottomView.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef void(^NNActionBlock)(id param);
12 |
13 | @interface NNBottomView : UIView
14 |
15 | - (instancetype)initWithFrame:(CGRect)frame buttonTitleArray:(NSArray *)buttonTitleArray;
16 |
17 | /** 按钮点击事件 */
18 | @property (nonatomic, copy) NNActionBlock actionBlock;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/UIViewAnimationPractice/Views/NNView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNView.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | typedef void(^NNActionBlock)(id param);
11 |
12 | @interface NNView : UIView
13 |
14 | /** 演示图片 */
15 | @property (nonatomic, strong) UIImageView *headerImage;
16 |
17 | /** 按钮点击事件 */
18 | @property (nonatomic, copy) NNActionBlock actionBlock;
19 |
20 | - (instancetype)initWithFrame:(CGRect)frame buttonTitleArray:(NSArray *)buttonTitleArray;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/NN_UIViewAnimationPractice/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/10.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/015.NN_UIViewAnimationPractice/README.md:
--------------------------------------------------------------------------------
1 | ## iOS 动画 - UIView Animation
2 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/016.NNCoreAnimation/.DS_Store
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/016.NNCoreAnimation/NNCoreAnimation.xcodeproj/project.xcworkspace/xcuserdata/liupengkun.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation.xcodeproj/xcuserdata/liupengkun.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNCoreAnimation.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/016.NNCoreAnimation/NNCoreAnimation/.DS_Store
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNCoreAnimation
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Assets.xcassets/header.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "header.jpeg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Assets.xcassets/header.imageset/header.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/016.NNCoreAnimation/NNCoreAnimation/Assets.xcassets/header.imageset/header.jpeg
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Controllers/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/016.NNCoreAnimation/NNCoreAnimation/Controllers/.DS_Store
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Controllers/NNBaseViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNBaseViewController.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "NNView.h"
11 | #define NNScreenWidth [UIScreen mainScreen].bounds.size.width
12 | #define NNScreenHeight [UIScreen mainScreen].bounds.size.height
13 |
14 | @interface NNBaseViewController : UIViewController
15 |
16 | @property (nonatomic, strong) NNView *nnView;
17 |
18 | - (void)buttonClick:(UIButton *)sender;
19 |
20 | - (NSArray *)buttonTitleArray;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Controllers/NNBaseViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNBaseViewController.m
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNBaseViewController ()
12 |
13 | /** 按钮的数组元素 **/
14 | @property (nonatomic, copy) NSArray *buttonTitleArray;
15 |
16 | @end
17 |
18 | @implementation NNBaseViewController
19 |
20 | - (void)viewDidLoad {
21 | [super viewDidLoad];
22 | [self initData];
23 | [self.view addSubview:self.nnView];
24 | }
25 |
26 | - (void)initData {
27 | _buttonTitleArray = [self buttonTitleArray];
28 | }
29 |
30 | #pragma mark - 处理事件区域
31 | - (void)buttonClick:(UIButton *)sender {
32 |
33 | }
34 |
35 | #pragma mark - 懒加载区域
36 | - (NNView *)nnView {
37 | if (!_nnView) {
38 | _nnView = [[NNView alloc] initWithFrame:self.view.frame buttonTitleArray:_buttonTitleArray];
39 | __weak typeof(self) weakSelf = self;
40 | _nnView.actionBlock = ^(id param) {
41 | UIButton *sender = param;
42 | [weakSelf buttonClick:sender];
43 | };
44 | }
45 | return _nnView;
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Controllers/NNOthersViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNOthersViewController.h
3 | // NNCoreAnimation
4 | //
5 | // Created by 刘朋坤 on 2018/8/18.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNOthersViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Controllers/NNPositionViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNPositionViewController.h
3 | // NNCoreAnimation
4 | //
5 | // Created by 刘朋坤 on 2018/8/13.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNPositionViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Controllers/NNRotationViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNRotationViewController.h
3 | // NNCoreAnimation
4 | //
5 | // Created by 刘朋坤 on 2018/8/13.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNRotationViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Controllers/NNScaleViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNScaleViewController.h
3 | // NNCoreAnimation
4 | //
5 | // Created by 刘朋坤 on 2018/8/13.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNBaseViewController.h"
10 |
11 | @interface NNScaleViewController : NNBaseViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Controllers/NNScaleViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNScaleViewController.m
3 | // NNCoreAnimation
4 | //
5 | // Created by 刘朋坤 on 2018/8/13.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNScaleViewController.h"
10 |
11 | @interface NNScaleViewController ()
12 |
13 | @end
14 |
15 | @implementation NNScaleViewController
16 |
17 | - (NSArray *)buttonTitleArray {
18 | return @[@"scale", @"scale.x", @"scale.y"];
19 | }
20 |
21 | - (void)buttonClick:(UIButton *)sender {
22 | switch (sender.tag) {
23 | case 0:
24 | [self scaleAnimationWithKeyPath:@"transform.scale" key:@"scaleAnimation"];
25 | break;
26 | case 1:
27 | [self scaleAnimationWithKeyPath:@"transform.scale.x" key:@"scaleAnimationX"];
28 | break;
29 | case 2:
30 | [self scaleAnimationWithKeyPath:@"transform.scale.y" key:@"scaleAnimationY"];
31 | break;
32 | default:
33 | break;
34 | }
35 | }
36 |
37 | - (void)scaleAnimationWithKeyPath:(NSString *)keyPath key:(NSString *)key {
38 | CABasicAnimation *anima = [CABasicAnimation animationWithKeyPath:keyPath];
39 | anima.toValue = [NSNumber numberWithFloat:0.3];
40 | anima.duration = 1.0f;
41 | [self.nnView.headerImage.layer addAnimation:anima forKey:key];
42 | }
43 |
44 | @end
45 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNCoreAnimation
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Views/NNBottomView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNBottomView.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef void(^NNActionBlock)(id param);
12 |
13 | @interface NNBottomView : UIView
14 |
15 | - (instancetype)initWithFrame:(CGRect)frame buttonTitleArray:(NSArray *)buttonTitleArray;
16 |
17 | /** 按钮点击事件 */
18 | @property (nonatomic, copy) NNActionBlock actionBlock;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/Views/NNView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNView.h
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | typedef void(^NNActionBlock)(id param);
11 |
12 | @interface NNView : UIView
13 |
14 | /** 演示图片 */
15 | @property (nonatomic, strong) UIImageView *headerImage;
16 |
17 | /** 按钮点击事件 */
18 | @property (nonatomic, copy) NNActionBlock actionBlock;
19 |
20 | - (instancetype)initWithFrame:(CGRect)frame buttonTitleArray:(NSArray *)buttonTitleArray;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/NNCoreAnimation/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNCoreAnimation
4 | //
5 | // Created by 刘朋坤 on 2018/8/11.
6 | // Copyright © 2018年 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/016.NNCoreAnimation/README.md:
--------------------------------------------------------------------------------
1 | ## iOS 动画 - 核心动画
2 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift.xcodeproj/project.xcworkspace/xcuserdata/DJ.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift.xcodeproj/project.xcworkspace/xcuserdata/DJ.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift.xcodeproj/xcuserdata/DJ.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NN_UIViewAnimationPractice_swift.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift/Assets.xcassets/header.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "header.jpeg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift/Assets.xcassets/header.imageset/header.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift/Assets.xcassets/header.imageset/header.jpeg
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NN_UIViewAnimationPractice_swift.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift.xcdatamodeld/NN_UIViewAnimationPractice_swift.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift/UIViewAnimationPractice/Controllers/NNAlphaAnimationViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNAlphaAnimationViewController.swift
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class NNAlphaAnimationViewController: NNBaseViewController {
12 |
13 | // 按钮点击事件
14 | override func buttonClick(index: NSInteger) {
15 | UIView.animate(withDuration: 1.5, animations: {
16 | self.nnView.headerImage.alpha = 0.2
17 | }) { (finished) in
18 | self.nnView.headerImage.alpha = 1
19 | }
20 | }
21 |
22 | // 数组元素
23 | override func buttonTitleArrayMethod() -> NSArray {
24 | return ["Alpha"]
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swift/UIViewAnimationPractice/Controllers/NNBaseViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNBaseViewController.swift
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class NNBaseViewController: UIViewController {
12 |
13 | var buttonTitleArray : NSArray = []
14 |
15 | override func viewDidLoad() {
16 | super.viewDidLoad()
17 | self.view.backgroundColor = UIColor.white
18 | self.buttonTitleArray = self.buttonTitleArrayMethod()
19 | self.view.addSubview(nnView)
20 | }
21 |
22 | // 根据数组创建按钮,交给子类继承
23 | func buttonTitleArrayMethod() -> NSArray {
24 | return []
25 | }
26 |
27 | // 通过代理传出来的按钮点击事件,交给子类继承
28 | func buttonClick(index: NSInteger) {
29 |
30 | }
31 |
32 | lazy var nnView : NNView = {
33 | let tempView = NNView.init(frame: self.view.frame, buttonTitleArray: buttonTitleArray)
34 | tempView.delegate = self
35 | return tempView
36 | }()
37 |
38 | }
39 |
40 | extension NNBaseViewController : NNViewProtocol {
41 | func clickAction(index: NSInteger) {
42 | buttonClick(index: index)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swiftTests/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 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swiftTests/NN_UIViewAnimationPractice_swiftTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NN_UIViewAnimationPractice_swiftTests.swift
3 | // NN_UIViewAnimationPractice_swiftTests
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import NN_UIViewAnimationPractice_swift
11 |
12 | class NN_UIViewAnimationPractice_swiftTests: XCTestCase {
13 |
14 | override func setUp() {
15 | // Put setup code here. This method is called before the invocation of each test method in the class.
16 | }
17 |
18 | override func tearDown() {
19 | // Put teardown code here. This method is called after the invocation of each test method in the class.
20 | }
21 |
22 | func testExample() {
23 | // This is an example of a functional test case.
24 | // Use XCTAssert and related functions to verify your tests produce the correct results.
25 | }
26 |
27 | func testPerformanceExample() {
28 | // This is an example of a performance test case.
29 | self.measure {
30 | // Put the code you want to measure the time of here.
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swiftUITests/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 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/NN_UIViewAnimationPractice_swiftUITests/NN_UIViewAnimationPractice_swiftUITests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NN_UIViewAnimationPractice_swiftUITests.swift
3 | // NN_UIViewAnimationPractice_swiftUITests
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | class NN_UIViewAnimationPractice_swiftUITests: XCTestCase {
12 |
13 | override func setUp() {
14 | // Put setup code here. This method is called before the invocation of each test method in the class.
15 |
16 | // In UI tests it is usually best to stop immediately when a failure occurs.
17 | continueAfterFailure = false
18 |
19 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
20 | XCUIApplication().launch()
21 |
22 | // 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.
23 | }
24 |
25 | override func tearDown() {
26 | // Put teardown code here. This method is called after the invocation of each test method in the class.
27 | }
28 |
29 | func testExample() {
30 | // Use recording to get started writing UI tests.
31 | // Use XCTAssert and related functions to verify your tests produce the correct results.
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/017.NN_UIViewAnimationPractice_swift/README.md:
--------------------------------------------------------------------------------
1 | ## iOS 动画, UIView Animation,swift 语言;
2 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift.xcodeproj/project.xcworkspace/xcuserdata/DJ.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/018.NNCoreAnimation_swift/NNCoreAnimation_swift.xcodeproj/project.xcworkspace/xcuserdata/DJ.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift.xcodeproj/xcuserdata/DJ.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNCoreAnimation_swift.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift/Assets.xcassets/header.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "header.jpeg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift/Assets.xcassets/header.imageset/header.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/018.NNCoreAnimation_swift/NNCoreAnimation_swift/Assets.xcassets/header.imageset/header.jpeg
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift/NNCoreAnimation_swift.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNCoreAnimation_swift.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift/NNCoreAnimation_swift.xcdatamodeld/NNCoreAnimation_swift.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift/NNCoreAnimation_swift/Controllers/NNBaseViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNBaseViewController.swift
3 | // NN_UIViewAnimationPractice
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class NNBaseViewController: UIViewController {
12 |
13 | var buttonTitleArray : NSArray = []
14 |
15 | override func viewDidLoad() {
16 | super.viewDidLoad()
17 | self.view.backgroundColor = UIColor.white
18 | self.buttonTitleArray = self.buttonTitleArrayMethod()
19 | self.view.addSubview(nnView)
20 | }
21 |
22 | // 根据数组创建按钮,交给子类继承
23 | func buttonTitleArrayMethod() -> NSArray {
24 | return []
25 | }
26 |
27 | // 通过代理传出来的按钮点击事件,交给子类继承
28 | func buttonClick(index: NSInteger) {
29 |
30 | }
31 |
32 | lazy var nnView : NNView = {
33 | let tempView = NNView.init(frame: self.view.frame, buttonTitleArray: buttonTitleArray)
34 | tempView.delegate = self
35 | return tempView
36 | }()
37 |
38 | }
39 |
40 | extension NNBaseViewController : NNViewProtocol {
41 | func clickAction(index: NSInteger) {
42 | buttonClick(index: index)
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swift/NNCoreAnimation_swift/Controllers/NNScaleViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNScaleViewController.swift
3 | // NNCoreAnimation_swift
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class NNScaleViewController: NNBaseViewController {
12 |
13 | // 按钮点击事件
14 | override func buttonClick(index: NSInteger) {
15 | switch index {
16 | case 0:
17 | scaleAnimationWithKeyPath(keyPath: "transform.scale", key: "scaleAnimation")
18 | break
19 | case 1:
20 | scaleAnimationWithKeyPath(keyPath: "transform.scale.x", key: "scaleAnimationX")
21 | break
22 | case 2:
23 | scaleAnimationWithKeyPath(keyPath: "transform.scale.y", key: "scaleAnimationY")
24 | break
25 | default:
26 | break
27 | }
28 | }
29 |
30 | // 封装的统一方法
31 | func scaleAnimationWithKeyPath(keyPath:String, key:String) {
32 | let anima = CABasicAnimation.init(keyPath: keyPath)
33 | anima.toValue = 0.3
34 | anima.duration = 1
35 | self.nnView.headerImage.layer.add(anima, forKey: key)
36 | }
37 |
38 | // 数组元素
39 | override func buttonTitleArrayMethod() -> NSArray {
40 | return ["scale", "scale.x", "scale.y"]
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swiftTests/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 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swiftTests/NNCoreAnimation_swiftTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNCoreAnimation_swiftTests.swift
3 | // NNCoreAnimation_swiftTests
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import NNCoreAnimation_swift
11 |
12 | class NNCoreAnimation_swiftTests: XCTestCase {
13 |
14 | override func setUp() {
15 | // Put setup code here. This method is called before the invocation of each test method in the class.
16 | }
17 |
18 | override func tearDown() {
19 | // Put teardown code here. This method is called after the invocation of each test method in the class.
20 | }
21 |
22 | func testExample() {
23 | // This is an example of a functional test case.
24 | // Use XCTAssert and related functions to verify your tests produce the correct results.
25 | }
26 |
27 | func testPerformanceExample() {
28 | // This is an example of a performance test case.
29 | self.measure {
30 | // Put the code you want to measure the time of here.
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swiftUITests/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 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/NNCoreAnimation_swiftUITests/NNCoreAnimation_swiftUITests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNCoreAnimation_swiftUITests.swift
3 | // NNCoreAnimation_swiftUITests
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | class NNCoreAnimation_swiftUITests: XCTestCase {
12 |
13 | override func setUp() {
14 | // Put setup code here. This method is called before the invocation of each test method in the class.
15 |
16 | // In UI tests it is usually best to stop immediately when a failure occurs.
17 | continueAfterFailure = false
18 |
19 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
20 | XCUIApplication().launch()
21 |
22 | // 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.
23 | }
24 |
25 | override func tearDown() {
26 | // Put teardown code here. This method is called after the invocation of each test method in the class.
27 | }
28 |
29 | func testExample() {
30 | // Use recording to get started writing UI tests.
31 | // Use XCTAssert and related functions to verify your tests produce the correct results.
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/018.NNCoreAnimation_swift/README.md:
--------------------------------------------------------------------------------
1 | ## iOS 动画, 核心动画,swift 语言;
2 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest.xcodeproj/project.xcworkspace/xcuserdata/DJ.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/019.NNResponderTest/NNResponderTest.xcodeproj/project.xcworkspace/xcuserdata/DJ.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest.xcodeproj/xcuserdata/DJ.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNResponderTest.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface AppDelegate : UIResponder
13 |
14 | @property (strong, nonatomic) UIWindow *window;
15 |
16 | @property (readonly, strong) NSPersistentContainer *persistentContainer;
17 |
18 | - (void)saveContext;
19 |
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/Assets.xcassets/header.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "header.jpeg",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/Assets.xcassets/header.imageset/header.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/019.NNResponderTest/NNResponderTest/Assets.xcassets/header.imageset/header.jpeg
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/NNResponderTest.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNResponderTest.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/NNResponderTest.xcdatamodeld/NNResponderTest.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/NNTableView.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNTableView.h
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface NNTableView : UITableView
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/NNTableViewCell.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNTableViewCell.h
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface NNTableViewCell : UITableViewCell
14 |
15 | @property (nonatomic, strong) NSIndexPath *indexPath;
16 |
17 | @end
18 |
19 | NS_ASSUME_NONNULL_END
20 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/NNTableViewCell.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNTableViewCell.m
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNTableViewCell.h"
10 | #import "UIResponder+responder.h"
11 |
12 | @interface NNTableViewCell()
13 |
14 | @property (weak, nonatomic) IBOutlet UILabel *row;
15 | @property (weak, nonatomic) IBOutlet UILabel *section;
16 |
17 | @end
18 |
19 | @implementation NNTableViewCell
20 |
21 | - (void)awakeFromNib {
22 | [super awakeFromNib];
23 | // Initialization code
24 | }
25 |
26 | - (IBAction)buttonClick:(UIButton *)sender {
27 | NSString *string = [NSString stringWithFormat:@"%@%@的第%ld个按钮被点击了", self.section.text, self.row.text, sender.tag];
28 | if (sender.tag == 1) {
29 | [self responderWithKey:@"1" value:string];
30 | } else {
31 | [self responderWithKey:@"2" value:string];
32 | }
33 | }
34 |
35 | - (void)setIndexPath:(NSIndexPath *)indexPath {
36 | _indexPath = indexPath;
37 | self.row.text = [NSString stringWithFormat:@"第%ld行", (long)indexPath.row];
38 | self.section.text = [NSString stringWithFormat:@"第%ld组", (long)indexPath.section];
39 | }
40 |
41 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
42 | [super setSelected:selected animated:animated];
43 |
44 | // Configure the view for the selected state
45 | }
46 |
47 | @end
48 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/UIResponder+responder.h:
--------------------------------------------------------------------------------
1 | //
2 | // UIResponder+responder.h
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface UIResponder (responder)
14 |
15 | - (void)responderWithKey:(NSString *)key value:(id)value;
16 |
17 | @end
18 |
19 | NS_ASSUME_NONNULL_END
20 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/UIResponder+responder.m:
--------------------------------------------------------------------------------
1 | //
2 | // UIResponder+responder.m
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "UIResponder+responder.h"
10 |
11 | @implementation UIResponder (responder)
12 |
13 | - (void)responderWithKey:(NSString *)key value:(id)value {
14 | [[self nextResponder] responderWithKey:key value:value];
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "NNTableView.h"
11 |
12 | @interface ViewController ()
13 |
14 | @end
15 |
16 | @implementation ViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 | NNTableView *tableView = [[NNTableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
21 | [self.view addSubview:tableView];
22 | }
23 |
24 | #pragma mark - 通过 UIResponder 传递事件
25 | - (void)responderWithKey:(NSString *)key value:(id)value {
26 | NSLog(@"%@", value);
27 | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"UIResponder 传递事件" message:value preferredStyle:UIAlertControllerStyleAlert];
28 | UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleDefault handler:nil];
29 | [alertController addAction:okAction];
30 | [self presentViewController:alertController animated:YES completion:nil];
31 | }
32 |
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTest/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // NNResponderTest
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTestTests/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 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTestTests/NNResponderTestTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNResponderTestTests.m
3 | // NNResponderTestTests
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNResponderTestTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NNResponderTestTests
16 |
17 | - (void)setUp {
18 | // Put setup code here. This method is called before the invocation of each test method in the class.
19 | }
20 |
21 | - (void)tearDown {
22 | // Put teardown code here. This method is called after the invocation of each test method in the class.
23 | }
24 |
25 | - (void)testExample {
26 | // This is an example of a functional test case.
27 | // Use XCTAssert and related functions to verify your tests produce the correct results.
28 | }
29 |
30 | - (void)testPerformanceExample {
31 | // This is an example of a performance test case.
32 | [self measureBlock:^{
33 | // Put the code you want to measure the time of here.
34 | }];
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTestUITests/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 |
--------------------------------------------------------------------------------
/019.NNResponderTest/NNResponderTestUITests/NNResponderTestUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNResponderTestUITests.m
3 | // NNResponderTestUITests
4 | //
5 | // Created by 刘朋坤 on 2019/1/5.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface NNResponderTestUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation NNResponderTestUITests
16 |
17 | - (void)setUp {
18 | // Put setup code here. This method is called before the invocation of each test method in the class.
19 |
20 | // In UI tests it is usually best to stop immediately when a failure occurs.
21 | self.continueAfterFailure = NO;
22 |
23 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
24 | [[[XCUIApplication alloc] init] launch];
25 |
26 | // 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.
27 | }
28 |
29 | - (void)tearDown {
30 | // Put teardown code here. This method is called after the invocation of each test method in the class.
31 | }
32 |
33 | - (void)testExample {
34 | // Use recording to get started writing UI tests.
35 | // Use XCTAssert and related functions to verify your tests produce the correct results.
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/019.NNResponderTest/README.md:
--------------------------------------------------------------------------------
1 | ## view 事件传递,用 UIResponder 替代代理与block,传递事件更方便;
2 |
3 | - 核心代码,在 UIResponder 的分类 UIResponder+responder 中:
4 |
5 |
6 | ```
7 |
8 | - (void)responderWithKey:(NSString *)key value:(id)value {
9 | [[self nextResponder] responderWithKey:key value:value];
10 | }
11 |
12 | ```
13 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram.xcodeproj/project.xcworkspace/xcuserdata/DJ.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuPengKun1993/NNLearn/23a0090066d81066aa539719fca83a261443a5e9/020.NNSwiftOCProgram/NNSwiftOCProgram.xcodeproj/project.xcworkspace/xcuserdata/DJ.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram.xcodeproj/xcuserdata/DJ.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram.xcodeproj/xcuserdata/DJ.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | NNSwiftOCProgram.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram/NNSwiftOCProgram-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 "NNViewController.h"
7 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram/NNSwiftOCProgram.xcdatamodeld/.xccurrentversion:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | _XCCurrentVersionName
6 | NNSwiftOCProgram.xcdatamodel
7 |
8 |
9 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram/NNSwiftOCProgram.xcdatamodeld/NNSwiftOCProgram.xcdatamodel/contents:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram/NNView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNView.swift
3 | // NNSwiftOCProgram
4 | //
5 | // Created by 刘朋坤 on 2019/1/7.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @objc protocol NNViewProtocol: NSObjectProtocol {
12 | @objc func clickAction()
13 | }
14 |
15 | class NNView: UIView {
16 |
17 | @objc weak var delegate:NNViewProtocol?
18 |
19 | override init(frame: CGRect) {
20 | super.init(frame: frame)
21 | self.backgroundColor = UIColor.red
22 | addSubview(button)
23 | }
24 |
25 | required init?(coder aDecoder: NSCoder) {
26 | fatalError("init(coder:) has not been implemented")
27 | }
28 |
29 | @objc func buttonClick() {
30 | if (delegate != nil) {
31 | delegate?.clickAction()
32 | }
33 | }
34 |
35 | lazy var button:UIButton = {
36 | let tempButton = UIButton.init(frame: CGRect.init(x: 10, y: 35, width: 80, height: 30))
37 | tempButton.backgroundColor = UIColor.gray
38 | tempButton.setTitle("跳转", for: .normal)
39 | tempButton.addTarget(self, action: #selector(buttonClick), for: .touchUpInside)
40 | return tempButton
41 | }()
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram/NNViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // NNViewController.h
3 | // NNSwiftOCProgram
4 | //
5 | // Created by 刘朋坤 on 2019/1/7.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface NNViewController : UIViewController
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram/NNViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // NNViewController.m
3 | // NNSwiftOCProgram
4 | //
5 | // Created by 刘朋坤 on 2019/1/7.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | #import "NNViewController.h"
10 | #import "NNSwiftOCProgram-Swift.h"
11 |
12 | @interface NNViewController ()
13 |
14 | @end
15 |
16 | @implementation NNViewController
17 |
18 | - (void)viewDidLoad {
19 | [super viewDidLoad];
20 | self.view.backgroundColor = [UIColor cyanColor];
21 | self.navigationItem.title = @"OC 调用 Swift";
22 | NNView *nnView = [[NNView alloc] initWithFrame:CGRectMake(200, 200, 100, 100)];
23 | [self.view addSubview:nnView];
24 | nnView.delegate = self;
25 | }
26 |
27 | - (void)clickAction {
28 | ViewController *controller = [[ViewController alloc] init];
29 | [self.navigationController pushViewController:controller animated:YES];
30 | }
31 |
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgram/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // NNSwiftOCProgram
4 | //
5 | // Created by 刘朋坤 on 2019/1/7.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ViewController: UIViewController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 | view.addSubview(nnView)
16 | view.backgroundColor = UIColor.white
17 | }
18 |
19 | lazy var nnView:NNView = {
20 | let tempView = NNView.init(frame: CGRect.init(x: 100, y: 100, width: 100, height: 100))
21 | tempView.delegate = self
22 | return tempView
23 | }()
24 |
25 | }
26 |
27 | extension ViewController : NNViewProtocol {
28 | func clickAction() {
29 | self.navigationController?.pushViewController(NNViewController.init(), animated: true)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgramTests/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 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgramTests/NNSwiftOCProgramTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNSwiftOCProgramTests.swift
3 | // NNSwiftOCProgramTests
4 | //
5 | // Created by 刘朋坤 on 2019/1/7.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import NNSwiftOCProgram
11 |
12 | class NNSwiftOCProgramTests: XCTestCase {
13 |
14 | override func setUp() {
15 | // Put setup code here. This method is called before the invocation of each test method in the class.
16 | }
17 |
18 | override func tearDown() {
19 | // Put teardown code here. This method is called after the invocation of each test method in the class.
20 | }
21 |
22 | func testExample() {
23 | // This is an example of a functional test case.
24 | // Use XCTAssert and related functions to verify your tests produce the correct results.
25 | }
26 |
27 | func testPerformanceExample() {
28 | // This is an example of a performance test case.
29 | self.measure {
30 | // Put the code you want to measure the time of here.
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgramUITests/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 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/NNSwiftOCProgramUITests/NNSwiftOCProgramUITests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NNSwiftOCProgramUITests.swift
3 | // NNSwiftOCProgramUITests
4 | //
5 | // Created by 刘朋坤 on 2019/1/7.
6 | // Copyright © 2019 刘朋坤. All rights reserved.
7 | //
8 |
9 | import XCTest
10 |
11 | class NNSwiftOCProgramUITests: XCTestCase {
12 |
13 | override func setUp() {
14 | // Put setup code here. This method is called before the invocation of each test method in the class.
15 |
16 | // In UI tests it is usually best to stop immediately when a failure occurs.
17 | continueAfterFailure = false
18 |
19 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
20 | XCUIApplication().launch()
21 |
22 | // 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.
23 | }
24 |
25 | override func tearDown() {
26 | // Put teardown code here. This method is called after the invocation of each test method in the class.
27 | }
28 |
29 | func testExample() {
30 | // Use recording to get started writing UI tests.
31 | // Use XCTAssert and related functions to verify your tests produce the correct results.
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/020.NNSwiftOCProgram/README.md:
--------------------------------------------------------------------------------
1 |
2 | ### OC Swift 混编
3 |
4 | #### 设置: target-->build setting -->Packaging -->Defines Module 改为 “YES”;
5 |
6 | - Swift 调用 OC
7 |
8 | > 在桥接文件 `项目名-Bridging-Header` 中引入 OC 头文件:
9 | eg: `#import "NNViewController.h"`
10 |
11 |
12 | - OC 调用 Swift
13 |
14 | > 在需要调用的 OC 类里引用` #import "项目名-Swift.h"`,另外对于需要混编的 Swift 类里添加 `@objc` 声明或继承 NSObject 或 NSObject 的子类;
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 以梦为马
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 |
--------------------------------------------------------------------------------