ios - Singleton Swift Shared [String] -


i trying access same [string] in 2 viewcontrollers. first 1 setting array , second viewcontroller want array.

here singleton class.

class savedpostsbox{ var postnames: [string] = []  class var sharedinstance : savedpostsbox {     struct static {         static let instance : savedpostsbox = savedpostsbox()     }     return static.instance }   } 

in first viewcontroller this:

savedpostsbox().postnames = savedpostname 

and in second this:

savedpostname = savedpostsbox().postnames 

the problem when check sizes in different classes 0 in second not in first. tried lot of different methods , search everywhere solutions seems work lot of other people not me.

you have sharedinstance.

savedpostsbox.sharedinstance.postnames = savedpostname 

ans use everywhere, instead of instances of savedpostsbox


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -