title: How to convert NSView to NSTableView in Objective-C
body: <p>I have an NSTableView that has multiple objects of a custom NSTableViewCell.
  Each NSTableViewCell object has three NSTextFields.
  I want to send the inputed text in each of the NSFields and assign it to a String variable.
  The problem is that I need to get the superview object in order to determine the selectedRow in which that custom NSTableViewCell exists.</p>
  
  <p>something would maybe look like this in Swift:</p>
  
  <pre><code>let textField = sender as! NStextField
  let myView = textField.superview?.superview?.superview as! NSTableView
  let num = myView.row(for: textField.superview!)
  </code></pre>
  
  <p>I tried this for one of the NSTextField:</p>
  
  <pre><code>- (IBAction)setValue:(id)sender {
      NSTableView *thisTable = self.cell.superview.superview.superview.superview;
      NSInteger num = [thisTable selectedRow];  
  }
  </code></pre>
  
  <p>It didn't work and also I'm getting this warning:</p>
  
  <blockquote>
    <p>Incompatible pointer types initializing 'NSTableView *' with an
    expression of type 'NSView * _Nullable'</p>
  </blockquote>
  
  <p>My CustomCell class is a simple Class just to draw the cell.</p>
  
  <pre><code>@implementation CustomCell
  - (id)init {
      self = [super init];
  
      if(self != nil) {
          _cellTitle;
          _cellBackLight;
          _cellTime;
  
      }
      return self;
  }
  
  - (void)drawRect:(NSRect)dirtyRect { 
      [super drawRect:dirtyRect];
  }
  </code></pre>
  
  <p>The .h file:</p>
  
  <pre><code>@interface CustomCell : NSTableCellView
  @property NSString *cellTitle;
  @property double cellValue;
  @property int cellTime;
  @property (strong) IBOutlet NSTextField *titleField;
  @property (strong) IBOutlet NSTextField *valueField;
  @property (strong) IBOutlet NSTextField *durationField; 
  //All outlets are linked from Storyboard to the CustomCell class.
  @end
  </code></pre>
  
  <p>The tableView delegate:</p>
  
  <pre><code>- (id)tableView:(NSTableView *)viewTableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex {
      NSTableCellView *cell = [viewTableView makeViewWithIdentifier:tableColumn.identifier owner:self];
  
      cell = [viewTableView makeViewWithIdentifier:@"MainCell" owner:self];
      return cell;
  }
  </code></pre>
  
  <hr>
  
  <p>What I am trying to achieve : 
  <a href="https://i.stack.imgur.com/8aGLe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8aGLe.png" alt="enter image description here"></a></p>