├── LICENSE
├── README.md
├── [1]. Ojbect-Oriented design principle Demo
├── [1] .Single Responsibility Principle
│ ├── SRPDemo1
│ │ ├── README.md
│ │ ├── SRPDemo1.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata
│ │ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── xcschemes
│ │ │ │ └── xcschememanagement.plist
│ │ ├── SRPDemo1
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Employee.h
│ │ │ ├── Employee.m
│ │ │ ├── FinancialApartment.h
│ │ │ ├── FinancialApartment.m
│ │ │ ├── HRApartment.h
│ │ │ ├── HRApartment.m
│ │ │ ├── Info.plist
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ ├── SRPDemo1Tests
│ │ │ ├── Info.plist
│ │ │ └── SRPDemo1Tests.m
│ │ └── SRPDemo1UITests
│ │ │ ├── Info.plist
│ │ │ └── SRPDemo1UITests.m
│ └── SRPDemo2
│ │ ├── README.md
│ │ ├── SRPDemo2.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ ├── SRPDemo2
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Employee.h
│ │ ├── Employee.m
│ │ ├── FinancialApartment.h
│ │ ├── FinancialApartment.m
│ │ ├── HRApartment.h
│ │ ├── HRApartment.m
│ │ ├── Info.plist
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ │ ├── SRPDemo2Tests
│ │ ├── Info.plist
│ │ └── SRPDemo2Tests.m
│ │ └── SRPDemo2UITests
│ │ ├── Info.plist
│ │ └── SRPDemo2UITests.m
├── [2]. Open Close Principle
│ ├── OCPDemo1
│ │ ├── OCPDemo1.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata
│ │ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── xcschemes
│ │ │ │ └── xcschememanagement.plist
│ │ ├── OCPDemo1
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Course.h
│ │ │ ├── Course.m
│ │ │ ├── Info.plist
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ ├── OCPDemo1Tests
│ │ │ ├── Info.plist
│ │ │ └── OCPDemo1Tests.m
│ │ ├── OCPDemo1UITests
│ │ │ ├── Info.plist
│ │ │ └── OCPDemo1UITests.m
│ │ └── README.md
│ └── OCPDemo2
│ │ ├── OCPDemo2.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ ├── OCPDemo2
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── AudioCourse.h
│ │ ├── AudioCourse.m
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Course.h
│ │ ├── Course.m
│ │ ├── Info.plist
│ │ ├── LiveCourse.h
│ │ ├── LiveCourse.m
│ │ ├── TextCourse.h
│ │ ├── TextCourse.m
│ │ ├── VideoCourse.h
│ │ ├── VideoCourse.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ │ ├── OCPDemo2Tests
│ │ ├── Info.plist
│ │ └── OCPDemo2Tests.m
│ │ ├── OCPDemo2UITests
│ │ ├── Info.plist
│ │ └── OCPDemo2UITests.m
│ │ └── README.md
├── [3]. Liskov Substitution Principle
│ ├── LSPDemo1
│ │ ├── LSPDemo1.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata
│ │ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ │ ├── IDEFindNavigatorScopes.plist
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ ├── xcdebugger
│ │ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ │ └── xcschemes
│ │ │ │ └── xcschememanagement.plist
│ │ ├── LSPDemo1
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Info.plist
│ │ │ ├── Rectangle.h
│ │ │ ├── Rectangle.m
│ │ │ ├── Square.h
│ │ │ ├── Square.m
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ ├── LSPDemo1Tests
│ │ │ ├── Info.plist
│ │ │ └── LSPDemo1Tests.m
│ │ ├── LSPDemo1UITests
│ │ │ ├── Info.plist
│ │ │ └── LSPDemo1UITests.m
│ │ └── README.md
│ └── LSPDemo2
│ │ ├── LSPDemo2.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ ├── LSPDemo2
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ ├── Quadrangle.h
│ │ ├── Quadrangle.m
│ │ ├── Rectangle.h
│ │ ├── Rectangle.m
│ │ ├── Square.h
│ │ ├── Square.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ │ ├── LSPDemo2Tests
│ │ ├── Info.plist
│ │ └── LSPDemo2Tests.m
│ │ ├── LSPDemo2UITests
│ │ ├── Info.plist
│ │ └── LSPDemo2UITests.m
│ │ └── README.md
├── [4]. Law of Demeter
│ ├── LODDemo1
│ │ ├── LODDemo1.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata
│ │ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── xcschemes
│ │ │ │ └── xcschememanagement.plist
│ │ ├── LODDemo1
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Car.h
│ │ │ ├── Car.m
│ │ │ ├── GasEngine.h
│ │ │ ├── GasEngine.m
│ │ │ ├── Info.plist
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ ├── LODDemo1Tests
│ │ │ ├── Info.plist
│ │ │ └── LODDemo1Tests.m
│ │ ├── LODDemo1UITests
│ │ │ ├── Info.plist
│ │ │ └── LODDemo1UITests.m
│ │ └── README.md
│ └── LODDemo2
│ │ ├── LODDemo2.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ ├── LODDemo2
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Car.h
│ │ ├── Car.m
│ │ ├── GasEngine.h
│ │ ├── GasEngine.m
│ │ ├── Info.plist
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ │ ├── LODDemo2Tests
│ │ ├── Info.plist
│ │ └── LODDemo2Tests.m
│ │ ├── LODDemo2UITests
│ │ ├── Info.plist
│ │ └── LODDemo2UITests.m
│ │ └── README.md
├── [5]. Interface Segregation Principle
│ ├── ISPDemo1
│ │ ├── ISPDemo1.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ ├── xcshareddata
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ │ └── xcuserdata
│ │ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ │ └── UserInterfaceState.xcuserstate
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── xcschemes
│ │ │ │ └── xcschememanagement.plist
│ │ ├── ISPDemo1
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Info.plist
│ │ │ ├── OnlineClient.h
│ │ │ ├── OnlineClient.m
│ │ │ ├── RestaurantProtocol.h
│ │ │ ├── TelephoneClient.h
│ │ │ ├── TelephoneClient.m
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ ├── WalkinClient.h
│ │ │ ├── WalkinClient.m
│ │ │ └── main.m
│ │ ├── ISPDemo1Tests
│ │ │ ├── ISPDemo1Tests.m
│ │ │ └── Info.plist
│ │ ├── ISPDemo1UITests
│ │ │ ├── ISPDemo1UITests.m
│ │ │ └── Info.plist
│ │ └── README.md
│ └── ISPDemo2
│ │ ├── ISPDemo2.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ ├── ISPDemo2
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Client.h
│ │ ├── Client.m
│ │ ├── Info.plist
│ │ ├── OnlineClient.h
│ │ ├── OnlineClient.m
│ │ ├── RestaurantPaymentProtocol.h
│ │ ├── RestaurantPlaceOrderProtocol.h
│ │ ├── TelephoneClient.h
│ │ ├── TelephoneClient.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ ├── WalkinClient.h
│ │ ├── WalkinClient.m
│ │ └── main.m
│ │ ├── ISPDemo2Tests
│ │ ├── ISPDemo2Tests.m
│ │ └── Info.plist
│ │ ├── ISPDemo2UITests
│ │ ├── ISPDemo2UITests.m
│ │ └── Info.plist
│ │ └── README.md
└── [6]. Dependency Inversion Principle
│ ├── DIPDemo1
│ ├── DIPDemo1.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── DIPDemo1
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── BackEndDeveloper.h
│ │ ├── BackEndDeveloper.m
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── FrondEndDeveloper.h
│ │ ├── FrondEndDeveloper.m
│ │ ├── Info.plist
│ │ ├── Project.h
│ │ ├── Project.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ ├── DIPDemo1Tests
│ │ ├── DIPDemo1Tests.m
│ │ └── Info.plist
│ ├── DIPDemo1UITests
│ │ ├── DIPDemo1UITests.m
│ │ └── Info.plist
│ └── README.md
│ └── DIPDemo2
│ ├── DIPDemo2.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── sunshijie.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
│ ├── DIPDemo2
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── BackEndDeveloper.h
│ ├── BackEndDeveloper.m
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── DeveloperProtocol.h
│ ├── FrondEndDeveloper.h
│ ├── FrondEndDeveloper.m
│ ├── Info.plist
│ ├── Project.h
│ ├── Project.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── main.m
│ ├── DIPDemo2Tests
│ ├── DIPDemo2Tests.m
│ └── Info.plist
│ ├── DIPDemo2UITests
│ ├── DIPDemo2UITests.m
│ └── Info.plist
│ └── README.md
├── [2]. Ojbect-Oriented design pattern Demo
├── [10]. Proxy Pattern Demo
│ ├── PPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── PPDemo
│ │ ├── HouseOwner.h
│ │ ├── HouseOwner.m
│ │ ├── HouseProxy.h
│ │ ├── HouseProxy.m
│ │ ├── Info.plist
│ │ ├── PaymentInterface.h
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ └── main.m
│ ├── PPDemoTests
│ │ ├── Info.plist
│ │ └── PPDemoTests.m
│ ├── PPDemoUITests
│ │ ├── Info.plist
│ │ └── PPDemoUITests.m
│ └── README.md
├── [11]. Decorator Pattern Demo
│ ├── DPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── DPDemo
│ │ ├── Decorators
│ │ │ ├── BlueBerrySauceDecorator.h
│ │ │ ├── BlueBerrySauceDecorator.m
│ │ │ ├── PeanutButterSauceDecorator.h
│ │ │ ├── PeanutButterSauceDecorator.m
│ │ │ ├── SauceDecorator.h
│ │ │ ├── SauceDecorator.m
│ │ │ ├── VinegarSauceDecorator.h
│ │ │ └── VinegarSauceDecorator.m
│ │ ├── Info.plist
│ │ ├── Salad
│ │ │ ├── BeefSalad.h
│ │ │ ├── BeefSalad.m
│ │ │ ├── ChickenSalad.h
│ │ │ ├── ChickenSalad.m
│ │ │ ├── Salad.h
│ │ │ ├── Salad.m
│ │ │ ├── VegetableSalad.h
│ │ │ └── VegetableSalad.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ └── main.m
│ ├── DPDemoTests
│ │ ├── DPDemoTests.m
│ │ └── Info.plist
│ ├── DPDemoUITests
│ │ ├── DPDemoUITests.m
│ │ └── Info.plist
│ └── README.md
├── [12]. Flyweight Pattern Demo
│ ├── FWPD.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── FWPD
│ │ ├── FlowerFactory.h
│ │ ├── FlowerFactory.m
│ │ ├── FlowerImageView.h
│ │ ├── FlowerImageView.m
│ │ ├── Info.plist
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ ├── Contents.json
│ │ │ ├── anemone.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ └── anemone.png
│ │ │ ├── cosmos.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ └── cosmos.png
│ │ │ ├── gerberas.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ └── gerberas.png
│ │ │ ├── hollyhock.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ └── hollyhock.png
│ │ │ ├── jasmine.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ └── jasmine.png
│ │ │ └── zinnia.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ └── zinnia.png
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ └── main.m
│ ├── FWPDTests
│ │ ├── FWPDTests.m
│ │ └── Info.plist
│ ├── FWPDUITests
│ │ ├── FWPDUITests.m
│ │ └── Info.plist
│ └── README.md
├── [13]. Template Pattern Demo
│ ├── README.md
│ ├── TPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ └── TPDemo
│ │ ├── Algorithm
│ │ ├── HotDrink.h
│ │ └── HotDrink.m
│ │ ├── Client
│ │ ├── ViewController.h
│ │ └── ViewController.m
│ │ ├── Concrete Algorithm
│ │ ├── HotDrinkAmericano.h
│ │ ├── HotDrinkAmericano.m
│ │ ├── HotDrinkLatte.h
│ │ ├── HotDrinkLatte.m
│ │ ├── HotDrinkTea.h
│ │ └── HotDrinkTea.m
│ │ ├── Info.plist
│ │ ├── Other
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ └── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ └── main.m
├── [14]. Strategy Pattern Demo
│ ├── README.md
│ ├── SPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ └── SPDemo
│ │ ├── Client
│ │ ├── ViewController.h
│ │ └── ViewController.m
│ │ ├── Context
│ │ ├── Context.h
│ │ └── Context.m
│ │ ├── Info.plist
│ │ ├── Other
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ └── main.m
│ │ └── Strategy
│ │ ├── Abstract Strategy
│ │ ├── TwoIntOperation.h
│ │ └── TwoIntOperation.m
│ │ └── Contrete Strategy
│ │ ├── TwoIntOperationAdd.h
│ │ ├── TwoIntOperationAdd.m
│ │ ├── TwoIntOperationDivision.h
│ │ ├── TwoIntOperationDivision.m
│ │ ├── TwoIntOperationMultiply.h
│ │ ├── TwoIntOperationMultiply.m
│ │ ├── TwoIntOperationSubstract.h
│ │ └── TwoIntOperationSubstract.m
├── [15]. Chain of Responsibilty Pattern Demo (before refactoring)
│ ├── CRPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── CRPDemo
│ │ ├── ATMDispenseChain.h
│ │ ├── ATMDispenseChain.m
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Currency.h
│ │ ├── Currency.m
│ │ ├── DispenseChainNode.h
│ │ ├── DispenseChainNode.m
│ │ ├── DispenseChainNodeFor10Yuan.h
│ │ ├── DispenseChainNodeFor10Yuan.m
│ │ ├── DispenseChainNodeFor20Yuan.h
│ │ ├── DispenseChainNodeFor20Yuan.m
│ │ ├── DispenseChainNodeFor50Yuan.h
│ │ ├── DispenseChainNodeFor50Yuan.m
│ │ ├── DispenseProtocol.h
│ │ ├── Info.plist
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ └── README.md
├── [16]. Chain of Responsibilty Pattern Demo (after refactoring)
│ ├── CRPDemo2.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── CRPDemo2
│ │ ├── ATMDispenseChain.h
│ │ ├── ATMDispenseChain.m
│ │ ├── DispenseChainNode.h
│ │ ├── DispenseChainNode.m
│ │ ├── DispenseProtocol.h
│ │ ├── Info.plist
│ │ ├── Other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── ViewController.h
│ │ │ └── ViewController.m
│ │ └── main.m
│ └── README.md
├── [17]. State Pattern Demo
│ ├── README.md
│ ├── STPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ └── STPDemo
│ │ ├── ActionProtocol.h
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Coder.h
│ │ ├── Coder.m
│ │ ├── Info.plist
│ │ ├── State.h
│ │ ├── State.m
│ │ ├── StateAwake.h
│ │ ├── StateAwake.m
│ │ ├── StateCoding.h
│ │ ├── StateCoding.m
│ │ ├── StateEating.h
│ │ ├── StateEating.m
│ │ ├── StateSleeping.h
│ │ ├── StateSleeping.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
├── [18]. Command Pattern Demo
│ ├── CPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── CPDemo
│ │ ├── Command
│ │ │ ├── Command.h
│ │ │ ├── Command.m
│ │ │ ├── CommandLightOff.h
│ │ │ ├── CommandLightOff.m
│ │ │ ├── CommandLightOn.h
│ │ │ └── CommandLightOn.m
│ │ ├── Info.plist
│ │ ├── Invoker
│ │ │ ├── RemoteControl.h
│ │ │ └── RemoteControl.m
│ │ ├── Other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── ViewController.h
│ │ │ ├── ViewController.m
│ │ │ └── main.m
│ │ └── Receiver
│ │ │ ├── Light.h
│ │ │ └── Light.m
│ └── README.md
├── [19]. Observer Pattern Demo
│ ├── OPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── OPDemo
│ │ ├── Info.plist
│ │ ├── Observer
│ │ │ ├── Investor.h
│ │ │ ├── Investor.m
│ │ │ ├── Observer.h
│ │ │ └── Observer.m
│ │ ├── Other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ └── main.m
│ │ ├── Subject
│ │ │ ├── FinancialAdviser.h
│ │ │ ├── FinancialAdviser.m
│ │ │ ├── Subject.h
│ │ │ └── Subject.m
│ │ ├── ViewController.h
│ │ └── ViewController.m
│ └── README.md
├── [1]. Simple Factory Pattern Demo
│ ├── README.md
│ ├── SFPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── SFPDemo
│ │ ├── Client
│ │ │ ├── Store.h
│ │ │ └── Store.m
│ │ ├── Factory
│ │ │ ├── PhoneFactory.h
│ │ │ └── PhoneFactory.m
│ │ ├── Info.plist
│ │ ├── Product
│ │ │ ├── HWPhone.h
│ │ │ ├── HWPhone.m
│ │ │ ├── IPhone.h
│ │ │ ├── IPhone.m
│ │ │ ├── MIPhone.h
│ │ │ ├── MIPhone.m
│ │ │ ├── Phone.h
│ │ │ └── Phone.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ └── main.m
│ ├── SFPDemoTests
│ │ ├── Info.plist
│ │ └── SFPDemoTests.m
│ └── SFPDemoUITests
│ │ ├── Info.plist
│ │ └── SFPDemoUITests.m
├── [20].Mediator Pattern Demo
│ ├── MPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── MPDemo
│ │ ├── ChatMediator.h
│ │ ├── ChatMediator.m
│ │ ├── Info.plist
│ │ ├── Other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── ViewController.h
│ │ │ └── ViewController.m
│ │ ├── User.h
│ │ ├── User.m
│ │ └── main.m
│ └── README.md
├── [2]. Factory Method Pattern Demo
│ ├── FMPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── FMPDemo
│ │ ├── Client
│ │ │ ├── Store.h
│ │ │ └── Store.m
│ │ ├── Factory
│ │ │ ├── HWPhoneFactory.h
│ │ │ ├── HWPhoneFactory.m
│ │ │ ├── IPhoneFactory.h
│ │ │ ├── IPhoneFactory.m
│ │ │ ├── MIPhoneFactory.h
│ │ │ ├── MIPhoneFactory.m
│ │ │ ├── PhoneFactory.h
│ │ │ └── PhoneFactory.m
│ │ ├── Info.plist
│ │ ├── Product
│ │ │ ├── HWPhone.h
│ │ │ ├── HWPhone.m
│ │ │ ├── IPhone.h
│ │ │ ├── IPhone.m
│ │ │ ├── MIPhone.h
│ │ │ ├── MIPhone.m
│ │ │ ├── Phone.h
│ │ │ └── Phone.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ └── main.m
│ ├── FMPDemoTests
│ │ ├── FMPDemoTests.m
│ │ └── Info.plist
│ ├── FMPDemoUITests
│ │ ├── FMPDemoUITests.m
│ │ └── Info.plist
│ └── README.md
├── [3]. Abstract Factory Pattern Demo
│ ├── AFPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── AFPDemo
│ │ ├── Client
│ │ │ ├── Store.h
│ │ │ └── Store.m
│ │ ├── Factory
│ │ │ ├── AppleFactory.h
│ │ │ ├── AppleFactory.m
│ │ │ ├── Factory.h
│ │ │ ├── Factory.m
│ │ │ ├── HWFactory.h
│ │ │ ├── HWFactory.m
│ │ │ ├── MIFactory.h
│ │ │ └── MIFactory.m
│ │ ├── Info.plist
│ │ ├── Other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ └── main.m
│ │ ├── Product - Computer
│ │ │ ├── Computer.h
│ │ │ ├── Computer.m
│ │ │ ├── MIComputer.h
│ │ │ ├── MIComputer.m
│ │ │ ├── MacBookComputer.h
│ │ │ ├── MacBookComputer.m
│ │ │ ├── MateBookComputer.h
│ │ │ └── MateBookComputer.m
│ │ ├── Product - Phone
│ │ │ ├── HWPhone.h
│ │ │ ├── HWPhone.m
│ │ │ ├── IPhone.h
│ │ │ ├── IPhone.m
│ │ │ ├── MIPhone.h
│ │ │ ├── MIPhone.m
│ │ │ ├── Phone.h
│ │ │ └── Phone.m
│ │ ├── ViewController.h
│ │ └── ViewController.m
│ ├── AFPDemoTests
│ │ ├── AFPDemoTests.m
│ │ └── Info.plist
│ ├── AFPDemoUITests
│ │ ├── AFPDemoUITests.m
│ │ └── Info.plist
│ └── README.md
├── [4]. Singleton Pattern Demo
│ ├── README.md
│ ├── SPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── SPDemo
│ │ ├── Info.plist
│ │ ├── LogManager.h
│ │ ├── LogManager.m
│ │ ├── ViewController.h
│ │ └── ViewController.m
│ ├── SPDemoTests
│ │ ├── Info.plist
│ │ └── SPDemoTests.m
│ ├── SPDemoUITests
│ │ ├── Info.plist
│ │ └── SPDemoUITests.m
│ └── other
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ └── main.m
├── [5]. Builder Pattern Demo
│ ├── BPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ ├── xcdebugger
│ │ │ └── Breakpoints_v2.xcbkptlist
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── BPDemo
│ │ ├── Builder
│ │ │ ├── Builder.h
│ │ │ ├── Builder.m
│ │ │ ├── IPhoneXRBuilder.h
│ │ │ ├── IPhoneXRBuilder.m
│ │ │ ├── MI8Builder.h
│ │ │ └── MI8Builder.m
│ │ ├── Director
│ │ │ ├── Director.h
│ │ │ └── Director.m
│ │ ├── Info.plist
│ │ ├── Other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ │ ├── AppIcon.appiconset
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ └── main.m
│ │ ├── Product
│ │ │ ├── Phone.h
│ │ │ └── Phone.m
│ │ ├── ViewController.h
│ │ └── ViewController.m
│ ├── BPDemoTests
│ │ ├── BPDemoTests.m
│ │ └── Info.plist
│ ├── BPDemoUITests
│ │ ├── BPDemoUITests.m
│ │ └── Info.plist
│ └── README.md
├── [6]. Prototype Pattern Demo
│ ├── PPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── PPDemo
│ │ ├── CollageInfo.h
│ │ ├── CollageInfo.m
│ │ ├── Info.plist
│ │ ├── Resume.h
│ │ ├── Resume.m
│ │ ├── UniversityInfo.h
│ │ ├── UniversityInfo.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ └── main.m
│ ├── PPDemoTests
│ │ ├── Info.plist
│ │ └── PPDemoTests.m
│ ├── PPDemoUITests
│ │ ├── Info.plist
│ │ └── PPDemoUITests.m
│ └── README.md
├── [7]. Facade Pattern Demo
│ ├── FPDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── FPDemo
│ │ ├── AirConditioner.h
│ │ ├── AirConditioner.m
│ │ ├── CDPlayer.h
│ │ ├── CDPlayer.m
│ │ ├── DVDPlayer.h
│ │ ├── DVDPlayer.m
│ │ ├── HomeDevice.h
│ │ ├── HomeDevice.m
│ │ ├── HomeDeviceManager.h
│ │ ├── HomeDeviceManager.m
│ │ ├── Info.plist
│ │ ├── Projecter.h
│ │ ├── Projecter.m
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ ├── VoiceBox.h
│ │ ├── VoiceBox.m
│ │ └── other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ └── main.m
│ ├── FPDemoTests
│ │ ├── FPDemoTests.m
│ │ └── Info.plist
│ ├── FPDemoUITests
│ │ ├── FPDemoUITests.m
│ │ └── Info.plist
│ └── README.md
├── [8]. Adaptor Pattern Demo
│ ├── APDemo.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcuserdata
│ │ │ │ └── sunshijie.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ ├── APDemo
│ │ ├── Adaptor
│ │ │ ├── Adaptor.h
│ │ │ └── Adaptor.m
│ │ ├── Info.plist
│ │ ├── NewCache
│ │ │ ├── NewCache.h
│ │ │ ├── NewCache.m
│ │ │ └── NewCacheProtocol.h
│ │ ├── OldCache
│ │ │ ├── OldCache.h
│ │ │ ├── OldCache.m
│ │ │ └── OldCacheProtocol.h
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── other
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ │ └── Contents.json
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ └── main.m
│ ├── APDemoTests
│ │ ├── APDemoTests.m
│ │ └── Info.plist
│ ├── APDemoUITests
│ │ ├── APDemoUITests.m
│ │ └── Info.plist
│ └── README.md
└── [9]. Bridge Pattern Demo
│ ├── BPDemo.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── sunshijie.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── sunshijie.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
│ ├── BPDemo
│ ├── Color
│ │ ├── BlueColor.h
│ │ ├── BlueColor.m
│ │ ├── Color.h
│ │ ├── Color.m
│ │ ├── GreenColor.h
│ │ ├── GreenColor.m
│ │ ├── RedColor.h
│ │ └── RedColor.m
│ ├── Info.plist
│ ├── Shape
│ │ ├── Circle.h
│ │ ├── Circle.m
│ │ ├── Rectangle.h
│ │ ├── Rectangle.m
│ │ ├── Shape.h
│ │ ├── Shape.m
│ │ ├── Square.h
│ │ └── Square.m
│ ├── ViewController.h
│ ├── ViewController.m
│ └── other
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ └── main.m
│ ├── BPDemoTests
│ ├── BPDemoTests.m
│ └── Info.plist
│ ├── BPDemoUITests
│ ├── BPDemoUITests.m
│ └── Info.plist
│ └── README.md
└── res
└── banner.png
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/Employee.m:
--------------------------------------------------------------------------------
1 | //
2 | // Employee.m
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Employee.h"
10 |
11 | @implementation Employee
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/FinancialApartment.h:
--------------------------------------------------------------------------------
1 | //
2 | // FinancialApartment.h
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Employee.h"
11 |
12 | @interface FinancialApartment : NSObject
13 |
14 | - (double)calculateSalary:(Employee *)employee;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/FinancialApartment.m:
--------------------------------------------------------------------------------
1 | //
2 | // FinancialApartment.m
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "FinancialApartment.h"
10 |
11 | @implementation FinancialApartment
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/HRApartment.h:
--------------------------------------------------------------------------------
1 | //
2 | // HRApartment.h
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Employee.h"
11 |
12 | @interface HRApartment : NSObject
13 |
14 | - (BOOL)willPromotionThisYear:(Employee*)employee;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/HRApartment.m:
--------------------------------------------------------------------------------
1 | //
2 | // HRApartment.m
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "HRApartment.h"
10 |
11 | @implementation HRApartment
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo1/SRPDemo1/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SRPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/29.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/Employee.h:
--------------------------------------------------------------------------------
1 | //
2 | // Employee.h
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Employee : NSObject
12 |
13 | //初始需求
14 | @property (nonatomic, copy) NSString *name;
15 | @property (nonatomic, copy) NSString *address;
16 | @property (nonatomic, copy) NSString *employeeID;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/Employee.m:
--------------------------------------------------------------------------------
1 | //
2 | // Employee.m
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Employee.h"
10 |
11 | @implementation Employee
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/FinancialApartment.h:
--------------------------------------------------------------------------------
1 | //
2 | // FinancialApartment.h
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Employee.h"
11 |
12 | @interface FinancialApartment : NSObject
13 |
14 | - (double)calculateSalary:(Employee *)employee;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/FinancialApartment.m:
--------------------------------------------------------------------------------
1 | //
2 | // FinancialApartment.m
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "FinancialApartment.h"
10 |
11 | @implementation FinancialApartment
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/HRApartment.h:
--------------------------------------------------------------------------------
1 | //
2 | // HRApartment.h
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Employee.h"
11 |
12 | @interface HRApartment : NSObject
13 |
14 | - (BOOL)willGetPromotionThisYear:(Employee*)employee;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/HRApartment.m:
--------------------------------------------------------------------------------
1 | //
2 | // HRApartment.m
3 | // SRPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "HRApartment.h"
10 |
11 | @implementation HRApartment
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // SRPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/29.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[1] .Single Responsibility Principle/SRPDemo2/SRPDemo2/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SRPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/29.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // OCPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1/Course.m:
--------------------------------------------------------------------------------
1 | //
2 | // Course.m
3 | // OCPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Course.h"
10 |
11 | @implementation Course
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // OCPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo1/OCPDemo1/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // OCPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/AudioCourse.h:
--------------------------------------------------------------------------------
1 | //
2 | // AudioCourse.h
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Course.h"
10 |
11 | @interface AudioCourse : Course
12 |
13 | @property (nonatomic, copy) NSString *audioUrl; //音频地址
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/AudioCourse.m:
--------------------------------------------------------------------------------
1 | //
2 | // AudioCourse.m
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "AudioCourse.h"
10 |
11 | @implementation AudioCourse
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/Course.m:
--------------------------------------------------------------------------------
1 | //
2 | // Course.m
3 | // OCPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Course.h"
10 |
11 | @implementation Course
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/LiveCourse.h:
--------------------------------------------------------------------------------
1 | //
2 | // LiveCourse.h
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Course.h"
10 |
11 | @interface LiveCourse : Course
12 |
13 | @property (nonatomic, copy) NSString *liveUrl; //直播地址
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/LiveCourse.m:
--------------------------------------------------------------------------------
1 | //
2 | // LiveCourse.m
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "LiveCourse.h"
10 |
11 | @implementation LiveCourse
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/TextCourse.h:
--------------------------------------------------------------------------------
1 | //
2 | // TextCourse.h
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Course.h"
10 |
11 | @interface TextCourse : Course
12 |
13 | @property (nonatomic, copy) NSString *content; //文字内容
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/TextCourse.m:
--------------------------------------------------------------------------------
1 | //
2 | // TextCourse.m
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "TextCourse.h"
10 |
11 | @implementation TextCourse
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/VideoCourse.h:
--------------------------------------------------------------------------------
1 | //
2 | // VideoCourse.h
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Course.h"
10 |
11 | @interface VideoCourse : Course
12 |
13 | @property (nonatomic, copy) NSString *videoUrl; //视频地址
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/VideoCourse.m:
--------------------------------------------------------------------------------
1 | //
2 | // VideoCourse.m
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "VideoCourse.h"
10 |
11 | @implementation VideoCourse
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[2]. Open Close Principle/OCPDemo2/OCPDemo2/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // OCPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/IDEFindNavigatorScopes.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // LSPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1/Square.h:
--------------------------------------------------------------------------------
1 | //
2 | // Square.h
3 | // LSPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Rectangle.h"
10 |
11 | @interface Square : Rectangle
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // LSPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo1/LSPDemo1/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // LSPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // LSPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/2.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2/Quadrangle.m:
--------------------------------------------------------------------------------
1 | //
2 | // Quadrangle.m
3 | // LSPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/2.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Quadrangle.h"
10 |
11 | @implementation Quadrangle
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2/Rectangle.h:
--------------------------------------------------------------------------------
1 | //
2 | // Rectangle.h
3 | // LSPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Quadrangle.h"
11 |
12 | @interface Rectangle : Quadrangle
13 |
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2/Square.h:
--------------------------------------------------------------------------------
1 | //
2 | // Square.h
3 | // LSPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/9/1.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Quadrangle.h"
10 |
11 | @interface Square : Quadrangle
12 | {
13 | @protected double _sideLength;
14 | }
15 |
16 | -(void)setSideLength:(double)sideLength;
17 |
18 | -(double)sideLength;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // LSPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/2.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[3]. Liskov Substitution Principle/LSPDemo2/LSPDemo2/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // LSPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/9/2.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | LODDemo1.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1/Car.h:
--------------------------------------------------------------------------------
1 | //
2 | // Car.h
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class GasEngine;
12 |
13 | @interface Car : NSObject
14 |
15 | //构造方法
16 | - (instancetype)initWithEngine:(GasEngine *)engine;
17 |
18 | //返回私有成员变量:引擎的实例
19 | - (GasEngine *)usingEngine;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1/GasEngine.h:
--------------------------------------------------------------------------------
1 | //
2 | // GasEngine.h
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface GasEngine : NSObject
12 |
13 | @property (nonatomic, copy) NSString *brandName;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1/GasEngine.m:
--------------------------------------------------------------------------------
1 | //
2 | // GasEngine.m
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "GasEngine.h"
10 |
11 | @implementation GasEngine
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo1/LODDemo1/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | LODDemo2.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // LODDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2/Car.h:
--------------------------------------------------------------------------------
1 | //
2 | // Car.h
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class GasEngine;
12 |
13 | @interface Car : NSObject
14 |
15 | //构造方法
16 | - (instancetype)initWithEngine:(GasEngine *)engine;
17 |
18 | //直接返回引擎品牌名称
19 | - (NSString *)usingEngineBrandName;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2/GasEngine.h:
--------------------------------------------------------------------------------
1 | //
2 | // GasEngine.h
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface GasEngine : NSObject
12 |
13 | @property (nonatomic, copy) NSString *brand;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2/GasEngine.m:
--------------------------------------------------------------------------------
1 | //
2 | // GasEngine.m
3 | // LODDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "GasEngine.h"
10 |
11 | @implementation GasEngine
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // LODDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[4]. Law of Demeter/LODDemo2/LODDemo2/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // LODDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1/OnlineClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // OnlineClient.h
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RestaurantProtocol.h"
11 |
12 | @interface OnlineClient : NSObject
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1/TelephoneClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // TelephoneClient.h
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RestaurantProtocol.h"
11 |
12 | @interface TelephoneClient : NSObject
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1/WalkinClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // WalkinClient.h
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "RestaurantProtocol.h"
11 |
12 | @interface WalkinClient : NSObject
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo1/ISPDemo1/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // ISPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/Client.h:
--------------------------------------------------------------------------------
1 | //
2 | // Client.h
3 | // ISPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "RestaurantPlaceOrderProtocol.h"
12 | #import "RestaurantPaymentProtocol.h"
13 |
14 | @interface Client : NSObject
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/Client.m:
--------------------------------------------------------------------------------
1 | //
2 | // Client.m
3 | // ISPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "Client.h"
10 |
11 | @implementation Client
12 |
13 | - (void)payOrder{
14 |
15 | }
16 |
17 | - (void)placeOrder{
18 |
19 | }
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/OnlineClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // OnlineClient.h
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Client.h"
11 |
12 | @interface OnlineClient : Client
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/OnlineClient.m:
--------------------------------------------------------------------------------
1 | //
2 | // OnlineClient.m
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "OnlineClient.h"
10 |
11 | @implementation OnlineClient
12 |
13 | - (void)placeOrder{
14 | NSLog(@"place on line order");
15 | }
16 |
17 | - (void)payOrder{
18 | NSLog(@"pay on line");
19 | }
20 | @end
21 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/RestaurantPaymentProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // RestaurantPaymentProtocol.h
3 | // ISPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol RestaurantPaymentProtocol
12 |
13 | - (void)payOrder;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/RestaurantPlaceOrderProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // RestaurantPlaceOrderProtocol.h
3 | // ISPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol RestaurantPlaceOrderProtocol
12 |
13 | - (void)placeOrder;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/TelephoneClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // TelephoneClient.h
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Client.h"
11 |
12 | @interface TelephoneClient : Client
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/TelephoneClient.m:
--------------------------------------------------------------------------------
1 | //
2 | // TelephoneClient.m
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "TelephoneClient.h"
10 |
11 | @implementation TelephoneClient
12 |
13 | - (void)placeOrder{
14 | NSLog(@"place telephone order");
15 | }
16 |
17 | - (void)payOrder{
18 | NSLog(@"pay on line");
19 | }
20 |
21 |
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // ISPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/WalkinClient.h:
--------------------------------------------------------------------------------
1 | //
2 | // WalkinClient.h
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Client.h"
11 |
12 | @interface WalkinClient : Client
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/WalkinClient.m:
--------------------------------------------------------------------------------
1 | //
2 | // WalkinClient.m
3 | // ISPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "WalkinClient.h"
10 |
11 | @implementation WalkinClient
12 |
13 | - (void)placeOrder{
14 | NSLog(@"place walk in customer order");
15 | }
16 |
17 | - (void)payOrder{
18 | NSLog(@"pay in person");
19 | }
20 |
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[5]. Interface Segregation Principle/ISPDemo2/ISPDemo2/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // ISPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/26.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/BackEndDeveloper.h:
--------------------------------------------------------------------------------
1 | //
2 | // BackEndDeveloper.h
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface BackEndDeveloper : NSObject
12 |
13 | - (void)writeJavaCode;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/BackEndDeveloper.m:
--------------------------------------------------------------------------------
1 | //
2 | // BackEndDeveloper.m
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "BackEndDeveloper.h"
10 |
11 | @implementation BackEndDeveloper
12 |
13 | - (void)writeJavaCode{
14 | NSLog(@"Write Java code");
15 | }
16 | @end
17 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/FrondEndDeveloper.h:
--------------------------------------------------------------------------------
1 | //
2 | // FrondEndDeveloper.h
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface FrondEndDeveloper : NSObject
12 |
13 | - (void)writeJavaScriptCode;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/FrondEndDeveloper.m:
--------------------------------------------------------------------------------
1 | //
2 | // FrondEndDeveloper.m
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "FrondEndDeveloper.h"
10 |
11 | @implementation FrondEndDeveloper
12 |
13 | - (void)writeJavaScriptCode{
14 | NSLog(@"Write JavaScript code");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/Project.h:
--------------------------------------------------------------------------------
1 | //
2 | // Project.h
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Project : NSObject
12 |
13 | - (instancetype)initWithDevelopers:(NSArray *)developers;
14 |
15 | - (void)startDeveloping;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo1/DIPDemo1/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // DIPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/BackEndDeveloper.h:
--------------------------------------------------------------------------------
1 | //
2 | // BackEndDeveloper.h
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "DeveloperProtocol.h"
11 |
12 | @interface BackEndDeveloper : NSObject
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/BackEndDeveloper.m:
--------------------------------------------------------------------------------
1 | //
2 | // BackEndDeveloper.m
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "BackEndDeveloper.h"
10 |
11 | @implementation BackEndDeveloper
12 |
13 | - (void)writeCode{
14 | NSLog(@"Write Java code");
15 | }
16 | @end
17 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/DeveloperProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // Developer.h
3 | // DIPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol DeveloperProtocol
12 |
13 | - (void)writeCode;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/FrondEndDeveloper.h:
--------------------------------------------------------------------------------
1 | //
2 | // FrondEndDeveloper.h
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "DeveloperProtocol.h"
11 |
12 | @interface FrondEndDeveloper : NSObject
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/FrondEndDeveloper.m:
--------------------------------------------------------------------------------
1 | //
2 | // FrondEndDeveloper.m
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import "FrondEndDeveloper.h"
10 |
11 | @implementation FrondEndDeveloper
12 |
13 | - (void)writeCode{
14 | NSLog(@"Write JavaScript code");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/Project.h:
--------------------------------------------------------------------------------
1 | //
2 | // Project.h
3 | // DIPDemo1
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "DeveloperProtocol.h"
11 |
12 | @interface Project : NSObject
13 |
14 | - (instancetype)initWithDevelopers:(NSArray >*)developers;
15 |
16 | - (void)startDeveloping;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // DIPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[1]. Ojbect-Oriented design principle Demo/[6]. Dependency Inversion Principle/DIPDemo2/DIPDemo2/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // DIPDemo2
4 | //
5 | // Created by J_Knight_ on 2018/8/25.
6 | // Copyright © 2018年 J_Knight_. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | PPDemo.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo/HouseOwner.h:
--------------------------------------------------------------------------------
1 | //
2 | // HouseOwner.h
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/19.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "PaymentInterface.h"
11 |
12 | @interface HouseOwner : NSObject
13 |
14 | @end
15 |
16 |
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo/HouseOwner.m:
--------------------------------------------------------------------------------
1 | //
2 | // HouseOwner.m
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/19.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HouseOwner.h"
10 |
11 | @implementation HouseOwner
12 |
13 | - (void)getPayment:(double)money{
14 |
15 | NSLog(@"House owner get payment : %.2lf",money);
16 | }
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo/HouseProxy.h:
--------------------------------------------------------------------------------
1 | //
2 | // HouseProxy.h
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/19.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "PaymentInterface.h"
11 |
12 | @interface HouseProxy : NSObject
13 |
14 | @end
15 |
16 |
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo/PaymentInterface.h:
--------------------------------------------------------------------------------
1 | //
2 | // Payment.h
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/19.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol PaymentInterface
12 |
13 | - (void)getPayment:(double)money;
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/19.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/19.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[10]. Proxy Pattern Demo/PPDemo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/19.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Decorators/BlueBerrySauceDecorator.h:
--------------------------------------------------------------------------------
1 | //
2 | // BlueBerrySauceDecorator.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "SauceDecorator.h"
10 |
11 | @interface BlueBerrySauceDecorator : SauceDecorator
12 |
13 | @end
14 |
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Decorators/PeanutButterSauceDecorator.h:
--------------------------------------------------------------------------------
1 | //
2 | // PeanutButterSauceDecorator.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "SauceDecorator.h"
10 |
11 | @interface PeanutButterSauceDecorator : SauceDecorator
12 |
13 | @end
14 |
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Decorators/SauceDecorator.h:
--------------------------------------------------------------------------------
1 | //
2 | // SauceDecorator.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Salad.h"
10 |
11 | @interface SauceDecorator : Salad
12 |
13 | @property (nonatomic, strong) Salad *salad;
14 |
15 | - (instancetype)initWithSalad:(Salad *)salad;
16 |
17 | @end
18 |
19 |
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Decorators/VinegarSauceDecorator.h:
--------------------------------------------------------------------------------
1 | //
2 | // VinegarSauceDecorator.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "SauceDecorator.h"
10 |
11 |
12 |
13 | @interface VinegarSauceDecorator : SauceDecorator
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Salad/BeefSalad.h:
--------------------------------------------------------------------------------
1 | //
2 | // BeefSalad.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Salad.h"
10 |
11 | @interface BeefSalad : Salad
12 |
13 | @end
14 |
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Salad/BeefSalad.m:
--------------------------------------------------------------------------------
1 | //
2 | // BeefSalad.m
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "BeefSalad.h"
10 |
11 | @implementation BeefSalad
12 |
13 |
14 | - (NSString *)getDescription{
15 | return @"[Beef Salad]";
16 | }
17 |
18 | - (double)price{
19 | return 16.0;
20 | }
21 |
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Salad/ChickenSalad.h:
--------------------------------------------------------------------------------
1 | //
2 | // ChickenSalad.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Salad.h"
10 |
11 |
12 |
13 | @interface ChickenSalad : Salad
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Salad/ChickenSalad.m:
--------------------------------------------------------------------------------
1 | //
2 | // ChickenSalad.m
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "ChickenSalad.h"
10 |
11 | @implementation ChickenSalad
12 |
13 | - (NSString *)getDescription{
14 | return @"[Chicken Salad]";
15 | }
16 |
17 | - (double)price{
18 | return 10.0;
19 | }
20 |
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Salad/Salad.h:
--------------------------------------------------------------------------------
1 | //
2 | // Salad.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Salad : NSObject
12 |
13 | - (NSString *)getDescription;
14 |
15 | - (double)price;
16 |
17 | @end
18 |
19 |
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Salad/VegetableSalad.h:
--------------------------------------------------------------------------------
1 | //
2 | // VegetableSalad.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Salad.h"
10 |
11 |
12 |
13 | @interface VegetableSalad : Salad
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/Salad/VegetableSalad.m:
--------------------------------------------------------------------------------
1 | //
2 | // VegetableSalad.m
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "VegetableSalad.h"
10 |
11 | @implementation VegetableSalad
12 |
13 |
14 | - (NSString *)getDescription{
15 | return @"[Vegetable Salad]";
16 | }
17 |
18 | - (double)price{
19 | return 5.0;
20 | }
21 |
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[11]. Decorator Pattern Demo/DPDemo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // DPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | FWPD.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/FlowerImageView.h:
--------------------------------------------------------------------------------
1 | //
2 | // Flower.h
3 | // Flyweight
4 | //
5 | // Created by Carlo Chung on 11/29/10.
6 | // Copyright 2010 Carlo Chung. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface FlowerImageView : UIImageView
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/FlowerImageView.m:
--------------------------------------------------------------------------------
1 | //
2 | // Flower.m
3 | // Flyweight
4 | //
5 | // Created by Carlo Chung on 11/29/10.
6 | // Copyright 2010 Carlo Chung. All rights reserved.
7 | //
8 |
9 | #import "FlowerImageView.h"
10 |
11 |
12 | @implementation FlowerImageView
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // FWPD
4 | //
5 | // Created by Sun Shijie on 2018/11/18.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // FWPD
4 | //
5 | // Created by Sun Shijie on 2018/11/18.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/anemone.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "anemone.png",
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 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/anemone.imageset/anemone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/anemone.imageset/anemone.png
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/cosmos.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "cosmos.png",
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 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/cosmos.imageset/cosmos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/cosmos.imageset/cosmos.png
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/gerberas.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "gerberas.png",
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 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/gerberas.imageset/gerberas.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/gerberas.imageset/gerberas.png
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/hollyhock.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "hollyhock.png",
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 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/hollyhock.imageset/hollyhock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/hollyhock.imageset/hollyhock.png
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/jasmine.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "jasmine.png",
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 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/jasmine.imageset/jasmine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/jasmine.imageset/jasmine.png
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/zinnia.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "zinnia.png",
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 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/zinnia.imageset/zinnia.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/Assets.xcassets/zinnia.imageset/zinnia.png
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[12]. Flyweight Pattern Demo/FWPD/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // FWPD
4 | //
5 | // Created by Sun Shijie on 2018/11/18.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Algorithm/HotDrink.h:
--------------------------------------------------------------------------------
1 | //
2 | // HotDrink.h
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface HotDrink : NSObject
14 |
15 | - (void)makingProcess;
16 |
17 | - (void)addMainMaterial;
18 |
19 | - (void)addIngredients;
20 |
21 | @end
22 |
23 | NS_ASSUME_NONNULL_END
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Client/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Concrete Algorithm/HotDrinkAmericano.h:
--------------------------------------------------------------------------------
1 | //
2 | // HotDrinkAmericano.h
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HotDrink.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface HotDrinkAmericano : HotDrink
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Concrete Algorithm/HotDrinkLatte.h:
--------------------------------------------------------------------------------
1 | //
2 | // HotDrinkLatte.h
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HotDrink.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface HotDrinkLatte : HotDrink
14 |
15 |
16 | @end
17 |
18 | NS_ASSUME_NONNULL_END
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Concrete Algorithm/HotDrinkLatte.m:
--------------------------------------------------------------------------------
1 | //
2 | // HotDrinkLatte.m
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HotDrinkLatte.h"
10 |
11 | @implementation HotDrinkLatte
12 |
13 | - (void)addMainMaterial{
14 |
15 | NSLog(@"add ground coffee");
16 | }
17 |
18 |
19 | - (void)addIngredients{
20 |
21 | NSLog(@"add milk");
22 | }
23 |
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Concrete Algorithm/HotDrinkTea.h:
--------------------------------------------------------------------------------
1 | //
2 | // HotDrinkTea.h
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "HotDrink.h"
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | @interface HotDrinkTea : HotDrink
16 |
17 | @end
18 |
19 | NS_ASSUME_NONNULL_END
20 |
21 |
22 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Concrete Algorithm/HotDrinkTea.m:
--------------------------------------------------------------------------------
1 | //
2 | // HotDrinkTea.m
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HotDrinkTea.h"
10 |
11 | @implementation HotDrinkTea
12 |
13 |
14 | - (void)addMainMaterial{
15 |
16 | NSLog(@"add tea leaf");
17 | }
18 |
19 |
20 | - (void)addIngredients{
21 |
22 | NSLog(@"add nothing");
23 | }
24 |
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/Other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[13]. Template Pattern Demo/TPDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // TPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/11.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Client/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Strategy/Abstract Strategy/TwoIntOperation.h:
--------------------------------------------------------------------------------
1 | //
2 | // TwoIntOperation.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface TwoIntOperation : NSObject
12 |
13 | - (int)operationOfInt1:(int)int1 int2:(int)int2;
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Strategy/Abstract Strategy/TwoIntOperation.m:
--------------------------------------------------------------------------------
1 | //
2 | // TwoIntOperation.m
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "TwoIntOperation.h"
10 |
11 | @implementation TwoIntOperation
12 |
13 | - (int)operationOfInt1:(int)int1 int2:(int)int2{
14 |
15 | //implenting by sub classes;
16 | return 0;
17 | }
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Strategy/Contrete Strategy/TwoIntOperationAdd.h:
--------------------------------------------------------------------------------
1 | //
2 | // TwoIntOperatiionAdd.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "TwoIntOperation.h"
12 |
13 | @interface TwoIntOperationAdd : TwoIntOperation
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Strategy/Contrete Strategy/TwoIntOperationAdd.m:
--------------------------------------------------------------------------------
1 | //
2 | // TwoIntOperatiionAdd.m
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "TwoIntOperationAdd.h"
10 |
11 | @implementation TwoIntOperationAdd
12 |
13 | - (int)operationOfInt1:(int)int1 int2:(int)int2{
14 |
15 | NSLog(@"==== adding ====");
16 |
17 | return int1 + int2;
18 | }
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Strategy/Contrete Strategy/TwoIntOperationDivision.h:
--------------------------------------------------------------------------------
1 | //
2 | // TwoOperationStrategyDivision.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "TwoIntOperation.h"
12 |
13 | @interface TwoIntOperationDivision : TwoIntOperation
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Strategy/Contrete Strategy/TwoIntOperationMultiply.h:
--------------------------------------------------------------------------------
1 | //
2 | // TwoIntOperationMultiply.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "TwoIntOperation.h"
12 |
13 | @interface TwoIntOperationMultiply : TwoIntOperation
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[14]. Strategy Pattern Demo/SPDemo/Strategy/Contrete Strategy/TwoIntOperationSubstract.h:
--------------------------------------------------------------------------------
1 | //
2 | // TwoOperationStrategyMinus.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2019/2/28.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "TwoIntOperation.h"
12 |
13 | @interface TwoIntOperationSubstract : TwoIntOperation
14 |
15 |
16 | @end
17 |
18 |
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/ATMDispenseChain.h:
--------------------------------------------------------------------------------
1 | //
2 | // ATMDispenseChain.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "DispenseProtocol.h"
12 |
13 | @interface ATMDispenseChain : NSObject
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/Currency.h:
--------------------------------------------------------------------------------
1 | //
2 | // Currency.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface Currency : NSObject
14 |
15 | - (instancetype)initWithAmount:(int)amount;
16 |
17 | - (int)getAmount;
18 |
19 | @end
20 |
21 | NS_ASSUME_NONNULL_END
22 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/DispenseChainNodeFor10Yuan.h:
--------------------------------------------------------------------------------
1 | //
2 | // DispenseChainFor10Dollar.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "DispenseChainNode.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface DispenseChainNodeFor10Yuan : DispenseChainNode
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/DispenseChainNodeFor20Yuan.h:
--------------------------------------------------------------------------------
1 | //
2 | // DispenseChainFor5Dollar.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "DispenseChainNode.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface DispenseChainNodeFor20Yuan : DispenseChainNode
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/DispenseChainNodeFor50Yuan.h:
--------------------------------------------------------------------------------
1 | //
2 | // DispenseChainFor50Dollar.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "DispenseChainNode.h"
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | @interface DispenseChainNodeFor50Yuan : DispenseChainNode
16 |
17 |
18 | @end
19 |
20 | NS_ASSUME_NONNULL_END
21 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/DispenseProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // DispenseProtocol.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @protocol DispenseProtocol
14 |
15 | - (void)dispense:(int)amount;
16 |
17 | @end
18 |
19 | NS_ASSUME_NONNULL_END
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[15]. Chain of Responsibilty Pattern Demo (before refactoring)/CRPDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2/ATMDispenseChain.h:
--------------------------------------------------------------------------------
1 | //
2 | // ATMDispenseChain.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "DispenseProtocol.h"
12 |
13 | @interface ATMDispenseChain : NSObject
14 |
15 | - (instancetype)initWithDispenseNodeValues:(NSArray *)nodeValues;
16 |
17 | @end
18 |
19 |
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2/DispenseProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // DispenseProtocol.h
3 | // CRPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @protocol DispenseProtocol
14 |
15 | - (void)dispense:(int)amount;
16 |
17 | @end
18 |
19 | NS_ASSUME_NONNULL_END
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2/Other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CRPDemo2
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2/Other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2/Other/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CRPDemo2
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[16]. Chain of Responsibilty Pattern Demo (after refactoring)/CRPDemo2/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CRPDemo2
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/ActionProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // StateProtocol.h
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol ActionProtocol
12 |
13 | @optional;
14 |
15 | - (void)wakeUp;
16 |
17 | - (void)fallAsleep;
18 |
19 | - (void)startCoding;
20 |
21 | - (void)startEating;
22 |
23 |
24 | @end
25 |
26 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/State.h:
--------------------------------------------------------------------------------
1 | //
2 | // State.h
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "ActionProtocol.h"
12 | #import "Coder.h"
13 |
14 |
15 | @interface State : NSObject
16 | {
17 | @protected Coder *_coder;
18 | }
19 |
20 | - (instancetype)initWithCoder:(Coder *)coder;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/State.m:
--------------------------------------------------------------------------------
1 | //
2 | // State.m
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "State.h"
10 |
11 |
12 | @implementation State
13 |
14 | - (instancetype)initWithCoder:(Coder *)coder{
15 |
16 | self = [super init];
17 | if (self) {
18 | _coder = coder;
19 | }
20 | return self;
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/StateAwake.h:
--------------------------------------------------------------------------------
1 | //
2 | // StateAwake.h
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "State.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface StateAwake : State
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/StateCoding.h:
--------------------------------------------------------------------------------
1 | //
2 | // StateCoding.h
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "State.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface StateCoding : State
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/StateEating.h:
--------------------------------------------------------------------------------
1 | //
2 | // StateEating.h
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "State.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface StateEating : State
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/StateSleeping.h:
--------------------------------------------------------------------------------
1 | //
2 | // StateSleeping.h
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "State.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface StateSleeping : State
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[17]. State Pattern Demo/STPDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // STPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/3.
6 | // Copyright © 2019 Sunshijie. 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 | }
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Command/Command.h:
--------------------------------------------------------------------------------
1 | //
2 | // Command.h
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Command : NSObject
12 |
13 | - (void)excute;
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Command/Command.m:
--------------------------------------------------------------------------------
1 | //
2 | // Command.m
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Command.h"
10 |
11 | @implementation Command
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Command/CommandLightOff.h:
--------------------------------------------------------------------------------
1 | //
2 | // CommandLightOff.h
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Command.h"
10 |
11 | @class Light;
12 | NS_ASSUME_NONNULL_BEGIN
13 |
14 | @interface CommandLightOff : Command
15 |
16 | - (instancetype)initWithLight:(Light *)light;
17 |
18 | @end
19 |
20 | NS_ASSUME_NONNULL_END
21 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Command/CommandLightOn.h:
--------------------------------------------------------------------------------
1 | //
2 | // ConmmandLightOn.h
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Command.h"
10 | @class Light;
11 |
12 |
13 | @interface CommandLightOn : Command
14 |
15 | - (instancetype)initWithLight:(Light *)light;
16 |
17 | @end
18 |
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Invoker/RemoteControl.h:
--------------------------------------------------------------------------------
1 | //
2 | // RemoteControl.h
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class Command;
12 |
13 |
14 | @interface RemoteControl : NSObject
15 |
16 | - (void)setCommand:(Command *)command;
17 |
18 | - (void)pressButton;
19 |
20 |
21 | @end
22 |
23 |
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Other/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Receiver/Light.h:
--------------------------------------------------------------------------------
1 | //
2 | // Light.h
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface Light : NSObject
14 |
15 |
16 | - (void)lightOn;
17 |
18 | - (void)lightOff;
19 |
20 | @end
21 |
22 | NS_ASSUME_NONNULL_END
23 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[18]. Command Pattern Demo/CPDemo/Receiver/Light.m:
--------------------------------------------------------------------------------
1 | //
2 | // Light.m
3 | // CPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Light.h"
10 |
11 | @implementation Light
12 |
13 |
14 | - (void)lightOn{
15 |
16 | NSLog(@"Light on");
17 | }
18 |
19 |
20 | - (void)lightOff{
21 |
22 | NSLog(@"Light off");
23 | }
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo/Observer/Investor.h:
--------------------------------------------------------------------------------
1 | //
2 | // Investor.h
3 | // OPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/1.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "Observer.h"
12 |
13 | @interface Investor : Observer
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo/Observer/Investor.m:
--------------------------------------------------------------------------------
1 | //
2 | // Investor.m
3 | // OPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/1.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Investor.h"
10 |
11 | @implementation Investor
12 |
13 | - (void)update{
14 |
15 | float buyingPrice = [_subject getBuyingPrice];
16 | NSLog(@"investor %p buy stock of price:%.2lf",self,buyingPrice);
17 | }
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo/Other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // OPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/1.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo/Other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo/Other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // OPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/1.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo/Subject/FinancialAdviser.h:
--------------------------------------------------------------------------------
1 | //
2 | // FinancialAdviser.h
3 | // OPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/1.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "Subject.h"
12 |
13 | @interface FinancialAdviser : Subject
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo/Subject/FinancialAdviser.m:
--------------------------------------------------------------------------------
1 | //
2 | // FinancialAdviser.m
3 | // OPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/1.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "FinancialAdviser.h"
10 |
11 | @implementation FinancialAdviser
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[19]. Observer Pattern Demo/OPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // OPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/1.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | SFPDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Client/Store.h:
--------------------------------------------------------------------------------
1 | //
2 | // Store.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Phone.h"
11 |
12 | @interface Store : NSObject
13 |
14 | - (void)sellPhone:(Phone *)phone;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Client/Store.m:
--------------------------------------------------------------------------------
1 | //
2 | // Store.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Store.h"
10 |
11 | @implementation Store
12 |
13 | - (void)sellPhone:(Phone *)phone{
14 | NSLog(@"Store begins to sell phone:%@",[phone class]);
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Factory/PhoneFactory.h:
--------------------------------------------------------------------------------
1 | //
2 | // PhoneFactory.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Phone.h"
11 |
12 | @interface PhoneFactory : NSObject
13 |
14 | + (Phone *)createPhoneWithTag:(NSString *)tag;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Product/HWPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // HWPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface HWPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Product/HWPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // HWPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HWPhone.h"
10 |
11 | @implementation HWPhone
12 |
13 | - (void)packaging{
14 | NSLog(@"HUAWEI Phone has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Product/IPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // IPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface IPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Product/IPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // IPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "IPhone.h"
10 |
11 | @implementation IPhone
12 |
13 | - (void)packaging{
14 | NSLog(@"IPhone has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Product/MIPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // MiPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface MIPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Product/MIPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // MiPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "MIPhone.h"
10 |
11 | @implementation MIPhone
12 |
13 | - (void)packaging{
14 | NSLog(@"MIPhone has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Product/Phone.h:
--------------------------------------------------------------------------------
1 | //
2 | // Phone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Phone : NSObject
12 |
13 | //package to store
14 | - (void)packaging;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/Product/Phone.m:
--------------------------------------------------------------------------------
1 | //
2 | // Phone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @implementation Phone
12 |
13 | - (void)packaging{
14 | //implemented by subclass
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[1]. Simple Factory Pattern Demo/SFPDemo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[20].Mediator Pattern Demo/MPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[20].Mediator Pattern Demo/MPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[20].Mediator Pattern Demo/MPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[20].Mediator Pattern Demo/MPDemo/ChatMediator.h:
--------------------------------------------------------------------------------
1 | //
2 | // ChatMediator.h
3 | // MPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class User;
12 |
13 | @interface ChatMediator : NSObject
14 |
15 |
16 | - (void)addUser:(User *)user;
17 |
18 | - (void)sendMessage:(NSString *)message fromUser:(User *)user;
19 |
20 | @end
21 |
22 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[20].Mediator Pattern Demo/MPDemo/Other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // MPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[20].Mediator Pattern Demo/MPDemo/Other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[20].Mediator Pattern Demo/MPDemo/Other/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // MPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[20].Mediator Pattern Demo/MPDemo/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // MPDemo
4 | //
5 | // Created by Sun Shijie on 2019/3/2.
6 | // Copyright © 2019 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Client/Store.h:
--------------------------------------------------------------------------------
1 | //
2 | // Store.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Phone.h"
11 |
12 | @interface Store : NSObject
13 |
14 | - (void)sellPhone:(Phone *)phone;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Client/Store.m:
--------------------------------------------------------------------------------
1 | //
2 | // Store.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Store.h"
10 |
11 | @implementation Store
12 |
13 | - (void)sellPhone:(Phone *)phone{
14 | NSLog(@"Store begins to sell phone:%@",[phone class]);
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Factory/HWPhoneFactory.h:
--------------------------------------------------------------------------------
1 | //
2 | // HWPhoneFactory.h
3 | // FMPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "PhoneFactory.h"
10 |
11 | @interface HWPhoneFactory : PhoneFactory
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Factory/IPhoneFactory.h:
--------------------------------------------------------------------------------
1 | //
2 | // IPhoneFactory.h
3 | // FMPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "PhoneFactory.h"
10 |
11 | @interface IPhoneFactory : PhoneFactory
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Factory/MIPhoneFactory.h:
--------------------------------------------------------------------------------
1 | //
2 | // MIPhoneFactory.h
3 | // FMPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/17.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "PhoneFactory.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface MIPhoneFactory : PhoneFactory
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Factory/PhoneFactory.h:
--------------------------------------------------------------------------------
1 | //
2 | // PhoneFactory.h
3 | // FMPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Phone.h"
11 |
12 | @interface PhoneFactory : NSObject
13 |
14 | + (Phone *)createPhone;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Factory/PhoneFactory.m:
--------------------------------------------------------------------------------
1 | //
2 | // PhoneFactory.m
3 | // FMPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "PhoneFactory.h"
10 |
11 | @implementation PhoneFactory
12 |
13 | + (Phone *)createPhone{
14 | //implemented by subclass
15 | return nil;
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Product/HWPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // HWPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface HWPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Product/HWPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // HWPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HWPhone.h"
10 |
11 | @implementation HWPhone
12 |
13 | - (void)packaging{
14 |
15 | NSLog(@"HUAWEI Phone has been packaged");
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Product/IPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // IPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface IPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Product/IPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // IPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "IPhone.h"
10 |
11 | @implementation IPhone
12 |
13 | - (void)packaging{
14 |
15 | NSLog(@"IPhone has been packaged");
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Product/MIPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // MiPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface MIPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Product/MIPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // MiPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "MIPhone.h"
10 |
11 | @implementation MIPhone
12 |
13 | - (void)packaging{
14 |
15 | NSLog(@"MIPhone has been packaged");
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Product/Phone.h:
--------------------------------------------------------------------------------
1 | //
2 | // Phone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Phone : NSObject
12 |
13 | //package to store
14 | - (void)packaging;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/Product/Phone.m:
--------------------------------------------------------------------------------
1 | //
2 | // Phone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @implementation Phone
12 |
13 | - (void)packaging{
14 | //implemented by subclass
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // FMPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // FMPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[2]. Factory Method Pattern Demo/FMPDemo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // FMPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Client/Store.h:
--------------------------------------------------------------------------------
1 | //
2 | // Store.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Phone.h"
11 | #import "Computer.h"
12 |
13 | @interface Store : NSObject
14 |
15 | - (void)sellPhone:(Phone *)phone;
16 |
17 | - (void)sellComputer:(Computer *)computer;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Factory/AppleFactory.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppleFactory.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Factory.h"
10 |
11 | @interface AppleFactory : Factory
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Factory/Factory.h:
--------------------------------------------------------------------------------
1 | //
2 | // Factory.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Phone.h"
11 | #import "Computer.h"
12 |
13 | @interface Factory : NSObject
14 |
15 | + (Phone *)createPhone;
16 |
17 | + (Computer *)createComputer;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Factory/HWFactory.h:
--------------------------------------------------------------------------------
1 | //
2 | // HWFactory.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Factory.h"
10 |
11 | @interface HWFactory : Factory
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Factory/MIFactory.h:
--------------------------------------------------------------------------------
1 | //
2 | // MiFactory.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Factory.h"
10 |
11 | @interface MIFactory : Factory
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Computer/Computer.h:
--------------------------------------------------------------------------------
1 | //
2 | // Computer.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Computer : NSObject
12 |
13 | //package to store
14 | - (void)packaging;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Computer/Computer.m:
--------------------------------------------------------------------------------
1 | //
2 | // Computer.m
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Computer.h"
10 |
11 | @implementation Computer
12 |
13 | - (void)packaging{
14 | //implemented by subclass
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Computer/MIComputer.h:
--------------------------------------------------------------------------------
1 | //
2 | // MiComputer.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Computer.h"
10 |
11 | @interface MIComputer : Computer
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Computer/MIComputer.m:
--------------------------------------------------------------------------------
1 | //
2 | // MiComputer.m
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "MIComputer.h"
10 |
11 | @implementation MIComputer
12 |
13 | - (void)packaging{
14 | NSLog(@"MIComputer has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Computer/MacBookComputer.h:
--------------------------------------------------------------------------------
1 | //
2 | // MacBookComputer.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Computer.h"
10 |
11 | @interface MacBookComputer : Computer
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Computer/MacBookComputer.m:
--------------------------------------------------------------------------------
1 | //
2 | // MacBookComputer.m
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "MacBookComputer.h"
10 |
11 | @implementation MacBookComputer
12 |
13 | - (void)packaging{
14 | NSLog(@"MacBookComputer has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Computer/MateBookComputer.h:
--------------------------------------------------------------------------------
1 | //
2 | // HWComputer.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Computer.h"
10 |
11 | @interface MateBookComputer : Computer
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Computer/MateBookComputer.m:
--------------------------------------------------------------------------------
1 | //
2 | // HWComputer.m
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "MateBookComputer.h"
10 |
11 | @implementation MateBookComputer
12 |
13 | - (void)packaging{
14 | NSLog(@"MateBookComputer has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Phone/HWPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // HWPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface HWPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Phone/HWPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // HWPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HWPhone.h"
10 |
11 | @implementation HWPhone
12 |
13 | - (void)packaging{
14 | NSLog(@"HUAWEI Phone has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Phone/IPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // IPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface IPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Phone/IPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // IPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "IPhone.h"
10 |
11 | @implementation IPhone
12 |
13 | - (void)packaging{
14 | NSLog(@"IPhone has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Phone/MIPhone.h:
--------------------------------------------------------------------------------
1 | //
2 | // MiPhone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @interface MIPhone : Phone
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Phone/MIPhone.m:
--------------------------------------------------------------------------------
1 | //
2 | // MiPhone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "MIPhone.h"
10 |
11 | @implementation MIPhone
12 |
13 | - (void)packaging{
14 | NSLog(@"Mi Phone has been packaged");
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Phone/Phone.h:
--------------------------------------------------------------------------------
1 | //
2 | // Phone.h
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Phone : NSObject
12 |
13 | //package to store
14 | - (void)packaging;
15 |
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/Product - Phone/Phone.m:
--------------------------------------------------------------------------------
1 | //
2 | // Phone.m
3 | // SFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @implementation Phone
12 |
13 | - (void)packaging{
14 | //implemented by subclass
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[3]. Abstract Factory Pattern Demo/AFPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // AFPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/3.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/SPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/SPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/SPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/SPDemo.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | SPDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/SPDemo/LogManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // LogManager.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/6.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface LogManager : NSObject
12 |
13 | +(instancetype)sharedInstance;
14 |
15 | - (void)printLog:(NSString *)logMessage;
16 |
17 | - (void)uploadLog:(NSString *)logMessage;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/SPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/6.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/6.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[4]. Singleton Pattern Demo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/6.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo/Builder/IPhoneXRBuilder.h:
--------------------------------------------------------------------------------
1 | //
2 | // PhoneHighClassBuilder.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/5.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Builder.h"
10 |
11 | @interface IPhoneXRBuilder : Builder
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo/Builder/MI8Builder.h:
--------------------------------------------------------------------------------
1 | //
2 | // MI8Builder.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/5.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Builder.h"
10 |
11 | @interface MI8Builder : Builder
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo/Director/Director.h:
--------------------------------------------------------------------------------
1 | //
2 | // Director.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/5.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Builder.h"
11 |
12 | @interface Director : NSObject
13 |
14 | - (void)constructPhoneWithBuilder:(Builder *)builder;
15 |
16 | - (Phone *)obtainPhone;
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo/Other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/5.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo/Other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo/Other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/5.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo/Product/Phone.m:
--------------------------------------------------------------------------------
1 | //
2 | // Phone.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/5.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Phone.h"
10 |
11 | @implementation Phone
12 |
13 | - (NSString *)description{
14 |
15 | return [NSString stringWithFormat:@" CPU: %@ | Capacity: %@ | Display: %@ | Camera: %@",_cpu,_capacity,_display,_camera];
16 | }
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[5]. Builder Pattern Demo/BPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/5.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo.xcodeproj/xcuserdata/sunshijie.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | PPDemo.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo/CollageInfo.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollageInfo.h
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/9.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface CollageInfo : NSObject
12 |
13 | @property (nonatomic, copy) NSString *startYear;
14 | @property (nonatomic, copy) NSString *endYear;
15 | @property (nonatomic, copy) NSString *major;
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo/CollageInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // CollageInfo.m
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/9.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "CollageInfo.h"
10 |
11 | @implementation CollageInfo
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/9.
6 | // Copyright © 2018年 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/9.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[6]. Prototype Pattern Demo/PPDemo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // PPDemo
4 | //
5 | // Created by Sun Shijie on 2018/10/9.
6 | // Copyright © 2018年 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/AirConditioner.h:
--------------------------------------------------------------------------------
1 | //
2 | // AirConditioner.h
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HomeDevice.h"
10 |
11 |
12 |
13 | @interface AirConditioner : HomeDevice
14 |
15 | //高温模式
16 | - (void)startHighTemperatureMode;
17 |
18 | //常温模式
19 | - (void)startMiddleTemperatureMode;
20 |
21 | //低温模式
22 | - (void)startLowTemperatureMode;
23 |
24 | @end
25 |
26 |
27 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/CDPlayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // CDPlayer.h
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HomeDevice.h"
10 |
11 | @interface CDPlayer : HomeDevice
12 |
13 | - (void)playMusic;
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/CDPlayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // CDPlayer.m
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "CDPlayer.h"
10 |
11 | @implementation CDPlayer
12 |
13 | - (void)play{
14 | NSLog(@"CDPlayer begins to play");
15 | }
16 | @end
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/DVDPlayer.h:
--------------------------------------------------------------------------------
1 | //
2 | // DVDPlayer.h
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HomeDevice.h"
10 |
11 | @interface DVDPlayer : HomeDevice
12 |
13 | - (void)playMovie;
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/DVDPlayer.m:
--------------------------------------------------------------------------------
1 | //
2 | // DVDPlayer.m
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "DVDPlayer.h"
10 |
11 | @implementation DVDPlayer
12 |
13 | - (void)play{
14 |
15 | NSLog(@"DVDPlayer begins to play");
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/HomeDevice.h:
--------------------------------------------------------------------------------
1 | //
2 | // HomeDevice.h
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //设备基类
12 |
13 | @interface HomeDevice : NSObject
14 |
15 | //连接电源
16 | - (void)on;
17 |
18 | //关闭电源
19 | - (void)off;
20 |
21 | @end
22 |
23 |
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/HomeDevice.m:
--------------------------------------------------------------------------------
1 | //
2 | // HomeDevice.m
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HomeDevice.h"
10 |
11 | @implementation HomeDevice
12 |
13 | //连接电源
14 | - (void)on{
15 | NSLog(@"%@ is on",[self class]);
16 | }
17 |
18 | //关闭电源
19 | - (void)off{
20 | NSLog(@"%@ is off",[self class]);
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/Projecter.h:
--------------------------------------------------------------------------------
1 | //
2 | // Projecter.h
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "HomeDevice.h"
10 |
11 | @class DVDPlayer;
12 |
13 | //投影仪类
14 |
15 | @interface Projecter : HomeDevice
16 |
17 | - (void)connetDVDPlayer:(DVDPlayer *)dvdPlayer;
18 |
19 | - (void)disconnetDVDPlayer:(DVDPlayer *)dvdPlayer;
20 |
21 | @end
22 |
23 |
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[7]. Facade Pattern Demo/FPDemo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // FPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/3.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/Adaptor/Adaptor.h:
--------------------------------------------------------------------------------
1 | //
2 | // Adaptor.h
3 | // APDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "OldCacheProtocol.h"
11 |
12 | @class NewCache;
13 |
14 | @interface Adaptor : NSObject
15 |
16 | - (instancetype)initWithNewCache:(NewCache *)newCache;
17 |
18 | @end
19 |
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/NewCache/NewCache.h:
--------------------------------------------------------------------------------
1 | //
2 | // NewCache.h
3 | // APDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #import "NewCacheProtocol.h"
12 |
13 | @interface NewCache : NSObject
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/NewCache/NewCacheProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // NewCacheProtocol.h
3 | // APDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol NewCacheProtocol
12 |
13 | - (void)new_saveCacheObject:(id)obj forKey:(NSString *)key;
14 |
15 | - (id)new_getCacheObjectForKey:(NSString *)key;
16 |
17 | @end
18 |
19 |
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/OldCache/OldCache.h:
--------------------------------------------------------------------------------
1 | //
2 | // OldCache.h
3 | // APDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "OldCacheProtocol.h"
11 |
12 |
13 | @interface OldCache : NSObject
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/OldCache/OldCacheProtocol.h:
--------------------------------------------------------------------------------
1 | //
2 | // OldCacheProtocol.h
3 | // APDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @protocol OldCacheProtocol
12 |
13 | - (void)old_saveCacheObject:(id)obj forKey:(NSString *)key;
14 |
15 | - (id)old_getCacheObjectForKey:(NSString *)key;
16 |
17 | @end
18 |
19 |
20 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // APDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // APDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[8]. Adaptor Pattern Demo/APDemo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // APDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/4.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo.xcodeproj/project.xcworkspace/xcuserdata/sunshijie.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Color/BlueColor.h:
--------------------------------------------------------------------------------
1 | //
2 | // BlueColor.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Color.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface BlueColor : Color
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Color/BlueColor.m:
--------------------------------------------------------------------------------
1 | //
2 | // BlueColor.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "BlueColor.h"
10 |
11 | @implementation BlueColor
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Color/Color.h:
--------------------------------------------------------------------------------
1 | //
2 | // Color.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Color : NSObject
12 |
13 | @end
14 |
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Color/Color.m:
--------------------------------------------------------------------------------
1 | //
2 | // Color.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Color.h"
10 |
11 | @implementation Color
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Color/GreenColor.h:
--------------------------------------------------------------------------------
1 | //
2 | // GreenColor.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Color.h"
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface GreenColor : Color
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Color/GreenColor.m:
--------------------------------------------------------------------------------
1 | //
2 | // GreenColor.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "GreenColor.h"
10 |
11 | @implementation GreenColor
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Color/RedColor.h:
--------------------------------------------------------------------------------
1 | //
2 | // RedColor.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Color.h"
10 |
11 |
12 | @interface RedColor : Color
13 |
14 | @end
15 |
16 |
17 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Color/RedColor.m:
--------------------------------------------------------------------------------
1 | //
2 | // RedColor.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "RedColor.h"
10 |
11 | @implementation RedColor
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Shape/Circle.h:
--------------------------------------------------------------------------------
1 | //
2 | // Circle.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Shape.h"
10 |
11 |
12 |
13 | @interface Circle : Shape
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Shape/Circle.m:
--------------------------------------------------------------------------------
1 | //
2 | // Circle.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Circle.h"
10 |
11 | @implementation Circle
12 |
13 | - (void)show{
14 |
15 | [super show];
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Shape/Rectangle.h:
--------------------------------------------------------------------------------
1 | //
2 | // Rectangle.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Shape.h"
10 |
11 | @interface Rectangle : Shape
12 |
13 | @end
14 |
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Shape/Rectangle.m:
--------------------------------------------------------------------------------
1 | //
2 | // Rectangle.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Rectangle.h"
10 |
11 | @implementation Rectangle
12 |
13 | - (void)show{
14 |
15 | [super show];
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Shape/Shape.h:
--------------------------------------------------------------------------------
1 | //
2 | // Shape.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Color.h"
11 |
12 | @interface Shape : NSObject
13 | {
14 | @protected Color *_color;
15 | }
16 |
17 | - (void)renderColor:(Color *)color;
18 |
19 | - (void)show;
20 |
21 | @end
22 |
23 |
24 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Shape/Shape.m:
--------------------------------------------------------------------------------
1 | //
2 | // Shape.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Shape.h"
10 |
11 | @implementation Shape
12 |
13 |
14 | - (void)renderColor:(Color *)color{
15 |
16 | _color = color;
17 | }
18 |
19 | - (void)show{
20 | NSLog(@"Show %@ with %@",[self class],[_color class]);
21 | }
22 | @end
23 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Shape/Square.h:
--------------------------------------------------------------------------------
1 | //
2 | // Square.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Shape.h"
10 |
11 |
12 |
13 | @interface Square : Shape
14 |
15 | @end
16 |
17 |
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/Shape/Square.m:
--------------------------------------------------------------------------------
1 | //
2 | // Square.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import "Square.h"
10 |
11 | @implementation Square
12 |
13 | - (void)show{
14 |
15 | [super show];
16 | }
17 | @end
18 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/other/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/other/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/[2]. Ojbect-Oriented design pattern Demo/[9]. Bridge Pattern Demo/BPDemo/other/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // BPDemo
4 | //
5 | // Created by Sun Shijie on 2018/11/20.
6 | // Copyright © 2018 Sunshijie. 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 |
--------------------------------------------------------------------------------
/res/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/knightsj/object-oriented-design/b37e514ceb6d56438bbc527cf821d1e112419d4c/res/banner.png
--------------------------------------------------------------------------------