summaryrefslogtreecommitdiff
path: root/frontends/cocoa/arc.h
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/cocoa/arc.h')
-rw-r--r--frontends/cocoa/arc.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/frontends/cocoa/arc.h b/frontends/cocoa/arc.h
new file mode 100644
index 000000000..bfdf31c5c
--- /dev/null
+++ b/frontends/cocoa/arc.h
@@ -0,0 +1,22 @@
+#ifndef arc_h
+#define arc_h
+
+/**
+ * Retains an Objective-C object and returns a pointer that can be passed to C.
+ * @param object The object to retain
+ * @return Pointer suitable to be stored in C code.
+ */
+static inline void *arc_retain(id object) {
+ return (__bridge_retained void *)object;
+}
+
+/**
+ * Releases the Objective-C object pointed to by a C pointer.
+ * @param pointer Object pointer to release.
+ */
+static inline void arc_release(void *pointer) {
+ id object = (__bridge_transfer id)pointer;
+ object = nil;
+}
+
+#endif