I am working on a Cocoa/Objective-C app in XCode4 that uses shortcutrecorder to record keyboard shortcuts and save them to defaults.
I am saving the KeyCombo.code and KeyCombo.flags attributes from the recorder, i.e:
[shortcutRecorder KeyCombo].code
[shortcutRecorder KeyCombo].flags
Where shortcutRecorder is an IBOutlet to the SRRecorderControl.
In order to restore saved keyboard shortcuts when the user opens the preferences window again, I load the KeyCombo.code and KeyCombo.flags attributes from defaults, and need to restore them to the `SRRecorderControl.
I am trying to do:
[shortcutRecorder setKeyCombo:[
PTKeyCombo keyComboWithKeyCode:
[shortcutRecorder keyCombo].code
modifiers:[shortcutRecorder cocoaToCarbonFlags:[shortcutRecorder
keyCombo].flags]]];
But this causes an error: Sending 'id' to parameter of incompatible type 'KeyCombo' (aka 'struct_KeyCombo')
I thought this might be because setKeyCombo takes a KeyCombo object and not a PTKeyCombo object, so I changed it:
[shortcutRecorder setKeyCombo:[
KeyCombo keyComboWithKeyCode:
[shortcutRecorder keyCombo].code
modifiers:[shortcutRecorder cocoaToCarbonFlags:[shortcutRecorder
keyCombo].flags]]];
But now I receive the error: Receiver type 'KeyCombo' (aka 'struct_KeyCombo') is not an Objective-C class
I’m not sure how to go about creating a valid object to pass to setKeyCombo. Any tips on the best way to handle this?
Try
SRMakeKeyCombo(code, flags)