macruby

MacRuby custom initializers

空扰寡人 提交于 2020-01-06 15:31:50
问题 Just discovered MacRuby this afternoon; man is that ever COOL! However, I've run into some difficulties while attempting to extend an old project with some MacRuby-fu. Here's the deal: So I have a superclass in Objective-C that looks like this: @implementation Foo - (id) init { if (self = [super init]) { //Do nothing, don't have enough data... } return self; } - (id) initWithName:(NSString*)n andLocation:(NSString*)loc andSomethingElse:(Bar*)b { if (self = [super init]) { //Set a LOT of

MacRuby pointer, referencing, dereferencing when using Cocoa Frameworks

烂漫一生 提交于 2020-01-05 01:07:38
问题 On MacRuby Pointer to typedef struct, I learnt how to dereference a pointer created with x=Pointer.new_with_type ... ==> use x.value, or x[0] Works a treat ! Now I want to learn what I believe to be the "opposite". I'm trying to use this API. OSStatus SecKeychainCopySettings ( SecKeychainRef keychain, SecKeychainSettings *outSettings ); Second parameter must be a Pointer. But I never manage to get the real outSettings of the keychain opened, I only get the default settings. framework

When a cocoa method wants a selector as a parameter, how do I express this in ruby?

喜你入骨 提交于 2019-12-24 20:27:04
问题 In this tutorial for sheet programming in cocoa, I am told to invoke the following method: [[alert beginSheetModalForWindow:[searchField window] modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil]; I have written this as follows in ruby, alert.beginSheetModalForWindow(self.window, modalDelegate:self, didEndSelector: :alertDidEnd, contextInfo:nil) Of course, the didEndSelector part is wrong. Later in my code I have a method alertDidEnd, which takes

No input to NSTextField when running macruby

陌路散爱 提交于 2019-12-24 00:47:17
问题 i have a simple macruby application and i want to get some user-input via a NSTextField, but when i run the application with '''macruby test.rb''' all the input on the focused text-field goes into the bash. is there something that i need to set, to get the input into the text-field? # test.rb framework 'AppKit' application = NSApplication.sharedApplication frame = [0.0, 0.0, 300, 200] window = NSWindow.alloc.initWithContentRect(frame, styleMask: NSTitledWindowMask | NSClosableWindowMask,

Is it possible to reduce the startup time of MacRuby scripts which use the ScriptingBridge?

痞子三分冷 提交于 2019-12-23 04:19:35
问题 I would like to use MacRuby with ScriptingBridge instead of AppleScript to control Mac applications which support AppleScript. I used to do this using appscript, which is effectively deprecated, hence the move the MacRuby and scripting bridge. The only problem I have is that the ScriptingBridge framework takes about a second to load, even on a fast machine with a fast SSD. For example, this simple script takes about 0.9 seconds to run, with almost of the time spend loading the ScriptingBridge

How can I discover what apps are installed on OS X using Objective C or Macruby?

左心房为你撑大大i 提交于 2019-12-18 13:31:56
问题 could you tell me please - which object and which method can i use to fetch information about installed applications on OSX with objective c or macruby? 回答1: You can just call the Apple command-line tool system_profiler , e.g. % system_profiler SPApplicationsDataType For C or Objective-C you could use system() to do this. For more info: % man system % man system_profiler 回答2: If you meant to list all of GUI apps, you can use Launch Services. For the list of functions, see the reference. Do

Getting source HTML from a WebView in Cocoa

徘徊边缘 提交于 2019-12-18 13:25:37
问题 I'm working on a OS X program where the user does some light WYSIWYG HTML editing in a WebView. Being new to programming with Cocoa and WebKit, I have absolutely no idea how to get selected text from a WebView - the intention being to take what the user selected, add HTML code (like div's or span's) around the text, and replace the selected text with the modified code. How can this be accomplished? I'm currently programming this project with MacRuby, but I'd appreciate help from Objective-C

Should I learn MacRuby or RubyCocoa [closed]

无人久伴 提交于 2019-12-18 12:15:50
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I am wanting to learn mac development with ruby but I'm not sure which one to go at. RubyCocoa has been around longer but I think

Simple persistence framework compatible with macruby?

蓝咒 提交于 2019-12-13 13:23:14
问题 I'm running into problems using macruby with ActiveRecord (w/ sqlite3) or Sequel. Any other suggestions? I need a simple lightweight persistence mechanism to embed within my application that can handle less than 5 tables and at most low tens of thousands of rows. 回答1: The following combination works: MacRuby 0.8 sqlite3-ruby gem 1.3.2 sequel gem 3.18.0 OSX 10.6.5 The trick was uninstalling the 'sqlite3' gem and installing 'sqlite3-ruby'. 回答2: This also works MacRuby 0.12 sqlite3-ruby gem 1.3

MacRuby Pointer to typedef struct

≡放荡痞女 提交于 2019-12-13 03:41:52
问题 this code fails with Semgentation Fault: 11, and I can't understand why framework 'Cocoa' framework 'CoreFoundation' framework 'Security' * keychainObject = Pointer.new_with_type('^{OpaqueSecKeychainRef}') SecKeychainOpen("/Users/charbon/Library/Keychains/Josja.keychain",keychainObject) SecKeychainLock(keychainObject) I'm sure it has to do with the keychainObject type, because this works (it locks the default keychain). SecKeychainLock(nil) I'm using the '^{OpaqueSecKeychainRef}' as the type