Help ! Get array from another class (Dao) and release it


hi,

have function in dao class return array. array function , used in class when release array, application crash when run it.

here code:

dao.m

//funtion data database , return nsmutablearray.
-(nsmutablearray*) selecttypesarray
{
nsmutablearray * types = [nsmutablearray alloc]init];

// code here data database.

return types;
}


firstviewcontroller.m

viewdidload
{

dao dao = [[dao alloc]init];

nsmutablearray * temp = [dao selecttypesarray];

nsmutablearray * types = temp;


[self.displaytypes:types];

[temp release];
[dao release];

}

-(void)displaytypes: (nsmutablearray*)types
{
nslog(@"types count %i", [types count]);
}

when run program, crash error message : "-[__nsarraym count]: message sent deallocated". think happens because have released "temp" , "types" reference deallocated object ... ...but don't know how write code in correct way. can tell me correct way write code?

comments , suggestions welcome , appreciated. lot. :)
 

you need (re)view memory management programming guide learn how use retain, release , autorelease correctly objects neither deallocated prematurely nor leaked because aren't deallocated @ all.
 


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

Popular posts from this blog

Mac OS X Server as File Server for 50/50 Mac & PC Workgroup

Permissions Problem?

iPhone won't sync with iTunes