Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You cannot use <code>NSArray</code> unless the Objective-C code uses <code>NSArray</code>, i.e. the generator allows us to map some ObjC constructs to .NET types (e.g. <code>NSString</code> to <code>string</code>) but it won't allow you to redefine ObjC types.</p> <pre><code>-(BOOL)playSound:(int)volume beepData:(int *)data length:(int)length error:(NSError **)error; </code></pre> <p>should be like:</p> <pre><code>[Export ("playSound:beepData:length:error:")] bool PlaySound (int volume, IntPtr data, int length, out NSError error); </code></pre> <p>You'll need to marshal your <code>data</code> into an <code>IntPtr</code>.</p> <pre><code>IntPtr data = Marshal.AllocHGlobal (length); Marshal.WriteInt32 (data1, 0); </code></pre> <p>and free it afterward.</p> <pre><code>Marshal.FreeHGlobal (data); </code></pre> <p>That's best done using a public helper method which calls your <strong>internal</strong> binding. You can make the <code>PlaySound</code> method <code>internal</code> by adding a <code>[Internal]</code> attribute to it's definition. So it becomes:</p> <pre><code>[Export ("playSound:beepData:length:error:")][Internal] bool PlaySound (int volume, IntPtr data, int length, out NSError error); </code></pre> <p>and you include the following code with your bindings (e.g. API.cs):</p> <pre><code>bool PlaySound (int volume, int[] data) { // I assume length is byte-based (check the docs) int length = data.Length * 4; IntPtr p = Marshal.AllocHGlobal (length); int j = 0; for (int i=0; i &lt; length; i+=4) Marshal.WriteInt32 (p [j++], i); NSError error; bool result = PlaySound (volume, p, length, out error); // free memory before throwing the exception (if any) Marshal.FreeHGlobal (data); if (error != null) throw new Exception (error.LocalizedDescription); return result; } </code></pre> <p>note: totally untried :-) I do not have the hardware, SDK or documentation. YMMV but that should be close.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload