I'm developing an app for OSX in Xcode5
I want to display a popover after a user ends editing a tableview cell what am I doing is the following:
-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
if ([[tableColumn.headerCell stringValue] isEqualToString:@"CUENTAS DE ACTIVO"]) {
[arrayOne replaceObjectAtIndex:row withObject:object];
}
else{
[arrayTwo replaceObjectAtIndex:row withObject:object];
}
[self.popoverClasifCuentas showRelativeToRect:[tableView bounds] ofView:[[[tableColumn dataCell] objectAtIndex:row] view] preferredEdge:NSMaxYEdge];
}
when I run this I get following error:
-[NSTextFieldCell objectAtIndex:]: unrecognized selector sent to instance 0x6080002a2a60
2014-06-09 19:17:18.424 eAccounting[2976:303] Exception detected while handling key input.
2014-06-09 19:17:18.424 eAccounting[2976:303] -[NSTextFieldCell objectAtIndex:]: unrecognized selector sent to instance 0x6080002a2a60
2014-06-09 19:17:18.426 eAccounting[2976:303] (
0 CoreFoundation 0x00007fff9428625c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8c47ee75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff9428912d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff941e4322 ___forwarding___ + 1010
4 CoreFoundation 0x00007fff941e3ea8 _CF_forwarding_prep_0 + 120
5 eAccounting 0x000000010000a88a -[EdicionDeCuentasWC tableView:setObjectValue:forTableColumn:row:] + 922
6 AppKit 0x00007fff955699f5 -[NSTableView textDidEndEditing:] + 487
7 CoreFoundation 0x00007fff94254e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
8 CoreFoundation 0x00007fff941488dd _CFXNotificationPost + 2893
9 Foundation 0x00007fff8d58c7ba -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
10 AppKit 0x00007fff9512582d -[NSTextView(NSPrivate) _giveUpFirstResponder:] + 438
11 AppKit 0x00007fff95173aec -[NSTextView(NSKeyBindingCommands) insertNewline:] + 239
12 AppKit 0x00007fff950f6c2f -[NSResponder doCommandBySelector:] + 71
13 AppKit 0x00007fff9512410a -[NSTextView doCommandBySelector:] + 196
14 AppKit 0x00007fff950f6151 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 1392
15 AppKit 0x00007fff951151c2 -[NSTextInputContext handleEvent:] + 845
16 AppKit 0x00007fff950f49dd -[NSView interpretKeyEvents:] + 180
17 AppKit 0x00007fff95114d6d -[NSTextView keyDown:] + 658
18 AppKit 0x00007fff950c156b -[NSWindow sendEvent:] + 1843
19 AppKit 0x00007fff95062b32 -[NSApplication sendEvent:] + 3395
20 AppKit 0x00007fff94eb2a19 -[NSApplication run] + 646
21 AppKit 0x00007fff94e9d7a3 NSApplicationMain + 940
22 eAccounting 0x000000010000c3e2 main + 34
23 libdyld.dylib 0x00007fff899a55fd start + 1
24 ??? 0x0000000000000003 0x0 + 3
it doesn't work fine, provisionally I added a hidden button on the top of my NSTableView, set an IBOutlet for it (popoverButton) and following IBAction:
- (IBAction)showPopover:(id)sender {
ClasificacionDeCuentasVC *vc = (ClasificacionDeCuentasVC *) self.popoverClasifCuentas.contentViewController;
vc.delegate = self;
[self.popoverClasifCuentas showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxYEdge];
}
and then I replaced on my NSTableView method last sentence:
-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
if ([[tableColumn.headerCell stringValue] isEqualToString:@"CUENTAS DE ACTIVO"]) {
[arrayOne replaceObjectAtIndex:row withObject:object];
}
else{
[arrayTwo replaceObjectAtIndex:row withObject:object];
}
[self.popoverButton performClick:tableView];
}
it works but shows my popover at NSButton's location like this:
and I want to show it on my tableview cell's location, how to do that???