<?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>The Cocoa Magazine</title>
	<atom:link href="http://thecocoamag.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://thecocoamag.com</link>
	<description>Written by and for the iOS &#38; Mac Developer Community</description>
	<lastBuildDate>Sun, 26 Jun 2011 23:16:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Recipe: Obj-C Message Tracing</title>
		<link>http://thecocoamag.com/?p=131</link>
		<comments>http://thecocoamag.com/?p=131#comments</comments>
		<pubDate>Fri, 24 Jun 2011 08:00:26 +0000</pubDate>
		<dc:creator>Allen Ding</dc:creator>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[June]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=131</guid>
		<description><![CDATA[Motivation In a non-trivial application, wrapping your head around interactions between components in your codebase can be difficult. For example, consider delegation via formal protocols, a pattern that is pervasive in iOS frameworks. The interaction protocols for objects connected through delegation often involve numerous and layered sequences of method calls going back and forth between [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Motivation</strong></p>
<p>In a non-trivial application, wrapping your head around interactions between components in your codebase can be difficult. For example, consider delegation via formal protocols, a pattern that is pervasive in iOS frameworks. The interaction protocols for objects connected through delegation often involve numerous and layered sequences of method calls going back and forth between an object and its delegate. Though the iOS API documentation is generally excellent, a visual trace of the messages that are being sent can be very instructive.<br />
In this article, we will take a look at some simple utility code that may assist you in understanding such interactions during your own development. This utility code behaves is as simple  to use as NSLog, but with the addition that logged output will be shown with visual indentation that makes it easy to understand the message context in which the logging is taking place.</p>
<p><strong>Result Preview</strong></p>
<p>To start off with, let&#8217;s take a look at some sample usage and console output (timestamps have been omitted).</p>
<pre class="brush: objc; title: ; notranslate">
//--- Sample usage begin ---
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
TCM_TRACE_BEGIN();
static NSString *CellIdentifier = @&quot;Cell&quot;;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
TCM_TRACE(@&quot;Created cell&quot;);
}
cell.textLabel.text = [NSString stringWithFormat:@&quot;Row %d&quot;, indexPath.row];
// Configure the cell.
return cell;
TCM_TRACE_END();
}
//--- Sample usage ends ---
//--- Sample output begins ---
-[TCMTraceAppDelegate application:didFinishLaunchingWithOptions:]
-[RootViewController shouldAutorotateToInterfaceOrientation:]
-[RootViewController shouldAutorotateToInterfaceOrientation:]
-[RootViewController viewDidLoad]
-[RootViewController viewWillAppear:]
-[RootViewController numberOfSectionsInTableView:]
-[RootViewController shouldAutorotateToInterfaceOrientation:]
-[RootViewController viewDidAppear:]
-[RootViewController numberOfSectionsInTableView:]
-[RootViewController tableView:numberOfRowsInSection:]
-[RootViewController tableView:cellForRowAtIndexPath:]
Created cell
//--- Sample output ends ---
</pre>
<p>The output above shows the messages sent by UIKit to a couple delegate objects (TCMTraceAppDelegate and RootViewController) when launching an app with a UITableView. The methods that end up in the log are those that we explicitly want to trace. Hopefully, you&#8217;ll agree that the visual trace makes the sequence and layering of calls made to the delegates easier to digest.</p>
<p>Here is more complex sample output obtained when running a modified version of the Core Data application template provided in the iOS 4.3 SDK.</p>
<pre class="brush: objc; title: ; notranslate">
//--- Sample output begins ---
-[CoreDataTracingAppDelegate awakeFromNib]
 -[CoreDataTracingAppDelegate managedObjectContext]
  -[CoreDataTracingAppDelegate persistentStoreCoordinator]
   -[CoreDataTracingAppDelegate managedObjectModel]
    Created managed object model
   Created persistent store coordinator
  Created managed object context
-[CoreDataTracingAppDelegate application:didFinishLaunchingWithOptions:]
  -[RootViewController shouldAutorotateToInterfaceOrientation:]
  -[RootViewController shouldAutorotateToInterfaceOrientation:]
  -[RootViewController viewDidLoad]
-[RootViewController viewWillAppear:]
    -[RootViewController numberOfSectionsInTableView:]
      -[RootViewController fetchedResultsController]
-[RootViewController shouldAutorotateToInterfaceOrientation:]
-[RootViewController viewDidAppear:]
-[RootViewController numberOfSectionsInTableView:]
-[RootViewController tableView:numberOfRowsInSection:]
-[RootViewController tableView:cellForRowAtIndexPath:]
  Created a cell
  -[RootViewController configureCell:atIndexPath:]

... (a cell was added here)

-[RootViewController insertNewObject]
  -[RootViewController controllerWillChangeContent:]
  -[RootViewController controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:]
    NSFetchedResultsChangeInsert
  -[RootViewController controllerDidChangeContent:]
    -[RootViewController numberOfSectionsInTableView:]
    -[RootViewController numberOfSectionsInTableView:]
    -[RootViewController tableView:numberOfRowsInSection:]
    -[RootViewController tableView:cellForRowAtIndexPath:]
      Created a cell
        -[RootViewController configureCell:atIndexPath:]

... (a cell was deleted here)

-[RootViewController tableView:commitEditingStyle:forRowAtIndexPath:]
    Deleted object
    -[RootViewController controllerWillChangeContent:]
    -[RootViewController controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:]
      NSFetchedResultsChangeDelete
  -[RootViewController controllerDidChangeContent:]
    -[RootViewController numberOfSectionsInTableView:]
    -[RootViewController numberOfSectionsInTableView:]
    -[RootViewController tableView:numberOfRowsInSection:]
//--- Sample output ends ---
</pre>
<p><strong>Implementation overview</strong></p>
<p>The mechanics of the implementation are trivial for the most part. We maintain a &#8220;trace depth&#8221; that is incremented when a method call we would like to trace is encountered and decremented at the end of the method. While logging, the current trace depth is used to properly format the output.</p>
<p>Every method we wish to trace will begin with TCM_TRACE_BEGIN() and must end with TCM_TRACE_END(). These paired macro statements will emit the current method&#8217;s name and set up a new log context for code executed within that method. We also have a macro called TCM_TRACE(format, …) for any additional log messages we would like to be output.</p>
<p>Additionally, let&#8217;s add the requirement that incorrectly paired TCM_TRACE_BEGIN() and TCM_TRACE_END() statements will not run so as to avoid unnoticed incorrect results. Implementing the TCM_TRACE_END() is slightly tricky because a method may have multiple return paths. We will engineer the solution so that missing this will result in a build error.</p>
<p>Having objects with automatic lifetimes and destructor calls as in (Objective) C++ is one solution, but we will keep our solution pure Objective-C. Luckily, Objective-C&#8217;s exception handling mechanism gives us what we need. TCM_TRACE_BEGIN() will expand to a dangling @try block that increments the trace depth and emits the current method. Similarly, TCM_TRACE_END() will close the previous @try block followed by a @finally block that ensures that decrements the trace depth. This approach takes care of the most common usage errors that might occur when using the macros. Yes, this is an abuse of the exception handling mechanism, but it does work rather well and should never be present in production code anyway.</p>
<p>The implementation of the actual logger class and some other housekeeping details are not particularly interesting and won&#8217;t be discussed here. Check the end of the article for the source.</p>
<p><strong>Notes</strong></p>
<p>You&#8217;ll notice that the implementation presented above expects the logging to be performed on a single thread. Extending it to be usable from multiple threads is possible, but I have never found a need to, and the interleaved output from multiple threads that might result would not be quite as useful for visualizing message traces. Note also that this isn&#8217;t actually an actual execution trace. For that, accessing the NSThread stack symbols API or using a tool like Instruments would be a better option.</p>
<p>Remember that behavior that is not explicitly specified in API documentation is behavior that is fair game for change later. You should never rely on observed behavior to infer guaranteed behavior of official APIs. The goal here was to develop a quick and dirty way of getting logging functionality to assist with comprehension and debugging. I personally find the most utility in this functionality when learning new APIs and quickly verifying expected interactions between my own classes.</p>
<p><strong>Files</strong></p>
<p>The files containing the implementation are TCMTrace(.h|.m).</p>
<p>The sample was developed in Xcode 4.0.1.<br />
<a href="https://github.com/allending/TCMTrace"> Simple sample project</a></p>
<p><a href="https://github.com/allending/CoreDataTrace">Core Datasample project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=131</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apress Book Excerpt &#8211; Building apps with Monotouch</title>
		<link>http://thecocoamag.com/?p=123</link>
		<comments>http://thecocoamag.com/?p=123#comments</comments>
		<pubDate>Fri, 24 Jun 2011 08:00:14 +0000</pubDate>
		<dc:creator>John W</dc:creator>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[Book Exerpt]]></category>
		<category><![CDATA[June]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=123</guid>
		<description><![CDATA[Our friends at Apress gave us a copy of &#8220;Developing C# Apps for iPhone and iPad Using MonoTouch&#8221; to include an excerpt in this month&#8217;s release. Take a look, and if you like it go buy the book. This excerpt is  the CoreGraphics and Core Animation chapters. Take a look. See what you think. [Download [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.apress.com/9781430231745"><img class="alignleft size-medium wp-image-124" title="JWilker" src="http://thecocoamag.com/wp-content/uploads/2011/06/JWilker-226x300.jpg" alt="" width="226" height="300" /></a>Our friends at Apress gave us a copy of &#8220;Developing C# Apps for iPhone and iPad Using MonoTouch&#8221; to include an excerpt in this month&#8217;s release. Take a look, and if you like it go <a href="http://www.apress.com/9781430231745">buy the book</a>.</p>
<p>This excerpt is  the CoreGraphics and Core Animation chapters. Take a look. See what you think.</p>
<p>[Download Ch 16: Drawing with CoreGraphics (PDF)]</p>
<p>[Download Ch 17: Core Animation (PDF)]</p>
<p><span id="more-123"></span><strong>Chapter 16: Drawing with CoreGraphics</strong></p>
<p style="padding-left: 30px;">Up until this point, any graphics we’ve drawn have been intrinsically handled by the controls we’ve used. For example, we’ve created plenty of buttons, but we’ve never had to draw them ourselves. Sometimes, however, we need to do custom drawing beyond what the controls offer out of the box. For example, let’s say that you want to build a view that has a rounded rectangle border. You could do this with images, but for maximum configurability, you could draw the lines and corners using CoreGraphics. That way, you could vary the radius of the corners, as well as the color and thickness of the lines, without having to do new images every time.</p>
<p style="padding-left: 30px;">We have several options to do custom drawing, including CoreGraphics, OpenGL, and the XNA Toolkit. CoreGraphics is the simplest option, as it is designed only for 2D drawing. We will explore CoreGraphics in this chapter.</p>
<p style="padding-left: 30px;">CoreGraphics is also known as the Quartz drawing system, as it inherits its design and functionality from the Quartz framework on the Mac OS.</p>
<p style="padding-left: 30px;">Entire books have been written on Quartz, and while this chapter will give a solid foundation on how to use CoreGraphics in MonoTouch, as well as introduce you to its common features, it is by no means exhaustive. The Quartz API is massive. Covering it in detail goes far beyond the scope of this book. With that said, however, if you’re looking for a more thorough reference once you’re through this chapter, check out <em>Apple’s Quartz 2D Programming Guide</em>. It’s part of the documentation that ships with the Xcode SDK, and is an invaluable asset for advanced drawing tasks.</p>
<p style="padding-left: 30px;">If you’re familiar with System.Drawing, you’ll no doubt find Quartz API similar, but it is exponentially more powerful. This chapter will get you well on your way with Quartz. By the end, you’ll have a good, solid grasp on all the important fundamentals, and be able to do most common drawing tasks.</p>
<p style="padding-left: 30px;">You can find examples of all the code in this chapter in use in the Example_Drawing companion application.</p>
<p style="padding-left: 30px;">Let’s first look at some fundamental concepts of CoreGraphics, and then we’ll dig into some code.</p>
<h1 style="padding-left: 30px;">Painter’s Model</h1>
<p style="padding-left: 30px;">CoreGraphics uses what is known as the painter’s model. As you draw, each subsequent drawing operation is applied on top of the previous one.</p>
<p style="padding-left: 30px;">Unlike layers in programs such as Photoshop, once you have drawn something, you can’t undraw it, or pull layers out. If you want to build an application like that, you either need to store a list of your draw operations and then re-draw each of the ones that you want to apply, or use multiple drawing surfaces, which we will explore in the “Drawing Context” section later in this chapter.</p>
<p style="padding-left: 30px;">If you’ve used System.Drawing, or any other modern 2D drawing frameworks, this model will be very familiar to you. And in fact, many of the same techniques and tools apply.</p>
<h1 style="padding-left: 30px;">Performance</h1>
<p style="padding-left: 30px;">Another important thing to know about CoreGraphics is that, while it is highly optimized for the iPhone, it is not guaranteed to use hardware acceleration. The iPhone and iPad have a dedicated GPU to handle drawing operations, and some operations that you do in CoreGraphics might be accelerated (handled by the GPU), but you never know what will be accelerated and what won’t.</p>
<p style="padding-left: 30px;">For most uses, this doesn’t matter, as the iPhone and iPad handle drawing operations quite well. However, for high-performance 2D or 3D drawing, like the kind you see in games, you should instead use OpenGL or the XNA Toolkit for MonoTouch (which also uses OpenGL under the hood). These toolkits have a number of other features that make them much more suitable for game development. Unfortunately, they’re also more complicated, which is why CoreGraphics is very useful.</p>
<p><strong>Chapter 17: Core Animation</strong></p>
<p style="padding-left: 30px;">One of the iconic things about iOS is its cinematic user experience. GUI elements slide on and off screen, fade in, fade out, flip, curl, and bounce, the result of which is an interface that feels very smooth, dynamic, and organic.</p>
<p style="padding-left: 30px;">Powering this cinematic experience is one of iOS’ foundation technologies, Core Animation. The Core Animation API provides you with a number of UIView-based animation features that allow you to easily animate changes in your interface so that your applications can provide the same cinematic experience that users have come to expect from iOS applications. View-based animation includes two types of animations: transition animations and same view animations. Transition animations are animations that occur when you’re changing between views. For instance, you might want to load another view and use a flip transition so that when it appears, the whole screen appears to flip with the new view on the side that rotates in. Same view animations are animations that occur on a single view, such as moving subviews around.</p>
<p style="padding-left: 30px;">In addition to the view-based animation features, the core animation API exposes lower-level animation functions that operate on CALayer objects, rather than UIView objects, and provide a powerful 2D animation framework that you can use to create more complex animations, and even power games.</p>
<p style="padding-left: 30px;">For most applications the view-based animation framework is the only part of Core Animation you’ll ever use. They provide a powerful way to give your interface that cinematic feel without much work. In fact, if you’ve been reading this book front-to-back, you’ve already been exposed to it. In this chapter, we’ll explore it a little deeper and take a look at how to work with it in more detail. Then, we’re going to dig into the lower-level core animation API to see how advanced animation can be accomplished in the iOS.</p>
<p style="padding-left: 30px;">As with Chapter 16, this chapter covers most of everything you’ll ever need to use with animation; however, the Core Animation API is massive. If you’re doing advanced animation, you should check out the <em>Core Animation Programming Guide</em> in the Xcode developer documentation after you’ve read this chapter.</p>
<p style="padding-left: 30px;">You can find all the examples used in this chapter in the Example_CoreAnimation sample code and application.</p>
<h1 style="padding-left: 30px;">View-Based Animation Framework</h1>
<p style="padding-left: 30px;">There are two different approaches when working with the view-based animation framework: the new way and the old way. The new way (available since the iOS v4.0 release) is the way recommended by Apple, but both ways have their advantages. Let’s take a quick look at examples of both methods so that you have a clear understanding of them.</p>
<h2 style="padding-left: 30px;">View Animations via the Animation Blocks</h2>
<p style="padding-left: 30px;">First, the old way is to call BeginAnimations, optionally configure the animation options, make your view changes, and then call CommitAnimations. See Listing 17–1.</p>
<p style="padding-left: 30px;">&nbsp;</p>
<pre class="brush: objc; title: Listing 17–1. Animating changes on a UIView using the BeginAnimations and CommitAnimations methods; notranslate">


UIView.BeginAnimations(&quot;ImageMove&quot;);

//code to make changes to the view (move controls, swap views, etc.)

UIView.CommitAnimations();

</pre>
<p style="padding-left: 30px;">Using this method, iOS will automatically animate any changes that occur between the BeginAnimations and CommitAnimations calls.</p>
<p style="padding-left: 30px;">Technically, Apple refers to this method of animation as Animation Blocks, but as we’re about to see, that’s really confusing, given that the new way is called Block-Based Animation. I’ll just refer to it as “the old way” to avoid confusion.</p>
<h2 style="padding-left: 30px;">View Animations via Block-Based Animation</h2>
<p style="padding-left: 30px;">The new way is to make a call to the Animate method, specify the duration of the animation, optionally specify any of the animation options, and then pass a method (or code as a lambda) that makes the changes that should be animated. See Listing 17–2.</p>
<p style="padding-left: 30px;">&nbsp;</p>
<pre class="brush: objc; title: Listing 17–2. Animating changes on a UIView using an animation block method; notranslate">


UIView.Animate(0.2, () =&gt; { /* code to animate */ });

</pre>
<p style="padding-left: 30px;">In this case, to simplify things, I’ve used the C# lamdba syntax, but you could also pass an anonymous delegate, as shown in Listing 17–3.</p>
<p style="padding-left: 30px;">
<pre class="brush: objc; title: Listing 17–3. Using the delegate syntax instead of a Lambda expression; notranslate">&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;UIView.Animate(0.2, delegate() { /* code to animate */ });&lt;/p&gt;
&lt;p style=&quot;padding-left: 30px;&quot;&gt;</pre>
</p>
<p style="padding-left: 30px;">This approach is known as block-based animation. It’s called such because in objective-c, the analog to code that’s passed in to execute is called a block. If you take a look at the prototype for the Animate methods (there are several overrides), they all take NSAction objects for their blocks. MonoTouch automatically does the magic of converting an anonymous delegate into an NSAction for you, so it’s a very clean and seamless integration with the underlying Objective-C runtime.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=123</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rendevous with Open Source Cocoa</title>
		<link>http://thecocoamag.com/?p=66</link>
		<comments>http://thecocoamag.com/?p=66#comments</comments>
		<pubDate>Fri, 27 May 2011 08:02:09 +0000</pubDate>
		<dc:creator>Achal Aggarwal</dc:creator>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[May]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=66</guid>
		<description><![CDATA[Over the past 3 years, we have seen a lot of developers making the switch to iOS and quite recently to Mac development. Even though Objective-C has been around since the early 1980s, not many developers bothered to give it a try. Like it happens in every community, many developers have written loads of projects [...]]]></description>
				<content:encoded><![CDATA[<p>Over the past 3 years, we have seen a lot of developers making the switch to iOS and quite recently to Mac development. Even though Objective-C has been around since the early 1980s, not many developers bothered to give it a try.</p>
<p>Like it happens in every community, many developers have written loads of projects to help them with their next project. Some of these projects are Open Source with different licensing but almost all of them can be used in your next commercial app.</p>
<p>I will talk about two of these today, one which I feel is done in most of the apps and something else which should be present just to make the user experience better over time.</p>
<p><strong>JSONKit</strong></p>
<p>JSONKit is a very high performance Objective-C JSON Library written by John Engelhart (<a href="https://github.com/johnezang/JSONKit">https://github.com/johnezang/JSONKit</a>).</p>
<p>For those who do not know what this is, Javascript Object Notation, or JSON is a lightweight, text-based, serialization format for structured data that is used by many web services and API’s.</p>
<p>I know that there are a lot of other Open Source JSON Libraries present but when you compare JSONKit with others, you really feel the performance difference.</p>
<table width="100%">
<tbody>
<tr>
<td><a href="http://thecocoamag.com/wp-content/uploads/2011/05/serialize.png"><img class="size-medium wp-image-67" title="serialize" src="http://thecocoamag.com/wp-content/uploads/2011/05/serialize-300x190.png" alt="" width="300" height="190" /></a></td>
<td><a href="http://thecocoamag.com/wp-content/uploads/2011/05/deserialize.png"><img class="alignnone size-medium wp-image-68" title="deserialize" src="http://thecocoamag.com/wp-content/uploads/2011/05/deserialize-300x205.png" alt="" width="300" height="205" /></a></td>
</tr>
<tr>
<td colspan="2">*Image Courtesy: John EngelHart</td>
</tr>
</tbody>
</table>
<p>It is also very easy to integrate inside your app, as it is not a bunch of files. Just add the interface and an implementation file and add an import and we are good to go.</p>
<p>As far as the methods are concerned, they are easy to understand and also adds a few methods to NSString, NSData, NSArray and NSDictionary.</p>
<p>There are a few tips to speed up the process parse the JSON available on the github page. It mostly depends on how you are fetching your JSON.</p>
<p>With speed, there always are a few things to keep in mind. Same is the case with JSONKit.</p>
<p>JSONKit is not designed to be used with Mac OSX Garbage Collection. It is extremely unlikely that it would ever be supported.</p>
<p>The JSON to be parsed must be encoded as Unicode.</p>
<p>Now, lets have a look at another project called QuincyKit.</p>
<p><strong><a href="http://quincykit.net/">QuincyKit</a></strong></p>
<p>QuincyKit is a live management tool for your crash reports for Mac OSX and iOS. It has a 4 member core team which is leading the development of the project on the client as well as the server end (I’ll come to this later). The team includes Thomas Dohmke (@<a href="http://twitter.com/ashtom">ashtom</a>), Kent Sutherland (@<a href="http://twitter.com/ksuther">ksuther</a>), Stanley Rost (@<a href="http://twitter.com/soryu2">soryu2</a>) and Andreas Linde (@<a href="http://twitter.com/therealkerni">therealkerni</a>).</p>
<p>The iOS client of the project uses PLCrashReporter by Plausible Labs (<a href="http://plausiblelabs.com">http://plausiblelabs.com</a>) without which this would not have been possible.</p>
<p>QuincyKit is not a 3<sup>rd</sup> party service which allows you to manage all your crash reports. It is absolutely free and all you need is a webserver with PHP5 and MySQL to run the server component.</p>
<p>The server component gives you the following</p>
<ul>
<li>Collect crash reports from multiple apps</li>
<li>Automatic grouping of crash reports based on similarity for easier management and review</li>
<li>Graphical stats are provided which help you understand what all devices and OS versions are affected.</li>
</ul>
<p>The Client SDK (iOS and Mac OS X) allows you to</p>
<ul>
<li>Automatically detect a previous crash on the next launch of the app</li>
<li>Collect User Feedback (Only Mac OS X)</li>
<li>Provide the user feedback about the status of a crash (iOS Only)</li>
</ul>
<p>This SDK is AppStore ready and can be used in beta and release versions of your app very easily. As on the Mac it uses the system generated crash reports, and for iOS, the ones by PLCrashReporter, it is very reliable.</p>
<p>The Github Wiki provides the details of how to integrate it into your app along with project setup and a demo app for both the iOS and Mac OS X</p>
<p>Both these projects serve very different aspects of your application lifecycle. You might chose to include the in your next app, and if you do, just drop in a line to the original authors about your app <img src='http://thecocoamag.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=66</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to OUR Magazine</title>
		<link>http://thecocoamag.com/?p=4</link>
		<comments>http://thecocoamag.com/?p=4#comments</comments>
		<pubDate>Fri, 27 May 2011 08:01:57 +0000</pubDate>
		<dc:creator>John W</dc:creator>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[Editorial]]></category>
		<category><![CDATA[May]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=4</guid>
		<description><![CDATA[Hi, Welcome to The Cocoa Magazine. I started this magazine (I hesitate to call it that, since there will NEVER be a print component) because there was a clear lack of any such source for developers to get the best information available. Sure there&#8217;s google, and it does ok, but my hope is that over [...]]]></description>
				<content:encoded><![CDATA[<p>Hi,</p>
<p>Welcome to The Cocoa Magazine. I started this magazine (I hesitate to call it that, since there will NEVER be a print component) because there was a clear lack of any such source for developers to get the best information available. Sure there&#8217;s google, and it does ok, but my hope is that over time, the content here at the Cocoa Magazine is so much better than anywhere else, you&#8217;ll come here to search.</p>
<p>This magazine will be a mix of technical, business, design articles, and whatever else we think will have value to cocoa developers. The plan is to grow and become what the community needs.</p>
<p><strong>What&#8217;s in store for the future?</strong></p>
<p>To start, this magazine will live as a website, hopefully one that plays well on an iPad (thanks to <a href="http://onswipe.com/">Onswipe</a>), but a website nonetheless. The upside is that it&#8217;ll be entirely free and open, just drop in, search for content, read the articles each month (we&#8217;ll likely release stuff in between monthly releases as well, but that&#8217;s later), and more. As we get going though, the next steps involve getting an iPad app created, and figuring out a model that provides a little financial support for everyone involved (I wonder if AOL is still buying). The idea for the iPad app will be straightforward content. Nothing fancy like Wired and the like, just great content, searchable, archivable, and mobile.</p>
<p><strong>Wait, what&#8217;s that about money?</strong></p>
<p>Lots of good things are free, but great things cost money. We&#8217;re starting Cocoa Magazine good, but we&#8217;ll be great as soon as possible. When we do, we&#8217;ll be looking at a model similar to <a href="http://arstechnica.com/subscriptions/">ars.technica&#8217;s premier subscription</a>. That&#8217;s at least a few releases out, and only when we&#8217;re sure it&#8217;s gonna be worth it for you.</p>
<p>&nbsp;</p>
<p>Join us.</p>
<p>We&#8217;re still looking for contributors so if you think you&#8217;ve got something to share, drop us an email at Thecocoamag AT 360conferences DOT com and we&#8217;ll get you in our google group and get you on the schedule. This is gonna be a fun ride, we&#8217;re gonna make something awesome!</p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=4</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Conversations With Greg: Occipital</title>
		<link>http://thecocoamag.com/?p=56</link>
		<comments>http://thecocoamag.com/?p=56#comments</comments>
		<pubDate>Fri, 27 May 2011 08:01:46 +0000</pubDate>
		<dc:creator>Greg Cerveny</dc:creator>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[May]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=56</guid>
		<description><![CDATA[For those that don&#8217;t know Occipital, they&#8217;re the team behind Red Laser (iTunes link), which was recently bought by Ebay not too long ago. Since then, they&#8217;ve gone on to launch 360 Panorama (iTunes link), a widely popular panoramic photo app for the iPhone. Greg Cerveny is currently working with Occipital in Boulder CO as [...]]]></description>
				<content:encoded><![CDATA[<p>For those that don&#8217;t know Occipital, they&#8217;re the team behind <a href="http://itunes.apple.com/us/app/redlaser/id312720263?mt=8">Red Laser</a> (iTunes link), which was recently bought by Ebay not too long ago. Since then, they&#8217;ve gone on to launch <a href="http://itunes.apple.com/us/app/360-panorama/id377342622?mt=8">360 Panorama</a> (iTunes link), a widely popular panoramic photo app for the iPhone.</p>
<p>Greg Cerveny is currently working with Occipital in Boulder CO as a consultant and sat down to talk about all things Occipital, here&#8217;s the first 2 things they talked about.</p>
<p><strong>1. Occipital is an Engineering Company</strong><br />
&#8220;Most people think it (360 Panorama) is using the gyroscope, but it’s really computer vision that’s tracking motion. It’s actually more accurate than using the gyroscope.&#8221;<br />
This is how Jeff Powers explains the 360 Panorama app.  When he first tells me this, we are sitting in ergonomic ultraviolet office chairs in a meeting room cornered by two walls of glass.  Every available writing surface, including the two glass walls, are filled with notes and equations.<br />
It is immediately obvious that Occipital is not a casual app company.</p>
<p><strong>2. Any Bar Code Scanner Timeline</strong><br />
Late February, 2009<br />
Development on a bar code scanner and price comparison app that would later become Red Laser begins.</p>
<p>Early May, 2009<br />
The application is released with server side processing.  Photos can only be taken of a bar code taken at 12&#8243; away.<br />
Jeff Powers: &#8220;Unless you were a true expert at using it, it would be faster to read the bar code number, and type it in to your phone.&#8221;<br />
Vikas Reddy: &#8220;We made the decision that the server based approach was not going to work, and we had to do it real time.&#8221;</p>
<p>Late June, 2009<br />
Red Laser releases real time scanning of some barcodes, others still processed remotely.<br />
Apple begins rejecting subsequent updates.<br />
JP: &#8220;There was no access to the camera and what we were doing was off limits.  Policy was fluctuating, and ultimately, we were told that it wasn’t permitted.  But we kept developing even though it was very uncertain if it would ever be allowed at all.&#8221;</p>
<p>September, 2009<br />
Apple approved a version with real time scanning for all formats of bar codes. Growth occurs exponentially.   No advertising and very little press outreach.<br />
JP: &#8220;It was actually a fantastic case study we didn’t intend.   We had the control group, v1.0, with all the same features as v2.0, but not real time scanning.  The commerce part of it, the price checking part of it, all the exact same.  So, if your hypothesis is, any bar code scanner launched at the same time would do the same, that would be invalidated that v1.0 got almost no usage, and v2.0 took off exponentially.  The only thing that changed was the actual computer vision of the barcode scanning.&#8221;</p>
<p>Not Explicitly Listed<br />
6 months of iteration on computer vision based bar code algorithm</p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=56</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UIGestureRecognizer Saves The Day</title>
		<link>http://thecocoamag.com/?p=11</link>
		<comments>http://thecocoamag.com/?p=11#comments</comments>
		<pubDate>Fri, 27 May 2011 08:01:36 +0000</pubDate>
		<dc:creator>Jonathan Hays (3Jacks Software,  @cheesemaker)</dc:creator>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[May]]></category>
		<category><![CDATA[Jonathan Hays]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=11</guid>
		<description><![CDATA[So you’ve just finished implementing the latest, greatest application and for once, you feel that your design was kept intact through the entire project schedule.  You’ve kept your objects oriented and your models viewed and controlled.  You’ve put together a design that Donald Knuth himself would approve of.  In short, your implementation is pure and [...]]]></description>
				<content:encoded><![CDATA[<p>So you’ve just finished implementing the latest, greatest application and for once, you feel that your design was kept intact through the entire project schedule.  You’ve kept your objects oriented and your models viewed and controlled.  You’ve put together a design that Donald Knuth himself would approve of.  In short, your implementation is pure and perfect, and your developer heart is light.</p>
<p>But, wait.  It looks like a last-minute change request from the beta testers just showed up in your inbox.  You take a look and quickly realize that your beta team members know what they’re talking about and if you want commercial success, you really need to add this feature.  You pop open Xcode and start going through your source code only to realize that you now face a difficult choice.  You can either spend weeks and months refactoring your design or you can quickly hack something in but it will ruin your design, and has a high likelihood of breaking in some of the edge cases.  Internally, your pragmatic brain must now wrestle with your code-purity soul.</p>
<p>Most experienced developers have found themselves in this situation at some point in their career.  Fortunately if you’re an iOS developer the UIGestureRecognizer class just might be able to get you out of the pickle you’re stuck in.  UIGestureRecognizers allow you to easily extend touch handling to UIView objects regardless of whether they were created to do so or not.  Applications written for iOS 3.2 and later can take advantage of them by either adding a pre-defined recognizer or implementing their own.</p>
<p>Using UIGestureRecognizers is incredibly simple.  The UIView class implements an addGestureRecognizer/removeGestureRecognizer function pair for inserting recognizers into their touch handling hierarchy.  The quickest way to get up and running is to simply use one of the built-in gesture recognizers.  The six built-in types are:</p>
<ol>
<li>UITapGestureRecognizer</li>
<li>UIPinchGestureRecognizer</li>
<li>UIPanGestureRecognizer</li>
<li>UISwipeGestureRecognizer</li>
<li>UIRotationGestureRecognizer</li>
<li>UILongPressGestureRecognizer</li>
</ol>
<p>While you certainly can come up with other types of gestures to build, these six provide  a large repertoire to start with.  It should be noted that multiple gesture recognizers could be added to an object.  What this means is that if you have a UIView object, you can easily add both rotate, swipe and press recognizers (or any other combination you can think of.)  This is the true power of gesture recognizers because they can be added cumulatively using the observer pattern without impacting existing object hierarchies.</p>
<p>Figure 1 shows a minimalist implementation of how you might add one to a view.  Please note that memory reference counting code has been removed to simplify the examples.  If you need to keep a pointer to the recognizer, you will need to make sure that you properly retain and release the pointer yourself or it will autorelease when removed from the view.</p>
<pre class="brush: objc; title: Figure 1; notranslate">
UIGestureRecognizer* recognizer = [[UITapGestureRecognizer alloc]
      initWithTarget:self action:@selector(tapReceived:)];
[self.view addGestureRecognizer:recognizer];
</pre>
<p style="text-align: left;">By choosing to implement gesture recognizers in the UIView base class, Apple chose to give developers greatest flexibility in what types of objects you can add these to.  You could just as easily add a rotate or swipe gesture to a UIButton as to a UIImageView, or a UITableView.  As you can see from the code in Figure 1, you simply pass a selector for whatever class function you choose to implement.  In this example, the calling class implements a tapReceived function that takes a UIGestureRecognizer as a parameter.  When tapReceived is called, the calling class receives the recognizer that it can then interrogate to determine what it should do in response.  Figure 2 shows an example of how you might implement the callback for handling a swipe gesture.</p>
<pre class="brush: objc; title: Figure 2; notranslate">
-(void)swipeReceived:(UISwipeGestureRecognizer *)gesture
{
CGPoint offset = self.view.center;
if (gesture.direction == UISwipeGestureRecognizerDirectionLeft)
{
offset.x -= 50.0;
[self.view setCenter:offset];
}
else if (gesture.direction == UISwipeGestureRecognizerDirectionRight)
{
offset.x += 50.0;
[self.view setCenter:offset];
}
}
</pre>
<p>As if this amount of flexibility wasn’t enough, Apple also provides one more mechanism for squeezing in “bad-code-bailout” functionality.  It does this in the form of the UIGestureRecognizerDelegate.  The three delegate functions shouldReceiveTouch, gestureRecognizerShouldBegin and shouldRecognizeSimultaneouslyWithGestureRecognizer will get called on your delegate object when a gesture is beginning.  They give you the opportunity to basically allow and disallow gestures based on whatever logic you might implement.  Obvious uses would be to disallow them based on application state or because other gestures are already in play.  To be clear, you can use gesture recognizers without setting the delegate property of the recognizer despite plenty of sample code to the contrary.  Furthermore, if you do chose to use the delegate functionality, all of the protocol functions are declared as optional.</p>
<p>If given all of the above flexibility still isn’t enough for you, you can always implement your own gesture recognizer.  If you go down that road, make sure to include UIGestureRecognizerSubclass.h, which will redeclare the UIGestureRecognizer state property as read/write as well as declare the eight functions that a derived class must implement.  The primary duty when implementing your own recognizer is to properly update the state property.  I will save implementing your own subclass as an activity for the reader, but suffice it to say the exercise is fairly straightforward.</p>
<p>As you can see, UIGestureRecognizers are incredibly handy for extending built-in UIKit classes as well as any proprietary classes you might have.  I personally have found them to be invaluable for the end of the project crunches where your pragmatic side needs to kick into gear.  Despite them being available since OS 3.2, not a lot of developers are aware of how powerful they can be.  For their part, Apple provides sample projects and documentation on their developer website, but to be honest, the class is so simple to use, you can find everything you need in the header files for the various classes.  I am repeatedly surprised at how many developers are unaware of the existence of these classes.  Hopefully if you fall into that category, this brief introduction to the UIGestureRecognizer class will give you another tool for your belt for those times when you need to get your project across the finish line.</p>
<p style="text-align: left;">&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=11</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Programming 101: How To Make a Tip Calculator</title>
		<link>http://thecocoamag.com/?p=76</link>
		<comments>http://thecocoamag.com/?p=76#comments</comments>
		<pubDate>Fri, 27 May 2011 08:01:27 +0000</pubDate>
		<dc:creator>Ray Wenderlich</dc:creator>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[May]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=76</guid>
		<description><![CDATA[If you&#8217;re completely new to iPhone programming and want to dive right in, this is the tutorial for you! In this tutorial, you&#8217;ll get started with iPhone programming by making a tip calculator! Why make a tip calculator?  First, it&#8217;s one of the easiest exercises you can do, so it is a great way to [...]]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re completely new to iPhone programming and want to dive right in, this is the tutorial for you!<br />
In this tutorial, you&#8217;ll get started with iPhone programming by making a tip calculator!</p>
<p>Why make a tip calculator?  First, it&#8217;s one of the easiest exercises you can do, so it is a great way to get started with iPhone development.</p>
<p>Secondly, if you&#8217;re as slow at math as I am, it&#8217;s actually really handy sometimes and you may find yourself using it!  :]<br />
So let&#8217;s get started, and get tipping!</p>
<p><a href="http://360idev.com/downloads/TipCalculator.zip">Source Code Available here</a></p>
<p><strong>Hello, iPhone!</strong><br />
To develop on the iPhone, you need a Mac.  Pretty much any Mac will do, whether a Mac laptop or what I used to get started &#8211; a Mac mini.<br />
Once you have your Mac, you need to download and install Xcode 4, the program you&#8217;ll use to build your apps.  You can <a href="href=&quot;http://developer.apple.com/xcode/">Download Xcode 4</a> from Apple&#8217;s site &#8211; it&#8217;s free if you&#8217;re a member of the iOS or Mac developer program, or you can buy it separately for a small fee if you&#8217;d like.<br />
Once you have Xcode 4 installed, run it and go to <em>File\New\New Project</em>.  Choose <em>iOS\Application\View-based Application</em>, and click Next.</p>
<div id="attachment_77" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/ViewBasedApplication.png"><img class="size-medium wp-image-77" title="ViewBasedApplication" src="http://thecocoamag.com/wp-content/uploads/2011/05/ViewBasedApplication-300x197.png" alt="" width="300" height="197" /></a><p class="wp-caption-text">Tap for Larger</p></div>
<p>On the next page, enter <em>TipCalculator</em> for the Product Name.  For the Company Identifier put a unique string (such as one of your domain names, if you own one).  Make sure Device Family is set to iPhone, and click Next.</p>
<div id="attachment_78" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/ProjectOptions.png"><img class="size-medium wp-image-78" title="ProjectOptions" src="http://thecocoamag.com/wp-content/uploads/2011/05/ProjectOptions-300x201.png" alt="" width="300" height="201" /></a><p class="wp-caption-text">tap for larger</p></div>
<p>Finally, choose a folder to save your project in, and click Create.<br />
Let&#8217;s see what you have so far!  In the toolbar at the top of Xcode, click Scheme and set it to your iPhone Simulator, as shown below:</p>
<div id="attachment_80" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/ProjectScheme.png"><img class="size-medium wp-image-80" title="ProjectScheme" src="http://thecocoamag.com/wp-content/uploads/2011/05/ProjectScheme-300x88.png" alt="" width="300" height="88" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Then click the Run button in the upper left of the toolbar, and you should see your app run in the Xcode simulator!</p>
<p><span id="more-76"></span></p>
<div id="attachment_81" class="wp-caption alignnone" style="width: 165px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/BlankScreen.png"><img class="size-medium wp-image-81" title="BlankScreen" src="http://thecocoamag.com/wp-content/uploads/2011/05/BlankScreen-155x300.png" alt="" width="155" height="300" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>So far so good, except this is kinda boring!  Let&#8217;s make things a little more interesting by making the screen say &#8220;Hello, iPhone!&#8221;<br />
In Xcode, you&#8217;ll see the files in your project listed off to the left.  Select TipCalculatorViewController, and it will bring up a visual editor for the main screen in your app:</p>
<div id="attachment_82" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/InterfaceBuilder.png"><img class="size-medium wp-image-82" title="InterfaceBuilder" src="http://thecocoamag.com/wp-content/uploads/2011/05/InterfaceBuilder-300x258.png" alt="" width="300" height="258" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>This visual editor is &#8220;Interface Builder&#8221; by the way, so I&#8217;ll refer to it by that from now on.<br />
We want to add a label to this screen that reads &#8220;Hello, iPhone!&#8221;  But to do this, you need to bring up the window that shows you all the views and controls you can add to the screen.<br />
To bring up this window, in the toolbar to the upper right, there is a segmented control with three buttons that reads <em>View</em>.  Click the button on the far right so it is shaded, and a window will slide in.<br />
The window on the side is split into two parts &#8211; a top part and a bottom part.  On the bottom part, it also has a toolbar, that lets you look through various libraries of things to add.  Make sure the third tab item is selected, for the Object library.<br />
Here&#8217;s a screenshot to show you the buttons you need to select:</p>
<div id="attachment_83" class="wp-caption alignnone" style="width: 151px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/Library.png"><img class="size-medium wp-image-83" title="Library" src="http://thecocoamag.com/wp-content/uploads/2011/05/Library-141x300.png" alt="" width="141" height="300" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Now, from the library look for the item that reads &#8220;Label&#8221;, and drag it into the top middle of your view.  Double click the label and change the text to &#8220;Hello, iPhone!&#8221;</p>
<div id="attachment_84" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/HelloiPhoneLayout.png"><img class="size-medium wp-image-84" title="HelloiPhoneLayout" src="http://thecocoamag.com/wp-content/uploads/2011/05/HelloiPhoneLayout-300x158.png" alt="" width="300" height="158" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Before we try this out, let&#8217;s make this text bigger, and a different color.  Make sure your label is selected, then in the top part of the sidebar to the right, select the fourth tab.<br />
This will bring up attributes you can change on the label, such as the alignment, number of lines, etc.<br />
You&#8217;ll seen an entry there for Font.  Click the button that looks like a T to the right of the font entry to bring up a visual editor, and set it to 36 points.<br />
You&#8217;ll notice that after setting it, the label seems to stay the same size, but that&#8217;s just because you haven&#8217;t increased the size of the label itself yet, and by default it shrinks to the area you give to it.<br />
So also increase the size of the label by dragging the blue dots at the edges until the text doesn&#8217;t grow anymore, and your screen should now look like this:</p>
<div id="attachment_85" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/ChangingFontSize.png"><img class="size-medium wp-image-85" title="ChangingFontSize" src="http://thecocoamag.com/wp-content/uploads/2011/05/ChangingFontSize-300x107.png" alt="" width="300" height="107" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>One last step &#8211; let&#8217;s change the font color.  To do this simply click the black box next to Text Color to bring up the color editor, and pick your favorite color:</p>
<div id="attachment_86" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/ChangingColor.png"><img class="size-medium wp-image-86" title="ChangingColor" src="http://thecocoamag.com/wp-content/uploads/2011/05/ChangingColor-300x166.png" alt="" width="300" height="166" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>And that&#8217;s it!  Click the Run button to run your project, and you should now have an App that says &#8220;Hello, iPhone!&#8221;</p>
<div id="attachment_88" class="wp-caption alignnone" style="width: 165px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/HelloiPhone1.png"><img class="size-medium wp-image-88" title="HelloiPhone" src="http://thecocoamag.com/wp-content/uploads/2011/05/HelloiPhone1-155x300.png" alt="" width="155" height="300" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p><strong>Tip Calculator Layout</strong><br />
All the stuff you just did was to get you familiar with the basics of running iPhone apps and adding controls.<br />
But that isn&#8217;t the way we want our Tip Calculator to actually look like, so let&#8217;s get the UI designed the way we&#8217;d like!<br />
First, double-click the &#8220;Hello, iPhone!&#8221; label, and change the text to &#8220;Tip Calculator.&#8221;<br />
Then, drag another label to the screen to the lower left of the &#8220;Tip Calculator&#8221; label, and change the text to &#8220;Bill Amount:&#8221;.</p>
<div id="attachment_89" class="wp-caption alignnone" style="width: 215px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/BillAmount.png"><img class="size-medium wp-image-89" title="BillAmount" src="http://thecocoamag.com/wp-content/uploads/2011/05/BillAmount-205x300.png" alt="" width="205" height="300" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Next, drag a <em>Text Field</em> from the library to the right of the label.  The Text Field is the control you use when you want the user to be able to enter numbers or letters.<br />
Resize the Text Field a bit so it fits all the way to the edge of the screen as well.</p>
<div id="attachment_90" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/BillAmountTextField.png"><img class="size-medium wp-image-90" title="BillAmountTextField" src="http://thecocoamag.com/wp-content/uploads/2011/05/BillAmountTextField-300x245.png" alt="" width="300" height="245" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Now, repeat this process to add another label reading &#8220;Tip Percent:&#8221; and a text field to its right.<br />
Also, drag a <em>Round Rect button</em> to the lower right, and double-click it to change the text to &#8220;Calculate!&#8221;<br />
Finally, add a label right below the button that reads &#8220;Your tip should be: XXXX&#8221; and extend the size to fit the entire width of the screen.<br />
At this point your layout should look as follows:</p>
<div id="attachment_92" class="wp-caption alignnone" style="width: 221px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/FinalLayout.png"><img class="size-medium wp-image-92" title="FinalLayout" src="http://thecocoamag.com/wp-content/uploads/2011/05/FinalLayout-211x300.png" alt="" width="211" height="300" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Click the Run button to run your app in the Simulator, and you should see your layout appear.  Try tapping one of the text fields, and you&#8217;ll notice that the keyboard comes up, but there&#8217;s a problem: it defaults to letters!</p>
<div id="attachment_93" class="wp-caption alignnone" style="width: 165px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/TipCalcLayoutKeyboard.png"><img class="size-medium wp-image-93" title="TipCalcLayoutKeyboard" src="http://thecocoamag.com/wp-content/uploads/2011/05/TipCalcLayoutKeyboard-155x300.png" alt="" width="155" height="300" /></a><p class="wp-caption-text">tap for larger</p></div>
<p>The keyboard style is another example of something you can change in the attribute editor for a control.<br />
So go select the two text fields (you can draw a border around them to select both), and change the keyboard to Numbers and Punctuation:</p>
<div id="attachment_94" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/KeyboardNumbersAndPunctuation.png"><img class="size-medium wp-image-94" title="KeyboardNumbersAndPunctuation" src="http://thecocoamag.com/wp-content/uploads/2011/05/KeyboardNumbersAndPunctuation-300x142.png" alt="" width="300" height="142" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Run your project again and tap on a text field, and now it&#8217;s easier to enter in a test tip amount!</p>
<div id="attachment_95" class="wp-caption alignnone" style="width: 166px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/TipCalcNewKeyboard.png"><img class="size-medium wp-image-95" title="TipCalcNewKeyboard" src="http://thecocoamag.com/wp-content/uploads/2011/05/TipCalcNewKeyboard-156x300.png" alt="" width="156" height="300" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Of course, tapping the Calculate button does absolutely nothing, which is kind of disappointing!  So let&#8217;s take care of this next.<br />
<strong> </strong></p>
<p><strong>Views and View Controller: Overview</strong><br />
<a href="http://thecocoamag.com/wp-content/uploads/2011/05/GotIt.png"><img class="alignright size-full wp-image-96" title="GotIt" src="http://thecocoamag.com/wp-content/uploads/2011/05/GotIt.png" alt="" width="307" height="235" /></a> All of the things you&#8217;ve been adding to the Tip Calculator so far (labels, text fields, and a button) are called <em>views</em>.<br />
If you think about it, somehow you&#8217;re going to need to write some code that has access to these views.<br />
You&#8217;ll need to get the value of what the user put in for the bill amount and tip percentage, run a calculation on it, and put the result in the lable to the bottom.  You&#8217;ll also need to know when the button is clicked.<br />
In iPhone development, the class that manages the views for a particular &#8220;screen&#8221; in your app is called a <em>View Controller</em>.  You may be familiar with this concept already if you&#8217;ve used the Model-View-Controller architecture in other languages.<br />
Your project already has a TipCalculatorViewController class set up for you, in TipCalculatorViewController.h and TipCalculatorViewController.m.<br />
So somehow, you need to find a way to hook up the views you&#8217;ve made in Interface Builder to this class!</p>
<p><strong>Views and View Controllers: Hooking Up</strong><br />
To hook up the view controller to the views, we want to make an instance variable and property for each of the views we need to access in code, and a method that will be called when the button is tapped, as shown below:</p>
<div id="attachment_97" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/TipCalcViewControllerHookup.png"><img class="size-medium wp-image-97" title="TipCalcViewControllerHookup" src="http://thecocoamag.com/wp-content/uploads/2011/05/TipCalcViewControllerHookup-300x195.png" alt="" width="300" height="195" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Luckily, this is incredibly easy in Xcode 4!<br />
In the toolbar at the top of Xcode where it reads <em>Editor</em> make sure the second tab is selected to bring up the Assistant Editor.<br />
Also, go to View\Assistant Layout\Assistant Editors on Bottom so it shows up below Interface Builder (I find it easier to work with that way).</p>
<div id="attachment_98" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/AssistantEditor.png"><img class="size-medium wp-image-98" title="AssistantEditor" src="http://thecocoamag.com/wp-content/uploads/2011/05/AssistantEditor-300x267.png" alt="" width="300" height="267" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Make sure that the Assistant Editor is set up to Automatic in its toolbar, and that the TipCalculatorViewController is showing up in the editor.<br />
Then, select the bill amount text field in Interface Builder, hold down control, and drag a line from it to right below the @interface block in the Assistant Editor:</p>
<div id="attachment_99" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/ConnectIB.png"><img class="size-medium wp-image-99" title="ConnectIB" src="http://thecocoamag.com/wp-content/uploads/2011/05/ConnectIB-300x264.png" alt="" width="300" height="264" /></a><p class="wp-caption-text">tap for larger</p></div>
<p>A popup will appear.  Enter billAmountTextField for the name, and click Connect.<br />
Once you&#8217;ve done this, you&#8217;ll see that it automatically creates an instance variable and property for you for billAmountTextField:</p>
<div id="attachment_100" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/BillAmountTextField1.png"><img class="size-medium wp-image-100" title="BillAmountTextField" src="http://thecocoamag.com/wp-content/uploads/2011/05/BillAmountTextField1-300x245.png" alt="" width="300" height="245" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>If you control-click on the Text Field in Interface Builder, you&#8217;ll see that it has also associated the text field to the File&#8217;s Owner (which is TipCalculatorViewController).  This is the step that hooks up the code to the view, all done for you!</p>
<div id="attachment_101" class="wp-caption alignnone" style="width: 310px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/BillAmountTextFieldHookup.png"><img class="size-medium wp-image-101" title="BillAmountTextFieldHookup" src="http://thecocoamag.com/wp-content/uploads/2011/05/BillAmountTextFieldHookup-300x233.png" alt="" width="300" height="233" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p>Now repeat this process for the Tip Percentage text field (naming it tipPercentTextField) and the label at the very bottom (name it resultLabel).<br />
Now we need to do something slightly different &#8211; hook up the calculate button to call a method in our view controller.  Luckily this is also quite easy with Xcode 4!<br />
Drag a line from the Calculate button down to the assistant editor after the @interface as you did for the others, but this time change the Connection type from Outlet to Action.  For name, enter calcTapped, and click Connect.<br />
This time, you&#8217;ll see that it&#8217;s created a method called calcTapped for you (that is empty right now).  Also if you control-click on the button in Interface Builder, you&#8217;ll see that it&#8217;s hooked up the Touch Up Inside event to this method for you.<br />
Almost done!  In the Files &amp; Groups tree to the left, select  TipCalculatorViewController.m to bring up the editor.  Scroll down to calcTapped, and replace the contents with the following:</p>
<pre class="brush: objc; title: ; notranslate">- (IBAction)calcTapped:(id)sender {

NSString *billAmountString = [billAmountTextField text];

float billAmountFloat = [billAmountString floatValue];

NSString *tipPercentString = [tipPercentTextField text];

float tipPercentFloat = [tipPercentString floatValue];

float tipAmount = billAmountFloat * tipPercentFloat;

NSString *result = [NSString stringWithFormat:@&quot;Your tip should be: %0.2f&quot;,

tipAmount];
    [resultLabel setText:result];
}
&lt;span style=&quot;font-family: Georgia, 'Times New Roman', '&lt;span class=;&quot;&gt;Bitstream&lt;/span&gt; Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;&quot;&gt;</pre>
<p>The first thing this does is get the text the user entered for each field.  The UITextFields have a text property you can use to get this.</p>
<p>It needs to convert each of these values to floats so we can do the calculation.  Luckily NSString has a helper method called floatValue that will convert strings to floats.<br />
Finally, it performs the calculation and sets the label to the result.<br />
Click the Run button to run your project, and you should now have a functional Tip Calculator!</p>
<div id="attachment_106" class="wp-caption alignnone" style="width: 166px"><a href="http://thecocoamag.com/wp-content/uploads/2011/05/TipCalculatorFinished.png"><img class="size-medium wp-image-106" title="TipCalculatorFinished" src="http://thecocoamag.com/wp-content/uploads/2011/05/TipCalculatorFinished-156x300.png" alt="" width="156" height="300" /></a><p class="wp-caption-text">Tap for larger</p></div>
<p><strong>Where To Go From Here?</strong><br />
Here is the <a href="TipCalculator.zip">sample project</a> with all of the code from the above tutorial.<br />
Contgratulations, you now have your very own iPhone app made from scratch, and pretty useful too!<br />
But why not make it even better?  You could add another field where the user can enter the tax rate, so you&#8217;re not over-tipping!  Or you could try to pull the tip calculation code into a helper class (your Model) to keep the code a bit cleaner.</p>
<p>If you&#8217;re interested in learning more, check out the <a href="http://www.raywenderlich.com/1797/how-to-create-a-simple-iphone-app-tutorial-part-1">How To Make A Simple iPhone App Tutorial</a> available on my <a href="http://www.raywenderlich.com">iPhone Tutorial blog</a>.  It shows you how to make an app about scary bugs, using some neat components in iPhone programming such as table views and image pickers!<br />
I hope you enjoyed this tutorial, and best of luck in your iOS adventures!<br />
<em>This is a post by <a href="http://twitter.com/#!/rwenderlich">Ray Wenderlich</a>, an indie iPhone developer passionate about making apps and teaching others the techniques to make them.  You can find more tutorials by Ray on his <a href="http://www.raywenderlich.com">iPhone Tutorial blog</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=76</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Things Done For Developers</title>
		<link>http://thecocoamag.com/?p=8</link>
		<comments>http://thecocoamag.com/?p=8#comments</comments>
		<pubDate>Fri, 27 May 2011 08:00:39 +0000</pubDate>
		<dc:creator>Collin Donnell</dc:creator>
				<category><![CDATA[2011]]></category>
		<category><![CDATA[May]]></category>
		<category><![CDATA[Collin Donnell]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=8</guid>
		<description><![CDATA[Capture Productivity is something I’ve thought a lot about because it’s something I’ve struggled with, I think a lot of other people have too. As developers we have a lot of tasks and reference materials to keep track of whether we’re working at a company, developing our own projects, or consulting for someone else. For [...]]]></description>
				<content:encoded><![CDATA[<h1 id="capture">Capture</h1>
<p>Productivity is something I’ve thought a lot about because it’s something I’ve struggled with, I think a lot of other people have too. As developers we have a lot of tasks and reference materials to keep track of whether we’re working at a company, developing our own projects, or consulting for someone else. For most people it’s hard to not lose anything without a water-tight system to capture and manage it all.</p>
<p>In this article I want to talk about capturing tasks and related materials. If you know <a href="http://en.wikipedia.org/wiki/Getting_Things_Done">GTD</a>, some of it’s going to sound familiar. In GTD one of the core ideas is that you need to capture every item that goes through your head in a trusted place where you <em>know</em> that you can come back to it later and process it effectively. For developers finding a system that’s  simple and seamless enough to not interfere is essential.</p>
<h2 id="methodsofcapture">Methods of Capture</h2>
<p>I combine high and low tech tools for capture, and default to whichever works for the context I’m in. As long as I trust the tool and know that I come back to it, the specific method of capture is really pretty secondary.</p>
<h3 id="onthemac">On The Mac</h3>
<p>On my Mac I’ll usually just type into a text file or directly into my task management software. Most of these apps have some concept of an inbox and that gives me a trusted and known place I can come back to for later processing. Pick any tool that makes you comfortable here. If you’re interested in processing your tasks later in a GTD centric way, <a href="http://www.omnigroup.com/products/omnifocus">OmniFocus</a> is a great choice that I’ve had a lot of success with.</p>
<p>A habit that I’ve recently started is having a folder called “Inbox” on my Mac for storing files that I’m not sure what to do with yet. I process this at least once a day to keep it from getting stale. Mine is kept in the root directory of my Dropbox folder and is kept as a<br />
stack on my dock. I’ve also set screenshots I take to go here which you can do from Terminal with this line: <code>defaults write com.apple.screencapture location /Full/Path/To/Folder</code>. Getting transient files off of my Desktop and processing them regularly has turned out to be a great habit for keeping track of these files.</p>
<h3 id="onthego">On The Go</h3>
<p>When I’m away from my computer and need to capture a task or thought quickly, I normally default to <a href="http://www.omnigroup.com/products/omnifocus_for_iphone/">OmniFocus</a> on my iPhone. The thing that’s important when picking a mobile tool is that if you’re going to sync with a desktop app you trust syncing will be automatic and painless enough that your information will be there you need it. <a href="http://www.omnigroup.com/products/omnifocus_for_iphone/">OmniFocus</a> has worked really well for that because the syncing is mostly automatic &#8211; my tasks have always just been everywhere I needed them. You should consider the level of pain you’re willing to endure here versus what tool you like the best offers. Entering tasks on the iPhone usually works best for me when I’m away and have a quick idea, or remember something I need to do want to jot it down. I don’t try to organize tasks using the iPhone at all and mostly just use it for capture.</p>
<p>If I need to store a slightly more detailed note, or I’m working with someone, a notebook is my solution. I don’t like to type a long set of notes into the iPhone if I can avoid it. Also when dealing with someone else jotting something into a notebook looks like you’re paying attention, pulling out an iPhone and typing feverishly into it makes you look like an asshole. When picking a notebook, find one sturdy and small enough to survive in your back pocket. Carrying it with you at all times is a great habit, and I definitely feel like I capture more errant ideas just by having it. <a href="http://www.fieldnotes.com">Field Notes</a> have treated me well, both for size and durability. I’ll also use the notebook for sketching into which is a task that neither a computer nor iPhone is particularly well suited for.</p>
<h2 id="wrappingup">Wrapping Up</h2>
<p>Capture is one of the most integral parts of any task management system. Without capturing everything you can’t even really be sure what you need to accomplish, let alone start doing it. In future articles I’d like to continue by discussing how to effectively process tasks and manage a reference system. I hope that reading this has given you some ideas for how you can be more effective at getting things out of your head and into a system, next month we’ll talk about processing and turning them into tasks.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=8</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://thecocoamag.com/?p=1</link>
		<comments>http://thecocoamag.com/?p=1#comments</comments>
		<pubDate>Tue, 05 Apr 2011 17:29:46 +0000</pubDate>
		<dc:creator>John W</dc:creator>
				<category><![CDATA[Editorial]]></category>

		<guid isPermaLink="false">http://thecocoamag.com/?p=1</guid>
		<description><![CDATA[Truer words. I love that the default blog post when you do a Word Press install is &#8220;Hello World&#8221; given that this magazine is for Mac and iOS developers, perhaps our &#8220;Hello World&#8221; should have been a twitter app&#8230; &#160; There&#8217;s not much to see here yet, in fact there until May 27th there won&#8217;t [...]]]></description>
				<content:encoded><![CDATA[<p>Truer words. I love that the default blog post when you do a Word Press install is &#8220;Hello World&#8221; given that this magazine is for Mac and iOS developers, perhaps our &#8220;Hello World&#8221; should have been a twitter app&#8230;</p>
<p>&nbsp;</p>
<p>There&#8217;s not much to see here yet, in fact there until May 27th there won&#8217;t be. That&#8217;s when the first &#8220;issue&#8221; of this goes live. We&#8217;ve got some great articles lined up and are working on a few more.</p>
<p>&nbsp;</p>
<p>Finding content in this magazine will be easy. Each &#8216;issue&#8217; will be tagged with the issue number and month and year. They&#8217;ll also be tagged with keywords so when you want to search on Xcode, you&#8217;ll only find articles dealing with code, and the IDE.</p>
<p>The idea is that this magazine becomes a useful resource for finding awesome and worthwhile content well down the road.</p>
<p>&nbsp;</p>
<p>All are welcome to contribute, just email (thecocoamag AT 360conferences DOT com)us to get started.</p>
]]></content:encoded>
			<wfw:commentRss>http://thecocoamag.com/?feed=rss2&#038;p=1</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
