summaryrefslogtreecommitdiff
path: root/Runtime/Export/iOS/CocoaIntegration.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Export/iOS/CocoaIntegration.cs
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/Export/iOS/CocoaIntegration.cs')
-rw-r--r--Runtime/Export/iOS/CocoaIntegration.cs89
1 files changed, 89 insertions, 0 deletions
diff --git a/Runtime/Export/iOS/CocoaIntegration.cs b/Runtime/Export/iOS/CocoaIntegration.cs
new file mode 100644
index 0000000..dea1431
--- /dev/null
+++ b/Runtime/Export/iOS/CocoaIntegration.cs
@@ -0,0 +1,89 @@
+#if UNITY_IPHONE_API
+
+using System;
+using System.Collections;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace UnityEngine
+{
+public sealed partial class iPhone
+{
+ [System.Runtime.InteropServices.DllImport("__Internal")]
+ internal static extern void UnityNSObject_RetainObject(IntPtr obj);
+
+ [System.Runtime.InteropServices.DllImport("__Internal")]
+ internal static extern void UnityNSObject_ReleaseObject(IntPtr obj);
+
+ public sealed partial class NSError
+ {
+ [System.Runtime.InteropServices.DllImport("__Internal")]
+ private static extern int UnityNSError_Code(IntPtr errorObj);
+
+ [System.Runtime.InteropServices.DllImport("__Internal")]
+ private static extern IntPtr UnityNSError_Description(IntPtr errorObj);
+
+ [System.Runtime.InteropServices.DllImport("__Internal")]
+ private static extern IntPtr UnityNSError_Reason(IntPtr errorObj);
+
+
+ private IntPtr _nativeError;
+ private NSError(IntPtr nativeError)
+ {
+ _nativeError = nativeError;
+ UnityNSObject_RetainObject(_nativeError);
+ }
+ ~NSError()
+ {
+ UnityNSObject_ReleaseObject(_nativeError);
+ }
+
+ public static NSError CreateNSError(IntPtr nativeError)
+ {
+ return nativeError == IntPtr.Zero ? null : new NSError(nativeError);
+ }
+
+ public int code
+ {
+ get { return UnityNSError_Code(_nativeError); }
+ }
+ public string description
+ {
+ get { return Marshal.PtrToStringAnsi(UnityNSError_Description(_nativeError)); }
+ }
+ public string reason
+ {
+ get { return Marshal.PtrToStringAnsi(UnityNSError_Reason(_nativeError)); }
+ }
+ }
+
+ public sealed partial class NSNotification
+ {
+ [System.Runtime.InteropServices.DllImport("__Internal")]
+ private static extern IntPtr UnityNSNotification_Name(IntPtr notificationObj);
+
+ private IntPtr _nativeNotification;
+ private NSNotification(IntPtr nativeNotification)
+ {
+ _nativeNotification = nativeNotification;
+ UnityNSObject_RetainObject(_nativeNotification);
+ }
+ ~NSNotification()
+ {
+ UnityNSObject_ReleaseObject(_nativeNotification);
+ }
+
+ public static NSNotification CreateNSNotification(IntPtr nativeNotification)
+ {
+ return nativeNotification == IntPtr.Zero ? null : new NSNotification(nativeNotification);
+ }
+
+ public string name
+ {
+ get { return Marshal.PtrToStringAnsi(UnityNSNotification_Name(_nativeNotification)); }
+ }
+ }
+}
+}
+
+#endif