snipt

Ctrl+h for KB shortcuts

Objective-C

Stopping an NSTimer

1
2
3
4
5
6
7
if (timer !=nil) {
		//stop the timer when the meeting has ended
		[timer invalidate];
		[timer release];
		timer = nil;
	}
	
https://snipt.net/embed/15542fbeb4cb7a1362ebc97d68c1bb9c/
https://snipt.net/raw/15542fbeb4cb7a1362ebc97d68c1bb9c/
15542fbeb4cb7a1362ebc97d68c1bb9c
objective-c
Objective-C
7
2016-09-27T12:46:48
True
False
False
/api/public/snipt/24451/
stopping-an-nstimer
<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 id="L-1"><a name="L-1"></a><span class="k">if</span> <span class="p">(</span><span class="n">timer</span> <span class="o">!=</span><span class="nb">nil</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="c1">//stop the timer when the meeting has ended</span> </span><span id="L-3"><a name="L-3"></a> <span class="p">[</span><span class="n">timer</span> <span class="n">invalidate</span><span class="p">];</span> </span><span id="L-4"><a name="L-4"></a> <span class="p">[</span><span class="n">timer</span> <span class="k">release</span><span class="p">];</span> </span><span id="L-5"><a name="L-5"></a> <span class="n">timer</span> <span class="o">=</span> <span class="nb">nil</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="p">}</span> </span><span id="L-7"><a name="L-7"></a> </span></pre></div> </td></tr></table>
core, timers

Objective-C

Handling a method invoked from an NSTimer

1
2
3
4
//handing a method invoked from an NSTimer
- (void)simulateTimeProgress:(NSTimer *)aTimer{
	
}
https://snipt.net/embed/08ae441a19be5780902a568be221f358/
https://snipt.net/raw/08ae441a19be5780902a568be221f358/
08ae441a19be5780902a568be221f358
objective-c
Objective-C
5
2016-09-26T19:31:22
True
False
False
/api/public/snipt/24450/
handling-a-method-invoked-from-an-nstimer
<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></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c1">//handing a method invoked from an NSTimer</span> </span><span id="L-2"><a name="L-2"></a><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">simulateTimeProgress:</span><span class="p">(</span><span class="bp">NSTimer</span> <span class="o">*</span><span class="p">)</span><span class="nv">aTimer</span><span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
core, timers

Objective-C

Activating the OS network activity spinner control

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
https://snipt.net/embed/d3828173ec9955bd40cd2f07a911603a/
https://snipt.net/raw/d3828173ec9955bd40cd2f07a911603a/
d3828173ec9955bd40cd2f07a911603a
objective-c
Objective-C
2
2016-09-22T00:46:49
True
False
False
/api/public/snipt/24346/
activating-the-os-network-activity-spinner-control
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="p">[</span><span class="bp">UIApplication</span> <span class="n">sharedApplication</span><span class="p">].</span><span class="n">networkActivityIndicatorVisible</span> <span class="o">=</span> <span class="nb">NO</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a><span class="p">[</span><span class="bp">UIApplication</span> <span class="n">sharedApplication</span><span class="p">].</span><span class="n">networkActivityIndicatorVisible</span> <span class="o">=</span> <span class="nb">YES</span><span class="p">;</span> </span></pre></div> </td></tr></table>
controllers, core, layout

Objective-C

Processing the elapse time of a method call

1
2
3
4
5
6
7
//process the elapse time
			NSTimeInterval start = CFAbsoluteTimeGetCurrent();
			
			//process image item detail
			[targetDrawView processImageItem:s.imageid];
			
			NSLog(@"It took %f seconds", CFAbsoluteTimeGetCurrent() - start);
https://snipt.net/embed/72fabe1657c9b97099a26e87a2839226/
https://snipt.net/raw/72fabe1657c9b97099a26e87a2839226/
72fabe1657c9b97099a26e87a2839226
objective-c
Objective-C
8
2016-09-22T00:44:13
True
False
False
/api/public/snipt/24337/
processing-the-elapse-time-of-a-method-call
<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 id="L-1"><a name="L-1"></a><span class="c1">//process the elapse time</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">NSTimeInterval</span> <span class="n">start</span> <span class="o">=</span> <span class="n">CFAbsoluteTimeGetCurrent</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a> <span class="c1">//process image item detail</span> </span><span id="L-5"><a name="L-5"></a> <span class="p">[</span><span class="n">targetDrawView</span> <span class="nl">processImageItem</span><span class="p">:</span><span class="n">s</span><span class="p">.</span><span class="n">imageid</span><span class="p">];</span> </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a> <span class="n">NSLog</span><span class="p">(</span><span class="s">@&quot;It took %f seconds&quot;</span><span class="p">,</span> <span class="n">CFAbsoluteTimeGetCurrent</span><span class="p">()</span> <span class="o">-</span> <span class="n">start</span><span class="p">);</span> </span></pre></div> </td></tr></table>
core, performance
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.