Menu Exception while tracking - cocoa

I have a serious exception thrown in 10.6, whereas everything is fine in 10.7. When calling action to menuitem the below log is generated. Please let me know why the following exception is thrown.
Regards,
iSight
23/04/12 6:26:15 PM MyApp[155] *** Assertion failure in -[NSComboBoxCell _objectValue:forString:errorDescription:], /SourceCache/AppKit/AppKit-1038.36/AppKit.subproj/NSCell.m:1531
23/04/12 6:26:15 PM MyApp[155] Invalid parameter not satisfying: aString != nil
23/04/12 6:26:25 PM MyApp[155] HIToolbox: ignoring exception '*** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: NSFont)' that raised inside Carbon event dispatch
CoreFoundation 0x99f3a6ca __raiseError + 41
libobjc.A.dylib 0x945e55a9 objc_exception_throw + 5
CoreFoundation 0x99f3a3f8 +[NSException raise:format:arguments:] + 13
CoreFoundation 0x99f3a36a +[NSException raise:format:] + 5
Foundation 0x9469d3eb -[NSCFDictionary setObject:forKey:] + 26
MyApp 0x000883df 0x0 + 55804
MyApp 0x000033d0 0x0 + 1326
MyApp 0x00029cf6 0x0 + 17125
AppKit 0x97443a26 -[NSApplication sendAction:to:from:] + 11
AppKit 0x974438d9 -[NSMenuItem _corePerformAction] + 43
0 AppKit 0x974435ca -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 17
1 AppKit 0x974434b6 -[NSMenu performActionForItemAtIndex:] + 6
2 AppKit 0x97443469 -[NSMenu _internalPerformActionForItemAtIndex:] + 5
3 AppKit 0x974433cf -[NSMenuItem
_internalPerformActionThroughMenuIfPossible] + 9
4 AppKit 0x97443313 -[NSCarbonMenuImpl
_carbonCommandProcessEvent:handlerCallRef:] + 33
5 AppKit 0x97437a55 NSSLMMenuEventHandler + 40
6 HIToolbox 0x90acac2f
_ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec
+ 156
7 HIToolbox 0x90ac9ef6 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec
+ 41
8 HIToolbox 0x90aec7f3 SendEventToEventTarget + 5
9 HIToolbox 0x90b18e87
_ZL18SendHICommandEventmPK9HICommandmmhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef
+ 44
0 HIToolbox 0x90b3db90 SendMenuCommandWithContextAndModifiers + 6
1 HIToolbox 0x90b3db47 SendMenuItemSelectedEvent + 12
2 HIToolbox 0x90b3da5d _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 15
3 HIToolbox 0x90cbf364
_ZL19PopUpMenuSelectCoreP8MenuData5PointdS1_tjPK4RecttmS4_S4_PK10__CFStringPP13OpaqueMenuRefPt
+ 185
4 HIToolbox 0x90cbf6bb _HandlePopUpMenuSelection7 + 67
5 AppKit 0x976cf6e6 _NSSLMPopUpCarbonMenu3 + 393
6 AppKit 0x976cfa76 -[NSCarbonMenuImpl
_popUpContextMenu:withEvent:forView:withFont:] + 22
7 AppKit 0x97848945 -[NSMenu _popUpContextMenu:withEvent:forView:withFont:] + 27
8 AppKit 0x978489e4 -[NSMenu
_popUpContextMenu:withEvent:forView:] + 6
9 AppKit 0x978487b7 -[NSMenu _popUpMenuWithEvent:forView:] + 5
0 AppKit 0x97a3f65d -[NSView rightMouseDown:] + 10
1 AppKit 0x97730d1b -[NSControl _rightMouseUpOrDown:] + 53
2 AppKit 0x9751ab28 -[NSWindow sendEvent:] + 575
3 AppKit 0x9743360b -[NSApplication sendEvent:] + 643
4 AppKit 0x973c7253 -[NSApplication run] + 91
5 AppKit 0x973bf289 NSApplicationMain + 57
6 MyApp 0x00002a45 0x0 + 1082
7 ??? 0x00000002 0x0 + 2 )
23/04/12 6:26:37 PM MyApp[155] NSMenu received exception *** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: NSFont) during menu tracking. The exception will be ignored.
23/04/12 6:26:37 PM Dynamo[155] *** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: NSFont)

In NSDictionary object you can not setting nil value

Related

Cocoa UI IBAction call seems to corrupt NSTimer

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.

How to solve error 'self.floatingGroupRowView should be equal to the given row view!'?

My macOS app uses a NSTableView with 'Floats Group Row' enabled. This works without problems on my test Macs. However, on a regular basis I receive crash reports from users with:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'self.floatingGroupRowView should be equal to the given row view!'
Does anyone know the conditions for this error?
The last part of the crashlog look similar to this:
0 CoreFoundation 0x00007fff51db6ff3 __exceptionPreprocess + 147
1 libobjc.A.dylib 0x00007fff78992c76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff51dbcda2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff53ebb260 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 192
4 AppKit 0x00007fff4f656e9f -[NSTableRowData _updateFloatingGroupRowView:row:] + 421
5 AppKit 0x00007fff4f4245db -[NSTableRowData _updateFrameRowView:row:] + 100
6 AppKit 0x00007fff4fd03fca __48-[NSTableRowData _doAutomaticRowHeightsForRows:]_block_invoke.1004 + 47
7 AppKit 0x00007fff4f40eae2 -[NSTableRowData enumerateAvailableRowViewsUsingBlock:] + 139
8 AppKit 0x00007fff4fd03ede -[NSTableRowData _doAutomaticRowHeightsForRows:] + 274
9 AppKit 0x00007fff4fd07157 __59-[NSTableRowData _automaticRowHeightsUpdateVisibleRowViews]_block_invoke.1494 + 141
10 AppKit 0x00007fff4fd06d05 -[NSTableRowData _keepTopRowStable:andDoWorkUntilDone:] + 535
11 AppKit 0x00007fff4fd07075 -[NSTableRowData _automaticRowHeightsUpdateVisibleRowViews] + 161
12 AppKit 0x00007fff4f415d85 -[NSTableRowData updateVisibleRowViews] + 261
13 AppKit 0x00007fff4f5bf24e -[NSTableRowData prepareContentInRect:] + 106
14 AppKit 0x00007fff4f5bed46 -[NSTableView prepareContentInRect:] + 303
15 AppKit 0x00007fff4fbbf7b1 __38-[NSView _pullInExtraTilesForOverdraw]_block_invoke + 562
16 AppKit 0x00007fff4f484a19 -[NSView _performWorkOnTilesFromRect:renderedContentRect:maximumRect:scrollVelocity:handler:] + 1544
17 AppKit 0x00007fff4f4841f2 -[NSView _pullInExtraTilesForOverdraw] + 854
18 AppKit 0x00007fff4f483e6d -[NSView _doIdlePrefetch] + 37
Unfortunately, these crashlogs don't point consistently to one particular line in my code.

NSToolbarItem unrecognized selector sent to instance

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.

removeobjectAtIndex: causes index to be -1;

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.

Passing value between NSTabView

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.

Resources