Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Objective-C

Importing Header Files

1
2
3
4
5
6
7
// In MyClass.h
// reserve room to a pointer to LibraryClass
@class LibraryClass;

// In MyClass.m
// Makes members of LibraryClass known and accessible in MyClass
#import "LibraryClass.h";
https://snipt.net/embed/2885301a1662106ccee3a3a0c27a21a1/
https://snipt.net/raw/2885301a1662106ccee3a3a0c27a21a1/
2885301a1662106ccee3a3a0c27a21a1
objective-c
Objective-C
7
2016-11-29T22:57:44
True
False
False
/api/public/snipt/39799/
importing-header-files
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// In MyClass.h</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">// reserve room to a pointer to LibraryClass</span> </span><span id="L-3"><a name="L-3"></a><span class="k">@class</span> <span class="nc">LibraryClass</span>; </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c1">// In MyClass.m</span> </span><span id="L-6"><a name="L-6"></a><span class="c1">// Makes members of LibraryClass known and accessible in MyClass</span> </span><span id="L-7"><a name="L-7"></a><span class="cp">#import &quot;LibraryClass.h&quot;;</span> </span></pre></div> </td></tr></table>
objective-c

Objective-C

Global Constants II

1
2
3
4
5
6
7
// GlobalConst.h
extern NSString * const MyFirstConstant;
extern int const myVal;

// GlobalConst.m
NSString * const MyFirstConstant = @"FirstConstant";
int const myVal = 110;
https://snipt.net/embed/20804cd36d773b1cfda87731c05b5130/
https://snipt.net/raw/20804cd36d773b1cfda87731c05b5130/
20804cd36d773b1cfda87731c05b5130
objective-c
Objective-C
7
2016-11-27T20:45:46
True
False
False
/api/public/snipt/39797/
global-constants-ii
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// GlobalConst.h</span> </span><span id="L-2"><a name="L-2"></a><span class="k">extern</span> <span class="bp">NSString</span> <span class="o">*</span> <span class="k">const</span> <span class="n">MyFirstConstant</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">extern</span> <span class="kt">int</span> <span class="k">const</span> <span class="n">myVal</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c1">// GlobalConst.m</span> </span><span id="L-6"><a name="L-6"></a><span class="bp">NSString</span> <span class="o">*</span> <span class="k">const</span> <span class="n">MyFirstConstant</span> <span class="o">=</span> <span class="s">@&quot;FirstConstant&quot;</span><span class="p">;</span> </span><span id="L-7"><a name="L-7"></a><span class="kt">int</span> <span class="k">const</span> <span class="n">myVal</span> <span class="o">=</span> <span class="mi">110</span><span class="p">;</span> </span></pre></div> </td></tr></table>
objective-c

Objective-C

Global Constants

1
2
3
4
5
6
7
8
// Define in GlobalConst.h
#define PREFS_MY_CONSTANT @"prefs_my_constant"

// Import in MyClass.m
#import "GlobalConst.h"

// Use in MyClass.m
NSLog(@"%@",PREFS_MY_CONSTANT);
https://snipt.net/embed/2f0efcbe16c741b3376669216adc2387/
https://snipt.net/raw/2f0efcbe16c741b3376669216adc2387/
2f0efcbe16c741b3376669216adc2387
objective-c
Objective-C
8
2016-12-01T04:17:42
True
False
False
/api/public/snipt/39796/
global-constants
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// Define in GlobalConst.h</span> </span><span id="L-2"><a name="L-2"></a><span class="cp">#define PREFS_MY_CONSTANT @&quot;prefs_my_constant&quot;</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">// Import in MyClass.m</span> </span><span id="L-5"><a name="L-5"></a><span class="cp">#import &quot;GlobalConst.h&quot;</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="c1">// Use in MyClass.m</span> </span><span id="L-8"><a name="L-8"></a><span class="n">NSLog</span><span class="p">(</span><span class="s">@&quot;%@&quot;</span><span class="p">,</span><span class="n">PREFS_MY_CONSTANT</span><span class="p">);</span> </span></pre></div> </td></tr></table>
objective-c

Bash

ocrunner verbose

ocrunner -v -s macosx10.6
https://snipt.net/embed/991d64391c1dd3f94ebec02ee97aa993/
https://snipt.net/raw/991d64391c1dd3f94ebec02ee97aa993/
991d64391c1dd3f94ebec02ee97aa993
bash
Bash
1
2016-12-02T11:37:48
True
False
False
/api/public/snipt/24140/
ocrunner-verbose
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>ocrunner -v -s macosx10.6 </span></pre></div> </td></tr></table>
objective-c, ocrunner
Copyrighted, illegal, or inappropriate content? Email [email protected].