Home iOS Enums, Classes and Buttons, Methods
Reply: 0

iOS Enums, Classes and Buttons, Methods

user1506
1#
user1506 Published in May 25, 2018, 11:10 am

So I have a few questions in general about tying things together. Lets say I have an enum filled with conditions as shown below.

enum Condition {

  case poor 
  case fair 
  case excellent
  case dan

}

I also have a class with stored properties

class Shoe {
  var color: Condition
  var laces: Condition

  init(color: Condition, laces: Condition) {
    self.color = color
    self.laces = laces
  }
}

My goal is to have users decide the condition of the object/variable inside of the class. Ideally I would like to accomplish this using MVC, setting the conditions up as buttons via UI. I'm learning online So I have a few questions.

  1. For the enum, is their anyway to connect buttons created in UI to the view controller in a way that the buttons represent the enum cases.
  2. For the class, although I'm not sure If its the best idea, Im thinking of creating a method that takes a dictionary of type [Object/Variable: Condition] and returns an interpolated string. "(object) is in (condition) Condition"
  3. I am also thinking I should create a second helper method to save the information and a for in loop to loop through the variables in the class ( there will be more variables than below).
  4. The final question I have is if its possible to have an label represent the stored properties in a class and how I should approach the label switching on variables in the class?
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.352243 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO