I am building a toy app using core data for two entities Log (attributes text and date) and Tag with a many-to-many tags relationship from Log to Tag.
I want to show logs in a table, so I:
- created an
NSArrayControllerinstance,LogControllerin IB with entity set toLog(pic) - created a one-column
NSTableViewwhose column is bound toLogController. pic - linked the
LogControllerin my app delegate (AppDelegate) usingIBOutlet.AppDelegatealso has themanagedObjectContext. - created a custom
NSCellclass withNSStringpropertiesmainTextandtagsTextthat I draw onto the cell - I set the above two cell properties in
AppDelegatein the- (void)tableView: willDisplayCell: forTableColumn: row:method. (MainControlleris also the table's delegate). For thetagsTextI get the tags for the current log and concatenate them into a singleNSString
Everything works fine, except: When I mouse-select a row that displays multiple tags the app crashes with an EXC_BAD_ACCESS. That's the only time I have any error, but I don't know what is causing it.
EXC_BAD_ACCESSis a memory error. You are using an object after deallocating it. It would be difficult to debug this without the code.Are you using the garbage collector? You do not have to manage memory yourself on the Mac.
Are the properties in your custom NSCell declared as "retain"?