nsoojin / voicecontrolsample-ios Goto Github PK
View Code? Open in Web Editor NEWCreating a stateful UI with GameplayKit - Voice Control
License: GNU General Public License v3.0
Creating a stateful UI with GameplayKit - Voice Control
License: GNU General Public License v3.0
지난 세미나를 매우 흥미롭게 보아 코드를 보던 중, state: State
가 private set이 되는 것으로 보여 질문드립니다.
외부에서stateView
의 state
를 확인하기 위함으로 보이는데, stateMachine
에 있는 currentState
를 이용한
internal extension VoiceStateView {
enum State: RawRepresentable {
case attending, detecting, listening, processing, reporting
var rawValue: GKState.Type {
switch self {
case .attending:
return AttendingState.self
case .detecting:
return DetectingState.self
case .listening:
return ListeningState.self
case .processing:
return ProcessingState.self
case .reporting:
return ReportingState.self
}
}
init?(rawValue: GKState.Type) {
switch rawValue {
case is AttendingState.Type:
self = .attending
case is DetectingState.Type:
self = .detecting
case is ListeningState.Type:
self = .listening
case is ProcessingState.Type:
self = .processing
case is ReportingState.Type:
self = .reporting
default:
return nil
}
}
}
}
...
var state: State? {
guard let currentState = self.stateMachine.currentState else {
return nil
}
return State(rawValue: type(of: currentState))
}
이와 같은 로직은 어떻게 생각하시는지 혹은 private set에 대한 다른 의도가 있으셨나 질문드립니다.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.