Module: ObjC

The ObjC module contains the main elements of RubyObjC, a bridge connecting the Ruby and Objective-C programming languages. RubyObjC allows code written in Ruby and Objective-C to be easily mixed, yielding software implementations that exploit the strengths of both languages.


Child modules and classes

Class ObjC::Class
Class ObjC::Function
Class ObjC::Method
Class ObjC::NSArray
Class ObjC::NSDictionary
Class ObjC::NSObject
Class ObjC::Object
Class ObjC::Variable

Constants

NameValueDescription
Ready Qtrue

Public Class methods

add_constant (p1, p2)

Add a symbolic constant to the ObjC module by importing the value corresponding to the specified symbol p1 and type p2. This method is typically used to wrap code that is not written in Objective-C.

add_enum (p1, p2)

Add an integer constant to the ObjC module with the specified name p1 and value p2. This method is typically used to wrap code that is not written in Objective-C.

add_function (p1)

Add an ObjC::Function p1 to the ObjC module as a module function. The module function will have the same name as the ObjC::Function. This method is typically used to wrap code that is not written in Objective-C.

copyright ()

Get a string describing the RubyObjC copyright.

external_resource_path ()

Get the path to the directory that contains the application (Cocoa-specific). This method is typically called from a Cocoa application‘s main.rb file.

get_methods ()

Get a hash containing the methods currently known to the Objective-C runtime. This method exhaustively scans the classes and methods in the Objective-C runtime and is surprisingly fast.

get_signature_for_selector (selector)

Get the signature for a given selector from the Objective-C runtime.

get_signatures ()

Get a hash containing the method signatures currently known to the Objective-C runtime. This method exhaustively scans the classes and methods in the Objective-C runtime and is surprisingly fast.

import (*names)

Import an Objective-C class for use in Ruby code. In most cases, this is done automatically. A NameError is raised if no corresponding Objective-C class can be found.

internal_resource_path ()

Get the path to an application‘s internal Resource directory (Cocoa-specific). This method is typically called from a Cocoa application‘s main.rb file.

load_all_files (path, except_this_file=nil)

Load all files in the specified directory (Cocoa-specific). This method is typically called from a Cocoa application‘s main.rb file.

load_external_files ()

Load all Ruby files in same directory as the application.

load_internal_files (except_this_file="main.rb")

Load all Ruby files in the application directory, with the exception of the specified file (typically main.rb).

log (p1)

Write a message p1 to the bridge logfile.

objc_method_calls ()

When Objective-C method call tracking is enabled, this returns a hash containing ObjC::Method objects as keys and the number of times each method has been called from Ruby since tracking was enabled.

objc_method_tracking ()

Determine whether or not Objective-C method call tracking is enabled.

objc_method_tracking= (p1)

Control tracking of Objective-C method calls. Set to true to enable tracking.

objc_to_ruby_calls ()

Get the number of times Ruby code has been called from Objective-C.

require (...)

Load one or more built-in RubyObjC components. Possible values include Foundation, AppKit, console, menu, nibtools. This method is typically called from a Cocoa application‘s main.rb file to load optional components. Component names can be given as Ruby strings or symbols and are case-insensitive.

ruby_to_objc_calls ()

Get the number of times Objective-C code has been called from Ruby.

set_path (p1)

Set the Ruby search path to be used by the application. Possible values are :LOCAL (to use the search path of the locally-installed ruby), :INTERNAL (to limit the search to the application‘s Resource directory), or a Ruby array of path names to use as the search path. This should be called at the beginning of any RubyObjC Cocoa application; it should typically be the first statement in the application‘s main.rb file.

strict= (strict)

Controls the enforcement of imethod/cmethod semantics. When true, the ObjC::Object method_added callback is disabled and methods are not automatically added to the Objective-C runtime. Instead, they must be declared with imethod (for instance methods) or cmethod (for class methods). When false, method_added attempts to expose all new methods to Objective-C. The default value is true.

top_methods (n = 10)

Get the n Objective-C methods that have been most frequently called from Ruby. Returns a list of lists. Each inner list contains the number of calls, the method, and the method signature. Objective-C method call tracking must be enabled.

top_signatures (n = 10)

Get the n Objective-C method signatures that have been most frequently called from Ruby. Returns a list of lists. Each inner list contains the number of calls and the method signature. Objective-C method call tracking must be enabled.

verbose ()

Get the verbosity of the ObjC module.

verbose= (p1)

Control the verbosity of the ObjC module. Set p1 to non-nil to generate logging messages.