# objc

Send Objective-C messages. Installed by the `ffi` capability on the **cocos (Cocotron) builds — iOS and Android**. The Miniclip cocos titles run a Cocotron Objective-C runtime on Android too, so the runtime functions resolve on both. On non-cocos games (il2cpp/Unity, e.g. Mobile Legends) `objc` is `nil` and not installed. arm64.

#### objc.class

`objc.class(name: string)`: pointer|nil

Returns the Class object for `name`, or nil.

#### objc.object

`objc.object(p: pointer|integer)`: object

Wraps an `id` as an object userdata.

#### objc.selector

`objc.selector(name: string)`: integer

Returns the `SEL` for `name`. Rarely needed; `obj:msg` takes a selector string directly.

## object userdata

#### obj:msg

`obj:msg(selector: string, signature: string, ...)`: any

Argument | Type | Description
-------- | ---- | -----------
  **selector** | string | The Objective-C selector, e.g. `"setHidden:"`.
  **signature** | string | The [ffi](/base/ffi/) signature of the method **without** self/`_cmd`, e.g. `"v(b)"`.
  **...** |  | The arguments.

Sends `selector` to the object through `objc_msgSend`, marshalling `self` and `_cmd` for you. Return typed as in `ffi.call`.

Method | Returns | Description
--- | --- | ---
`obj:class()` | pointer | The object's class.
`obj:class_name()` | string | The class name.
`obj:responds(selector)` | boolean | Whether the object responds to a selector.
`obj.pointer` | pointer | The underlying `id`. `tostring(obj)` is its address.

```lua
-- hide a UIView-like object
local view = objc.object(some_pointer)
view:msg("setHidden:", "v(b)", true)
```