Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Objective-C, just like in C, <code>&amp;</code> is the "address-of operator" and it returns the address of its argument. To find out more about it, I recommend you read <a href="http://publications.gbdirect.co.uk/c_book/chapter5/arrays_and_address_of.html" rel="nofollow">this short chapter</a> from The C Book.</p> <p>Here's an example of how the operator is used, to get a better idea:</p> <pre><code>#include &lt;stdio.h&gt; // define a function that takes a pointer to an integer as argument void change_value_of_int(int* int_to_change) { // change the value to which the argument points *int_to_change = 5; } int main() { // create a stack variable int test_int = 10; // pass the address of test_int to the function defined earlier change_value_of_int(&amp;test_int); // now the value of test_int is 5 printf("%d\n", test_int); return 0; } </code></pre> <p>Note that the <code>change_value_of_int()</code> function expects the first parameter to be a <em>pointer</em> to an int, not an int, so you can't call it with <code>change_value_of_int(test_int)</code>. You must send it the <em>address</em> of the <code>test_int</code> variable, not the variable itself (because if you send a copy of the variable, it can't change it).</p> <p>Same thing with the <code>NSError*</code> example. <code>jsonParser</code> expects the <em>address</em> of a <code>NSError*</code>, not a <code>NSError*</code>, therefore the method is defined as:</p> <pre><code>- (id)objectWithString:(NSString*)jsonrep error:(NSError**)error; </code></pre> <p>Take a look at <a href="http://code.google.com/p/json-framework/source/browse/trunk/Source/SBJSON.h?r=549#51" rel="nofollow">the header file</a> and at <a href="http://code.google.com/p/json-framework/source/browse/trunk/Source/SBJSON.m?r=549#82" rel="nofollow">the implementation</a> to see how it is used. The value of your <code>error</code> (<code>*error</code> = the value of the thing pointed to by the <code>error</code> argument) becomes the return value of <code>[errorTrace lastObject]</code>.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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