Re: Refresh com.apple.symbolichotkeys.plist
Is there any way to cause the system to re-read com.apple.symbolichotkeys.plist.plist in Cocoa (or anywhere else)? I want to programmatically change a shortcut (which is no problem), but I want it to take effect immediately. System Preferences obviously signals the system to do this - does anyone know how it does that? I did some more poking around and zeroed in on the following in the system log snippet: com.apple.launchd[1]: System: Looking up service com.apple.metadata.mds com.apple.launchd[1] (com.apple.launchd.peruser.501[160]): Mach service lookup: com.apple.metadata.mds com.apple.launchd[1]: Dispatching kevent... com.apple.launchd[1]: KEVENT[0]: udata = 0x10002b210 data = 0x30 ident = 5 filter = EVFILT_READ flags = EV_ADD|EV_RECEIPT fflags = 0x0 distnoted[16]: received_message_from System Preferences [A0] post SpotlightPrefCumulativePrefChangeNotification (null) Based on my very limited understanding, it seems the Mach service is the key, but I don't know how to simulate what System Preferences is doing. Sean DeNigris p.s. is there a better/additional list to ask about this? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Refresh com.apple.symbolichotkeys.plist
Hi list, Is there any way to cause the system to re-read com.apple.symbolichotkeys.plist.plist in Cocoa (or anywhere else)? I want to programmatically change a shortcut (which is no problem), but I want it to take effect immediately. System Preferences obviously signals the system to do this - does anyone know how it does that? Thanks! Sean DeNigris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is it possible to pass an object to a NIB
I tightened up the code a bit: #Obj-C version: - (id)initWithContentsOfURL:(NSURL *)nibFileURL nib_file = NSNib.alloc.initWithContentsOfURL NSURL::fileURLWithPath(@@NibPath) #Obj-C version: - (BOOL)instantiateNibWithOwner:(id)ownertopLevelObjects:(NSArray **)topLevelObjects #The Ruby bridge puts the top level objects in the second return value because the 2nd param takes a pointer # and Ruby does not have pointers result, top_level_objects = nib_file.instantiateNibWithOwner_topLevelObjects NSApplication.sharedApplication view = top_level_objects.find { |obj| obj.class == object_type } - Sean___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Is it possible to pass an object to a NIB
Really, the external name table is for referring to objects in nibs, rather than pushing objects into nibs. Thanks. That's what I wanted to know - I thought the docs suggested maybe you could pass objects in (other than owner) Furthermore, from your further description it sounds like what you’re referring to as a “view” is actually a subclass of NSWindowController; it knows how to load a nib file already, so you should just leverage that rather than try to do it all yourself by hand. Thanks again. It's an ultra-thin gui a-la Dave Astels' TDD: A Practical Guide (originally Mike Feathers' Humble dialog). There is another controller class that handles all the logic. This class just delegates the actions and outlets from Cocoa, so from my app's perspective, it's a view, but from cocoa's perspective, it's a controller. It think it should be just an NSObject (that's what I've seen in all the books and there's only one window in my app). I made it an NSWindowController in the process of trying to get it to load the nib (which is only for testing) and forgot to set it back. Is there a reason to keep it an NSWindowController? I ended up with the following that loaded the nib successfully in the test: NSApplication.sharedApplication top_level = [] context = NSDictionary::dictionaryWithObjects_forKeys [NSApp, top_level], [NSNibOwner, NSNibTopLevelObjects] @@NibPath = /path/to/MainMenu.nib OSX::NSBundle::loadNibFile_externalNameTable_withZone @@NibPath, context, NSApp.zone objects = context['NSTopLevelObjects'] view = objects.find { |obj| obj.class == object_type } Sean DeNigris s...@clipperadams.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Is it possible to pass an object to a NIB
Hi list! I'm writing a RubyCocoa app, but my question is on the Cocoa API... I'm trying to unit test a view class. As it is very thin (just delegates all work to the controller), all I want to check is that my connections (e.g. outlets and actions) are hooked up correctly. I've been trying to: 1. Create an instance of my class 2. use NSBundle::loadNibFile: externalNameTable: withZone: to load the nib 3. check the connections The docs for loadNibFile (http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSBundle_AppKitAdditions/Reference/Reference.html) seem to suggest that you can pass objects in: A name table whose keys identify objects associated with your program or the nib file. The newly unarchived objects from the nib file use this table to connect to objects in your program. But I can't get it to work after hours! This code is in ruby, but it's just bridged to the corresponding Cocoa calls: view = MyView.new # subclass of NSWindowController NSApplication.sharedApplication top_level = [] # I've tried passing everything I could think of here: - view # the object instance - My View = view # NSDictionary with key object name in IB and value object instance - MyView = view # NSDictionary with class name / object entry # I Also tried passing the object, and object-containing dictionaries below # e.g. dictionaryWithObjects_forKeys [NSApp, top_level, view], [NSNibOwner, NSNibTopLevelObjects, My View] context = NSDictionary::dictionaryWithObjects_forKeys [NSApp, top_level], [NSNibOwner, NSNibTopLevelObjects] NibPath = .../RandomAppRuby.app/Contents/Resources/English.lproj/MainMenu.nib OSX::NSBundle::loadNibFile_externalNameTable_withZone NibPath, context, NSApp.zone Thanks in advance for any guidance! Sean DeNigris s...@clipperadams.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Re: Can I tell [NSAppleScript executeAppleEvent] to wait for script to complete?
H, my NSAppleScript Class Reference documentation does not list any such method. It does list -executeAppleEvent:error: and - executeAndReturnError:, both of which return The result of executing the event, which implies that they must wait for the script to complete. Ha ha, yes, executeAppleEvent does wait for completion! My applescript was generating an error and stopping, so it appeared that executeAE was returning without blocking. Thanks. Sean DeNigris s...@clipperadams.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Can I tell [NSAppleScript executeAppleEvent] to wait for script to complete?
When I use [NSAppleScript executeAppleEvent] to call handlers in a compiled script, it returns immediately. Is there a way to get it to block until the script is finished? Maybe there a notification I can listen for? Thanks! Sean DeNigris s...@clipperadams.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSUserDefault and Negative numerical arguments (Was: Posting mouse clicks with multiple displays)
In main.m: NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; int x = [args integerForKey:@x]; int y = [args integerForKey:@y]; If the command line is MyApp -x -100 -y 100, NSUserDefaults does not recognize the -100 as the value of the x argument - it sets x to 0. If the '-' is removed, everything is fine. Is this a bug? Is there a way around? Yes-- -100 is parsed as an argument, not as a value to the previous argument. So, no, it isn't a bug. It is behaving correctly, for some values of correct. Welcome to shell programming the interface between shell process. Fragile space. Coder beware. I consider that if a negative number is a valid value for an option, and NSUserDefaults can not handle them, and this restriction is not documented, then it's a bug. Non-bug options would be: a) handle negative arguments correctly b) restrict numerical arguments to positive values and document this restriction The behavior of the object does not match the spec. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSUserDefault and Negative numerical arguments (Was: Posting mouse clicks with multiple displays)
What Alastar said; you have free reign over argv/argc prior to calling NSApplicationMain(). Duh! You're right, I will just process them myself! I don't know why I was so attached to making NSUserDefaults do what I wanted it too - probably lack of sleep and frustration with the documentation. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSUserDefault and Negative numerical arguments (Was: Posting mouse clicks with multiple displays)
When using NSUserDefaults to get command line arguments, it doesn't seem to handle negative numbers correctly. In main.m: NSUserDefaults *args = [NSUserDefaults standardUserDefaults]; int x = [args integerForKey:@x]; int y = [args integerForKey:@y]; If the command line is MyApp -x -100 -y 100, NSUserDefaults does not recognize the -100 as the value of the x argument - it sets x to 0. If the '-' is removed, everything is fine. Is this a bug? Is there a way around? Thanks again! Sean DeNigris s...@clipperadams.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com