copy and pointers


hello,
have array created through dataaccess , parsing when app starts run. array available in appdelegate. each viewcontroller needs access data saved in array calling using:
code:
thelist = [(appdelegate*)[[uiapplication sharedapplication] delegate] thelist];
the object thelist confusion starts. have tried different approaches here in order both proper memory management , let object live long needed in app.

instance, if have 3 table views , user may navigate between them using navigationcontroller. tables filled data described above. thelist defined follows:

.h file
nsarray *thelist;
code:
@property(nonatomic, copy) nsarray *thelist;
.m file
code:
//in viewdidload  thelist = [(appdelegate*)[[uiapplication sharedapplication] delegate]thelist];  mutablelist = [[nsmutablearray alloc]init];  for(object *o in thelist){  [mutablelist addobject:o];  }
some things not understand here:
if release thelist after code above, app crashing. defined property copy thought have release when not want use anymore? thelist pointer nsarray object - ie object not change long app lives. defined copy, wrote above, because after analyzing memory use, seemed effective solution. might wrong...?

anyway, after copying objects thelist local mutable array, thought correct kill thelist...? why wrong? problem noticed when navigating between different tableviews. app crashed when revisited table, , problem not appear solution above. question - right way go? effective? robust? more read memory management on iphone development, lmore confused feel.

in advance ideas or comments!
macloop
 

nowhere in code using property.

doing this:

code:
 thelist = ... 
just assigns object 'thelist' instance variable. property accessors not being used. should doing this:

code:
 self.thelist = ... 
if don't understand this, need go re-read basics of objective-c syntax , properties.

don't understand trying mutablelist variable. please post complete code; not snippets. confuses issue.
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments