ios - Transferring the same object between ViewControllers -


i have class, user, has nsmutablearray stores custom nsobjects. want 1 of these ever instantiated throughout entire app, , able call methods on in each viewcontroller getting , setting. problem don't know how call methods apply 1 instance, instead of creating new 1 each time. i'm new objective-c, learning curve makes me feel i'm missing bit obvious. i've been working on day , @ wit's end. there solution dilemma? should use singleton class?

(if helps, class user class stores to-do list each user uses app. custom nsobjects to-do items. there's better storage method should used here, i'm not sure is.)

randompleb sounds you're looking singleton. http://en.wikipedia.org/wiki/singleton_pattern. think question has been answered before search around on so.

laymen's terms; create static reference class want 1 of inside class, make static method in following way:

//call classes want modify  public static getsharedinstance() {     if(the static instance of class not exist){         instantiate instance;     }  return classes static instance.. } 

hope helps (and if wrong, hope can correct me)

also in regards storing objects, think nsmutablearray fine unless big persistent list each task has many properties in case maybe using coredata better.

fenix


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -