Skip to content

Commit

Permalink
Add msg_super usage note.
Browse files Browse the repository at this point in the history
  • Loading branch information
dboris committed May 26, 2024
1 parent 729be82 commit 730a131
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ constructs by comparing the equivalent Objective-C and OCaml code.

* Defining a new Cocoa class

Objective-C:
```objective-c
@interface MyClass : NSObject {
id myVar;
Expand Down Expand Up @@ -154,7 +155,10 @@ constructs by comparing the equivalent Objective-C and OCaml code.
]
```

**_NOTE:_** If your method does not accept arguments, the `~args` parameter
**_NOTE:_**
The `~args` parameter includes only the explicit argument types.
The number of arguments is the same as the number of `:` in the selector.
If your method does not accept arguments, the `~args` parameter
looks like this: `Objc_t.[]`

* Memory management
Expand Down Expand Up @@ -184,6 +188,30 @@ constructs by comparing the equivalent Objective-C and OCaml code.
an_instance |> msg_send (selector "anArbitrarySelector") ~args: Objc_t.[] ~return: Objc_t.void
```

* Sending a message to the superclass

Eg, `viewDidLoad`:

Objective-C:
```objective-c
- (void)viewDidLoad {
[super viewDidLoad]
...
}
```
OCaml:
```OCaml
let viewDidLoad self cmd =
self |> msg_super cmd ~args: Objc_t.[] ~return: Objc_t.void;
...
```

**_NOTE:_**
Method implementations in OCaml always include two implicit parameters:
self - a pointer to the object;
cmd - the current selector

## Documentation

At this time, the documentation of the project is lacking. The framework
Expand Down

0 comments on commit 730a131

Please sign in to comment.