I have 3 NSToolbarItems and the first one works just fine, the other two, each time I select them throw
[16392:513506] -[NSToolbarItem isEqualToString:]: unrecognized selector sent to instance 0x6080001203c0
2015-05-26 19:59:26.871 MyApp[16392:513506] (
0 CoreFoundation 0x00007fff89f9703c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8a40176e objc_exception_throw + 43
2 CoreFoundation 0x00007fff89f9a0ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff89edfe24 ___forwarding___ + 1028
4 CoreFoundation 0x00007fff89edf998 _CF_forwarding_prep_0 + 120
5 AppKit 0x00007fff9649d74e +[NSToolbar _shouldIgnoreItemIdentifier:] + 35
6 AppKit 0x00007fff9649d6f7 removeIgnoredIdentifiers + 89
7 AppKit 0x00007fff9675e526 -[NSToolbar selectableItemIdentifiers] + 224
8 AppKit 0x00007fff9675e411 -[NSToolbar _isSelectableItemIdentifier:] + 34
9 AppKit 0x00007fff9675e385 -[NSToolbar setSelectedItemIdentifier:] + 79
10 AppKit 0x00007fff96654f3c -[NSToolbarItemViewer mouseDown:] + 4951
11 AppKit 0x00007fff96bc52fc -[NSWindow _reallySendEvent:isDelayedEvent:] + 14125
12 AppKit 0x00007fff96554d76 -[NSWindow sendEvent:] + 470
13 AppKit 0x00007fff96551312 -[NSApplication sendEvent:] + 2504
14 AppKit 0x00007fff9647ac68 -[NSApplication run] + 711
15 AppKit 0x00007fff963f7354 NSApplicationMain + 1832
16 IPLocation 0x000000010001769d main + 109
17 libdyld.dylib 0x00007fff96ffd5c9 start + 1
18 ??? 0x0000000000000003 0x0 + 3
)
I tried disconnecting and reconnecting them from the storyboard,but nothing changed. The IBAction doesn't even get called.
My ViewController
func toolbarSelectableItemIdentifiers(toolbar: NSToolbar) -> [AnyObject] {
// let array = toolbar.items.filter { contains(Identifier.allValues, $0.itemIdentifier ) }//wrong!
return Identifier.allValues
}
The delegate just needed the name of the identifiers, not the selectable items themselves.
Related
I have a function:
NSTimer *learnUSBTimer=nil;
- (void)showUSBWindow:(id)sender {
[self updateDeviceButton:#"Cancel"];
[self hideDeviceClearButton:TRUE];
[selectedDeviceField setStringValue:#"Insert the USB device..."];
learnUSBMode=1;
if(learnUSBTimer)
{
if([learnUSBTimer isValid])[learnUSBTimer invalidate];
learnUSBTimer=nil;
}
}
And it seems my message sent to the timer object is being sent to the UI object:
2018-02-19 14:02:34.649581-0500 TokenLock[4068:819373] -[NSBox isValid]: unrecognized selector sent to instance 0x60000016bc40
2018-02-19 14:02:34.649691-0500 TokenLock[4068:819373] [General] -[NSBox isValid]: unrecognized selector sent to instance 0x60000016bc40
2018-02-19 14:02:34.651799-0500 TokenLock[4068:819373] [General] (
0 CoreFoundation 0x00007fff4f33833b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff7607c942 objc_exception_throw + 48
2 CoreFoundation 0x00007fff4f3cf5e4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff4f2aff03 ___forwarding___ + 1443
4 CoreFoundation 0x00007fff4f2af8d8 _CF_forwarding_prep_0 + 120
5 TokenLock 0x0000000100014cdc -[AppController showUSBWindow:] + 252
6 AppKit 0x00007fff4d02375a -[NSApplication(NSResponder) sendAction:to:from:] + 312
7 AppKit 0x00007fff4cac9933 -[NSControl sendAction:to:] + 86
8 AppKit 0x00007fff4cac985b __26-[NSCell _sendActionFrom:]_block_invoke + 136
9 AppKit 0x00007fff4cac9761 -[NSCell _sendActionFrom:] + 183
10 AppKit 0x00007fff4cb0aa18 -[NSButtonCell _sendActionFrom:] + 97
11 AppKit 0x00007fff4cac7fca -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2438
12 AppKit 0x00007fff4cb0a75f -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 777
13 AppKit 0x00007fff4cac6a64 -[NSControl mouseDown:] + 965
14 AppKit 0x00007fff4d1c2959 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 5891
15 AppKit 0x00007fff4d1bf5b0 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2359
16 AppKit 0x00007fff4d1be85c -[NSWindow(NSEventRouting) sendEvent:] + 497
17 AppKit 0x00007fff4d01f617 -[NSApplication(NSEvent) sendEvent:] + 307
18 AppKit 0x00007fff4c880d9d -[NSApplication run] + 812
19 AppKit 0x00007fff4c84ff1a NSApplicationMain + 804
20 TokenLock 0x0000000100001ea1 main + 97
21 TokenLock 0x0000000100001e34 start + 52
)
I dont understand how my NSTimer is being somehow assigned to the UI Box being clicked to execute the function?
It seems that there will be some memory management issue in your code. And the objects are not properly allocated/ deallocated or not initialised deinitialised properly.
So to solve this issue just run your code by enabling zombies into your project target settings.
It turns out this timer fires once. I was not setting it to nil in that code and so it became essentially an orphan because the system released the actual timer object after.
Setting it to nil on firing fixes the issue.
I have a NSTableView that is populated by an array called tableArray. I have a button that is supposed to remove the selected item from the array. In my removeItem: method:
[tableArray removeObjectAtIndex:[tableView selectedRow];
[tableView reloadData];
But I get the error:
2015-05-13 18:16:45.283 FileShedb1.0[979:303] *** -[__NSArrayM objectAtIndex:]: index 18446744073709551615 beyond bounds [0 .. 0]
2015-05-13 18:16:45.288 FileShedb1.0[979:303] (
0 CoreFoundation 0x00007fff8d35ff56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff93119d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8d2ed392 -[__NSArrayM objectAtIndex:] + 274
3 FileShedb1.0 0x00000001000028a9 -[MPOMainWindowController tableViewSelectionDidChange:] + 201
4 Foundation 0x00007fff8cca0d0e __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 + 47
5 CoreFoundation 0x00007fff8d3087ba _CFXNotificationPost + 2634
6 Foundation 0x00007fff8cc8cfc3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 65
7 AppKit 0x00007fff8ab10049 -[NSTableView _sendSelectionChangedNotificationForRows:columns:] + 203
8 AppKit 0x00007fff8aae6b0a -[NSTableView _enableSelectionPostingAndPost] + 425
9 AppKit 0x00007fff8aadcd75 -[NSTableView _tileAndRedisplayAll] + 358
10 FileShedb1.0 0x00000001000027bc -[MPOMainWindowController removeFile:] + 188
11 CoreFoundation 0x00007fff8d34f70d -[NSObject performSelector:withObject:] + 61
12 AppKit 0x00007fff8aaa98ca -[NSApplication sendAction:to:from:] + 139
13 AppKit 0x00007fff8aaa97fe -[NSControl sendAction:to:] + 88
14 AppKit 0x00007fff8aaa9729 -[NSCell _sendActionFrom:] + 137
15 AppKit 0x00007fff8aaa8bec -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2014
16 AppKit 0x00007fff8ab28b74 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 489
17 AppKit 0x00007fff8aaa77f6 -[NSControl mouseDown:] + 786
18 AppKit 0x00007fff8aa72c98 -[NSWindow sendEvent:] + 6306
19 AppKit 0x00007fff8aa0c3a5 -[NSApplication sendEvent:] + 5593
20 AppKit 0x00007fff8a9a2a0e -[NSApplication run] + 555
21 AppKit 0x00007fff8ac1eeac NSApplicationMain + 867
22 FileShedb1.0 0x00000001000014c2 main + 34
23 FileShedb1.0 0x0000000100001494 start + 52
)
Anyone know why i'm getting the error?
If no row is selected, selectedRow row returns -1. Put a check for this.
Checkout apple's documentation.
I'm testing Swift in a simple Mac app. I got a NSToolbar in Storyboard and draw a NSSearchfield inside. The NSSearchfiled is connected to the First Responder's method controlTextDidChange (the first responder is the ViewController where I added NSTextFieldDelegate).
This is the method:
#IBAction override func controlTextDidChange(obj: NSNotification!) {
println("searching...")
println(obj.object.stringValue)
}
The method gets correctly called every time a new character is searched and the app does not crash however what's being returned is the following:
searching...
2014-08-03 09:56:57.770 TestApp[1129:24219] -[NSSearchField object]: unrecognized selector sent to instance 0x6080001a07e0
2014-08-03 09:56:57.770 TestApp[1129:24219] -[NSSearchField object]: unrecognized selector sent to instance 0x6080001a07e0
2014-08-03 09:56:57.775 TestApp[1129:24219] (
0 CoreFoundation 0x00007fff92e6af1c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff930ae74e objc_exception_throw + 43
2 CoreFoundation 0x00007fff92e6de4d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x00007fff92db63c4 ___forwarding___ + 1028
4 CoreFoundation 0x00007fff92db5f38 _CF_forwarding_prep_0 + 120
5 TestApp 0x000000010000c187 _TFC9TestApp14ViewController20controlTextDidChangefS0_FGSQCSo14NSNotification_T_ + 231
6 TestApp 0x000000010000c582 _TToFC9TestApp14ViewController20controlTextDidChangefS0_FGSQCSo14NSNotification_T_ + 66
7 libsystem_trace.dylib 0x00007fff9117bc07 _os_activity_initiate + 75
8 AppKit 0x00007fff8d52b168 -[NSApplication sendAction:to:from:] + 410
9 AppKit 0x00007fff8d52af90 -[NSControl sendAction:to:] + 86
10 AppKit 0x00007fff8d6faf91 __26-[NSCell _sendActionFrom:]_block_invoke + 131
11 libsystem_trace.dylib 0x00007fff9117bc07 _os_activity_initiate + 75
12 AppKit 0x00007fff8d57329e -[NSCell _sendActionFrom:] + 144
13 AppKit 0x00007fff8d92fe8f __64-[NSSearchFieldCell(NSSearchFieldCell_Local) _sendPartialString]_block_invoke + 63
14 libsystem_trace.dylib 0x00007fff9117bc07 _os_activity_initiate + 75
15 AppKit 0x00007fff8d92fe47 -[NSSearchFieldCell(NSSearchFieldCell_Local) _sendPartialString] + 186
16 Foundation 0x00007fff932ee3d3 __NSFireTimer + 95
17 CoreFoundation 0x00007fff92dbf464 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
18 CoreFoundation 0x00007fff92dbf0f3 __CFRunLoopDoTimer + 1059
19 CoreFoundation 0x00007fff92e320fd __CFRunLoopDoTimers + 301
20 CoreFoundation 0x00007fff92d7b4d2 __CFRunLoopRun + 2018
21 CoreFoundation 0x00007fff92d7aaa8 CFRunLoopRunSpecific + 296
22 HIToolbox 0x00007fff90adcaff RunCurrentEventLoopInMode + 235
23 HIToolbox 0x00007fff90adc872 ReceiveNextEventCommon + 431
24 HIToolbox 0x00007fff90adc6b3 _BlockUntilNextEventMatchingListInModeWithFilter + 71
25 AppKit 0x00007fff8d35c2a5 _DPSNextEvent + 1000
26 AppKit 0x00007fff8d35ba79 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 139
27 AppKit 0x00007fff8d34fad3 -[NSApplication run] + 594
28 AppKit 0x00007fff8d33b2de NSApplicationMain + 1778
29 TestApp 0x000000010000da72 top_level_code + 34
30 TestApp 0x000000010000daaa main + 42
31 libdyld.dylib 0x00007fff8cb765c9 start + 1
32 ??? 0x0000000000000003 0x0 + 3
)
I can't figure out where the "unrecognized selector sent to instance" comes from.
controlTextDidChange method expects NSSearchField!, not NSNotification!.
Replace
#IBAction override func controlTextDidChange(obj: NSNotification!) {
println("searching...")
println(obj.object.stringValue)
}
with
#IBAction override func controlTextDidChange(obj: NSSearchField!) {
println("searching...")
println(obj.stringValue)
}
Solved by defining a custom method
#IBAction func controlTextDidChange_Custom(obj: NSSearchField!) {
if (!obj.stringValue.isEmpty) {
println("Searched: \(obj.stringValue)")
} else {
println("EMPTY")
}
}
I have a subclass of NSDocument that crashes whenever I use [self close] to avoid the default 'save' dialog for new documents:
2013-02-25 15:23:06.338 MyApp[692:403] An uncaught exception was raised
2013-02-25 15:23:06.338 MyApp[692:403] NSWindow: -_newFirstResponderAfterResigining is not a valid message outside of a responder's implementation of -resignFirstResponder.
2013-02-25 15:23:06.356 MyApp[692:403] (
0 CoreFoundation 0x00007fff8b2cdf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff88c00d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8b2cdd8a +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff8b2cdd14 +[NSException raise:format:] + 116
4 AppKit 0x00007fff858e0c34 -[NSWindow _newFirstResponderAfterResigning] + 164
5 AppKit 0x00007fff85882c8a -[NSTextView(NSSharing) resignFirstResponder] + 54
6 AppKit 0x00007fff8536dd79 -[NSWindow makeFirstResponder:] + 429
7 AppKit 0x00007fff85488dfb -[NSWindow dealloc] + 802
8 AppKit 0x00007fff8528b955 -[NSWindow release] + 535
9 AppKit 0x00007fff858b541c __destroy_helper_block_4 + 26
10 libsystem_blocks.dylib 0x00007fff8702b174 _Block_release + 181
11 libdispatch.dylib 0x00007fff84ab28f2 _dispatch_main_queue_callback_4CF + 308
12 CoreFoundation 0x00007fff8b262e7c __CFRunLoopRun + 1724
13 CoreFoundation 0x00007fff8b262486 CFRunLoopRunSpecific + 230
14 HIToolbox 0x00007fff8d64e2bf RunCurrentEventLoopInMode + 277
15 HIToolbox 0x00007fff8d65556d ReceiveNextEventCommon + 355
16 HIToolbox 0x00007fff8d6553fa BlockUntilNextEventMatchingListInMode + 62
17 AppKit 0x00007fff85252779 _DPSNextEvent + 659
18 AppKit 0x00007fff8525207d -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
19 AppKit 0x00007fff8524e9b9 -[NSApplication run] + 470
20 AppKit 0x00007fff854caeac NSApplicationMain + 867
21 MyApp 0x00000001059098d2 main + 34
22 MyApp 0x00000001059098a4 start + 52
23 ??? 0x0000000000000003 0x0 + 3
)
Has anyone seen this before or can anyone suggest a better/proper way to close an NSDocument without the save dialog being shown?
So judging by your followup comments, what you're trying to do is suppress the standard close confirmation sheet under specific circumstances. Some ways to do that:
Adopt autosaving-in-place, which moves away from the ancient paradigm of manually saving documents
Override -[NSDocument canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:] so it tells the delegate "yes, you can close", rather than presenting a sheet
Once a post is made, call [document updateChangeCount: NSChangeCleared] to inform the document that you consider it to be saved
I try to do a simple program in cocoa, a NSTabVew with 2 items, in the first item I set a content to a string var, in the second tab I display this value. I create two Object class (Prima and Seconda), than I add 2 object in IB setting like Prima and Seconda
Prima.m
- (IBAction) salva:(id) sender{
nome = [field stringValue];
NSLog(#"%#",nome);
}
Seconda.m
- (IBAction) visualizza:(id) sender{
NSString *dato;
Prima *prima = [[Prima alloc] init];
dato = prima.nome;
[label setStringValue:dato];
}
when I run the program I get this error:
2011-10-03 11:42:43.511 Prova[44622:707] *** Assertion failure in -[NSTextFieldCell _objectValue:forString:errorDescription:], /SourceCache/AppKit/AppKit-1138/AppKit.subproj/NSCell.m:1564
2011-10-03 11:42:43.511 Prova[44622:707] Invalid parameter not satisfying: aString != nil
2011-10-03 11:42:43.513 Prova[44622:707] (
0 CoreFoundation 0x00007fff8d497986 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff90ed9d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8d4977ba +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff8cce914f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
4 AppKit 0x00007fff88957685 -[NSCell _objectValue:forString:errorDescription:] + 160
5 AppKit 0x00007fff889575df -[NSCell _objectValue:forString:] + 19
6 AppKit 0x00007fff88957545 -[NSCell setStringValue:] + 41
7 AppKit 0x00007fff88a58039 -[NSControl setStringValue:] + 115
8 Prova 0x0000000100001365 -[Seconda visualizza:] + 133
9 CoreFoundation 0x00007fff8d48711d -[NSObject performSelector:withObject:] + 61
10 AppKit 0x00007fff88a3f852 -[NSApplication sendAction:to:from:] + 139
11 AppKit 0x00007fff88a3f784 -[NSControl sendAction:to:] + 88
12 AppKit 0x00007fff88a3f6af -[NSCell _sendActionFrom:] + 137
13 AppKit 0x00007fff88a3eb7a -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2014
14 AppKit 0x00007fff88abe57c -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 489
15 AppKit 0x00007fff88a3d786 -[NSControl mouseDown:] + 786
16 AppKit 0x00007fff88a0866e -[NSWindow sendEvent:] + 6280
17 AppKit 0x00007fff889a0f19 -[NSApplication sendEvent:] + 5665
18 AppKit 0x00007fff8893742b -[NSApplication run] + 548
19 AppKit 0x00007fff88bb552a NSApplicationMain + 867
20 Prova 0x0000000100000f92 main + 34
21 Prova 0x0000000100000f64 start + 52
22 ??? 0x0000000000000001 0x0 + 1
)
where is the error for you?
It seems that dato is nil, which (based on what you've given us) is probably because things aren't hooked up right in the XIB. Without more information I can't say more.