title: Creating window with a NSTextView programmatically
body: <p>I wish to create a window without a nib file which consists entirely of an NSTextView.</p>
  
  <p>It should act as a popup but still be modeless.</p>
  
  <p>So far I have two properties:</p>
  
  <pre><code>@property (strong,nonatomic) NSWindow *consoleWindow;
  @property (strong,nonatomic) NSTextView* textView;
  </code></pre>
  
  <p>Here is what my implementation looks like:</p>
  
  <pre><code>-(void)doubleAction:(NSOutlineView*)sender
       {
  
           if(self.currentLogEntry == nil)
           {
               return;
           }
  
           self.consoleWindow = nil;
           self.textView = nil;
  
  
           NSRect windowRect = NSMakeRect(10.0f, 10.0f, 500.0f, 400.0f);
           self.consoleWindow = [[NSWindow alloc] initWithContentRect:windowRect
                                                            styleMask:( NSResizableWindowMask | NSClosableWindowMask | NSTitledWindowMask)
                                                              backing:NSBackingStoreBuffered defer:NO];
  
  
           self.textView = [[NSTextView alloc] initWithFrame:[[self.consoleWindow contentView] frame]];
          [self.textView setString:self.currentLogEntry.value];
          [self.consoleWindow setContentView:self.textView];
  
  
           [self.consoleWindow makeKeyAndOrderFront:nil];
           [self.consoleWindow makeFirstResponder:self.textView];
  
  
  
           NSLog(@"Double clicked");
       }
  </code></pre>
  
  <p>Things have been wired up so I have a list of entries, whenever I double click on an entry the selected entry is loaded into <code>self.currentLogEntry</code> and this method is then fired. It works but if I close the window and try to open another entry I get <code>Thread 1:EXC_BAD_ACCESS (code=EXC_I386_GPFLT)</code></p>
  
  <p>I think it has something to do with the window not being released properly but I have tried a few things like setting the properties to nil whenever the program enters the doubleAction (as you can see in the code) but that doesn't help.</p>
  
  <p>Any help solving this problem is greatly appreciated.</p>