objective c - EXC_BAD_ACCESS in NSWindowController -


ok, situation bit complicated nature of issue should pretty simple more familiar me me cocoa memory management.

a few details : - main app, i'm loading "loadable" bundle (which consists of nswindowcontroller) - both projects (the main app , "plugin") arc-enabled

in plugin code, have custom initialization method :

- (id)initwithapi:(id)api {     pluginwindowcontroller* newpluginwindowcontroller = [super initwithwindownibname:@"pluginwindow"];      if (newpluginwindowcontroller)     {         [newpluginwindowcontroller setapi:api];     }      return newpluginwindowcontroller;  } 

this how api declared :

@property (unsafe_unretained) id api; 

now, here's catch :

  • i'm initializing using initwithapi: , api being set.
  • when i'm testing api's value in - (void)windowdidload: still shows fine.
  • however : when trying same thing within method (actually ibaction triggered button click in plugin's window)... trying [self api] triggers exc_bad_access error.

what doing wrong? ideas?

either declare property weak, if want automatically set nil when object dies, or strong, if want keep object alive (strong want).

unsafe_unretained result in dangling pointer if object deallocated (that's why called "unsafe"..)


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -