iphone - Global Variable problem -


i new in iphone.i use flag variable play songs in avaudio player songs handeled flag variable.we have 2 tabs in tab bar , want if song playing on other tab song info show.if use flag variable syncronize song info song.but can't access value of flag on song info tab.i import global file in song info file.

please me 1 through define global integer var can access in project.

global variables evil. complexity of app grows cause problems impossible track down.

there few ways handle this.

  1. create bool property in app delegate , reference property referencing app delegate. common way implement type of functionality.
  2. create custom singleton object hold variables. access variable calling singleton. use 1 large complex data.
  3. save value in user defaults calling +[nsuserdefaults standarduserdefaults]

in case think (3) best because you're trying save application state instead of user data. application state information belongs in user defaults. particularly handy when want restart app previous state e.g. open views , data open when last quit.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -