Add method comment
This commit is contained in:
parent
353986763c
commit
74dc09dda8
1 changed files with 5 additions and 0 deletions
|
@ -97,10 +97,15 @@ pub const Object = struct {
|
||||||
c.object_setIvar(self.value, ivar, val.value);
|
c.object_setIvar(self.value, ivar, val.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// In MacOS SDK, the memory is managed by ARC(Automatic Reference Counting).
|
||||||
|
/// Therefore, it not must retain an object explictlly.
|
||||||
|
/// But if you'd like to keep reference of objc object in ziglang-side, it could use this method to avoid releqsing object by ARC.
|
||||||
pub fn retain(self: Object) Object {
|
pub fn retain(self: Object) Object {
|
||||||
return fromId(objc_retain(self.value));
|
return fromId(objc_retain(self.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// if you have use the retain method, you must call the release method.
|
||||||
|
/// Otherwise, a memory leak will occur.
|
||||||
pub fn release(self: Object) void {
|
pub fn release(self: Object) void {
|
||||||
objc_release(self.value);
|
objc_release(self.value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue