cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

Preference not saving on 10.9 #34

Closed synapse closed 10 years ago

synapse commented 10 years ago

Hello, I noticed that on 10.9 the preference is not saved. Actually the .plist file is not created. In one of my other sandboxed project I managed to create the prefs .plist file by calling the [NSUserDefaults resetStandardUserDefaults]; before setting the pref object and syncing.

Any ideas how to fix this? Thanks in advance

Cris.

shpakovski commented 10 years ago

Hello, I saw this behavior with development builds, maybe it does not depend on MASShortcut? Seems more like a bug with OS X sandboxing to me. Could you please confirm that things start working once you remove the component? Sorry for the late reply.

synapse commented 10 years ago

Hello, I removed the sandbox and it still does not save the keys in my pref file. Could you indicate which is the method that saves the user defaults with the NSData after the keys were assigned? Till now I've added around 20 NSLogs and nothing seams to fire after this method

shpakovski commented 10 years ago

MASShortcut saves NSData into User Defaults here: MASShortcutView+UserDefaults.m:120. Does it help?

synapse commented 10 years ago
shpakovski commented 10 years ago

You have assigned the associatedUserDefaultsKey and MASShortcutDefaultsObserver has been created, right?

synapse commented 10 years ago

I've followed your demo project and assigned the "associatedUserDefaultsKey" to the view and set up a "MASShortcut registerGlobalShortcutWithUserDefaultsKey" that listens for the hotkey action. As for the "MASShortcutDefaultsObserver" I could't find any usage examples.

shpakovski commented 10 years ago

MASShortcutDefaultsObserver is under the hood detail, there is no need to create it. But could you set a breakpoint in its -init method. Does it get called?

synapse commented 10 years ago

Nope, doesn't get called. Here are some attached images http://cl.ly/VIB8 and http://cl.ly/VHpD . From the README I understand this should be enough to make it run.

shpakovski commented 10 years ago

Does setAssociatedUserDefaultsKey: get called? Please ensure than IBOutlets are connected.

synapse commented 10 years ago

Ok found the problem. I had a typo in my code (that's what you get when you let your children touch your pc). It's 2 days I'm trying to figure out why it doesn't hook. Thank you for your help and sorry for wasting your time.

BTW thanks a lot for this tool. Bye

shpakovski commented 10 years ago

No problem, glad you fixed it :) Have a good day!