Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Apologies if I'm oversimplifying your question, but are you asking how to define an Objective-C method? If so, you're going to have to learn Objective-C, there's no way around it:</p> <p><a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html#//apple_ref/doc/uid/TP30001163-CH1-SW2" rel="noreferrer">The Objective-C Programming Language</a> - <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-SW5" rel="noreferrer">Object Messaging</a></p> <p>You can do a lot of great things with no code on the iPhone and Mac platforms, but it's hard to imagine completing any useful application without writing <em>some</em> code.</p> <p><strong>Example</strong></p> <pre><code>- (float)multiplyThisFloatByTwoPointFive:(float)numberToMultiply { return numberToMultiply * 2.5; } </code></pre> <p>To call it:</p> <pre><code>[self multiplyThisFloatByTwoPointFive:3.7]; </code></pre> <p><strong>Libraries</strong></p> <p>If you mean "I want to put these non-class-specific methods somewhere I can access them universally", eg, a library, you can do this in two ways:</p> <ol> <li>Create some sort of "library" class like "MySpecialMathClass" (not to be confused with "my special education math class") or "MyAppAnimationTricks" and put your methods there (you'd define them as +someMethod: not -someMethod:, class- not instance-method, per Objective-C).</li> <li>If they only ever deal with primitives (such as int, float, double ...), consider just making them C functions, rather than Objective-C methods.</li> </ol>
    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