I have the following types of variables within swift code and would like to take specific action based on a rules based table. For example:
Class Variables
joints.shoulder.left.y
joints.arm.wrist.left.y
Typical swift/pseudo code:
if (joints.arm.wrist.left.y > joints.shoulder.left.y){
print("warning")
self.elevated = true }
Problem: Instead of coding if/then statements, I'd like to maintain this logic in a table which contains the following columns
- Left expression (e.g. joints.arm.wrist.left.y)
- Condition (e.g. > )
- Right expression (e.g. joints.shoulder.left.y)
- Results (e.g. self.elevated = true)
I'd like to know what is the best way to be able to evaluate the expressions held in the table, but then to set the actual variable within the class to be self.elevated = true. Basically I need to figure out a way in Swift/iOS to not only to evaluate the expressions, but also to take the string "self.elevated" and to use that string literally as it refers to the variable within the class itself.
Thank you.
Aucun commentaire:
Enregistrer un commentaire