ios - Where do I declare a variable on app launch, that accesses ViewController properties? -


so have class of want create instance app launches. initialize of properties switches/toggles in viewcontroller.

here class, of trying create instance:

import foundation  class propertycollection {     var property1: bool      init (property1: bool) {         self.property1 = property1      }      func disableall() {         self.property1 = false      }      func enableall() {         self.property1 = true      }      func info() -> string {         return "the properties are: \(property1)"     }  } 

so: putting declaration in appdelegate.swift gives me error ("use of unresoved identifier 'property1switch'"):

func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool {          var thepropertycollection: propertycollection = propertycollection(property1: property1switch.ison)          return true     } 

adding "viewcontroller." in front of "property1switch" doesn't either. error ("instance member 'property1switch' cannot used on type 'viewcontroller'")

func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool {      var thepropertycollection: propertycollection = propertycollection(property1: viewcontroller.property1switch.ison)      return true } 

but not trying "use type 'property1switch' on type 'view controller'". thought how reference stuff other classes?

it should this:

see initializing object, must provide initial value.

func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool {          var thepropertycollection: propertycollection = propertycollection(property1: true)          return true } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -