Wednesday, 22 April 2015

[NSArray count] Problem (exception thrown)


i have problem section of code:

code:
nsarray *array = [[[nsarray alloc] init] autorelease];      array = [self getsavedchanges];            nslog(@"%u", [array count]);
here getsavedchanges method:

code:
- (nsarray *)getsavedchanges  {      nsarray *array = [[[nsarray alloc] init] autorelease];      array = [nskeyedunarchiver unarchiveobjectwithfile:pathindocumentdirectory(@"points.data")];      return array;  }
here pathindocumentdirectory() function:

code:
nsstring *pathindocumentdirectory(nsstring *filename)  {      nsarray *documentdirectories = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);      nsstring *documentdirectory = [documentdirectories objectatindex:0];      return [documentdirectory stringbyappendingpathcomponent:filename];  }
the problem experiencing after objects unarchived , added nsarray, sent message "count." happens when send "count" nsarray. don't want count of objects in nsarray, want count of nsarray itself... why objects within nsarray being sent "count"?

in case wondering, here code debugger exception thrown. "mappoint" name of class of unarchived objects:

code:
2012-02-15 15:32:01.342 mylocation[16596:11c03] -[mappoint count]: unrecognized selector sent instance 0x6d8d540  2012-02-15 15:32:01.362 mylocation[16596:11c03] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[mappoint count]: unrecognized selector sent instance 0x6d8d540'  *** first throw call stack:  (0x157d052 0x139dd0a 0x157eced 0x14e3f00 0x14e3ce2 0x2c53 0x23864e 0x198a73 0x198ce2 0x198ea8 0x19fd9a 0x170be6 0x1718a6 0x180743 0x1811f8 0x174aa9 0x1380fa9 0x15511c5 0x14b6022 0x14b490a 0x14b3db4 0x14b3ccb 0x1712a7 0x172a9b 0x1d02 0x1c75)  terminate called throwing exception(gdb) 
 

why keep creating autoreleased array instances don't use , instantly assign object variable?
 


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

No comments:

Post a Comment