<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:series="http://unfoldingneurons.com/" version="2.0">

<channel>
	<title>Mobiletuts+</title>
	
	<link>http://mobile.tutsplus.com</link>
	<description>iPhone, Android, Windows and BlackBerry mobile development tutorials.</description>
	<lastBuildDate>Wed, 16 May 2012 11:30:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MobileTuts" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="mobiletuts" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">MobileTuts</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Networking Made Easy With AFNetworking</title>
		<link>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_afnetworking/</link>
		<comments>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_afnetworking/#comments</comments>
		<pubDate>Wed, 16 May 2012 11:30:42 +0000</pubDate>
		<dc:creator>Bart Jacobs</dc:creator>
				<category><![CDATA[iOS SDK]]></category>
		<category><![CDATA[AFNetworking]]></category>
		<category><![CDATA[Network Programming]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10741</guid>
		<description>&lt;p&gt;Networking is hard. There are various moving parts involved and many factors need to be considered to make it work. Fortunately, a number of open-source libraries have emerged over time to make networking easier. AFNetworking, created and maintained by the people of Gowalla, is one such library. This tutorial will introduce you to the AFNetworking framework while also showing how to query the iTunes Store API!&lt;/p&gt;
&lt;p&gt;&lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;In this tutorial, I will introduce you to AFNetworking and show you a glimpse of what this library has to offer. After spending a few minutes with this library, you will notice that it was designed with ease of use in mind. It will not only speed up your development, but it will also take care of many painstaking networking tasks. We will build a simple application that queries the iTunes Store for movies that match the search term &amp;#8220;harry&amp;#8221;. The results of our query will be displayed in a table view.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Project Summary&lt;/h2&gt;
&lt;p&gt;The application we are about to build queries the iTunes Store Search API. In particular, we search the iTunes Store for movies that match the search term &amp;#8220;harry&amp;#8221;. If our query is successful, we process the results and display them in a table view. Each row represents a movie with a title, a director, and a thumbnail showing the movie artwork. Ready? Let&amp;#8217;s get started.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Project Setup&lt;/h2&gt;
&lt;p&gt;Before we get our hands dirty with AFNetworking, we need to build a basic foundation. This means setting up our project, creating a table view, and adding an activity indicator view. We will show the activity indicator when our request is being processed by the iTunes Store. This will give the user that valuable extra bit of feedback that is often overlooked.&lt;/p&gt;
&lt;p&gt;Create a new project in Xcode by selecting the &lt;strong&gt;Single View Application&lt;/strong&gt; template from the list of templates. Name your application &lt;strong&gt;NetworkingIsFun&lt;/strong&gt;, enter a company identifier, set &amp;#8220;iPhone&amp;#8221; for the device family, and uncheck &amp;#8220;Use Storyboards&amp;#8221;. You can leave the rest untouched, but make sure that &lt;strong&gt;Use Automatic Reference Counting&lt;/strong&gt; is checked. Tell Xcode where you want to save your project and hit &amp;#8220;Save&amp;#8221;.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/iOS-SDK_AFNetworking/iOS-SDK_AFNetworking_figure-1.png" alt="AFNetworking is Fun: Project Setup - Figure 1"&gt;
&lt;/div&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/iOS-SDK_AFNetworking/iOS-SDK_AFNetworking_figure-2.png" alt="AFNetworking is Fun: Project Setup - Figure 2"&gt;
&lt;/div&gt;
&lt;hr /&gt;
&lt;h2&gt;Adding the Table and Activity Indicator Views&lt;/h2&gt;
&lt;p&gt;Even though Interface Builder is great, I often build my interfaces programmatically, and that is what we will do in this tutorial as well. It will allow us to just focus on the code without being distracted by Interface Builder. Open &lt;strong&gt;ViewController.h&lt;/strong&gt; and create three instance variables (ivars) as well as properties for these ivars. Since we are going to work with a table view, don&amp;#8217;t forget to make your view controller conform to the &lt;strong&gt;UITableViewDataSource&lt;/strong&gt; and &lt;strong&gt;UITableViewDelegate&lt;/strong&gt; protocols. Your view controller&amp;#8217;s header file should now look similar to the one below:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
#import &amp;lt;UIKit/UIKit.h&amp;gt;

@interface ViewController : UIViewController &amp;lt;UITableViewDataSource, UITableViewDelegate&amp;gt; {
    UITableView *_tableView;
    UIActivityIndicatorView *_activityIndicatorView;
    NSArray *_movies;
}

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic, retain) NSArray *movies;

@end
&lt;/pre&gt;
&lt;p&gt;If you are confused by the use of underscores, I recommend that you read about it &lt;a href="http://stackoverflow.com/a/6366336"&gt;here&lt;/a&gt;. Feel free to omit the underscores if you think it looks ugly or makes you feel uncomfortable. Apart from the underscores, there shouldn&amp;#8217;t be any surprises. We declare our UITableView and UIActivityIndicatorView as well as an NSArray, which we will use to store the results that we get back from our search query. Ready? Let&amp;#8217;s head over to our view controller&amp;#8217;s implementation file.&lt;/p&gt;
&lt;p&gt;Since we declared three properties in our header file, we need to synthesize their accessors in &lt;strong&gt;ViewController.m&lt;/strong&gt;. Again, if the underscores confuse you, you can leave them out.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
@synthesize tableView = _tableView, activityIndicatorView = _activityIndicatorView, movies = _movies;
&lt;/pre&gt;
&lt;p&gt;In our &lt;strong&gt;viewDidLoad&lt;/strong&gt; method, we set up our table and activity indicator views. The code below should be self-explanatory for the most part. If you have never set up a table view without using Interface Builder, you might see a few lines that are unfamiliar to you. Instead of wiring the table view up in Interface Builder, we take care of this in the &lt;strong&gt;viewDidLoad&lt;/strong&gt; method. After calling the superclass&amp;#8217; &lt;strong&gt;viewDidLoad&lt;/strong&gt; method, we initizalize our table view with a frame and a style, and we set our view controller as the data source and delegate of our table view. When our application launches, we hide our table view since we don&amp;#8217;t have anything to show as long as our query hasn&amp;#8217;t returned any results. Before adding the table view as a subview to our view controller&amp;#8217;s view, we set its autoresizing mask. The autoresizing mask defines how the table view should be resized if the parent view &amp;#8211; the view controller&amp;#8217;s view to which we add the table view &amp;#8211; changes in size. This happens when the device is rotated, for example. Confused? Don&amp;#8217;t worry about it. It isn&amp;#8217;t important for this application.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)viewDidLoad {
    [super viewDidLoad];

    // Setting Up Table View
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    self.tableView.hidden = YES;
    [self.view addSubview:self.tableView];

    // Setting Up Activity Indicator View
    self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    self.activityIndicatorView.hidesWhenStopped = YES;
    self.activityIndicatorView.center = self.view.center;
    [self.view addSubview:self.activityIndicatorView];
    [self.activityIndicatorView startAnimating];

    // Initializing Data Source
    self.movies = [[NSArray alloc] init];
}
&lt;/pre&gt;
&lt;p&gt;Setting up the activity indicator view is just as easy. We initialize the activity indicator view with a pre-defined style, set its &lt;strong&gt;hidesWhenStopped&lt;/strong&gt; property to &lt;strong&gt;YES&lt;/strong&gt;, and position it at the center of its parent view. After adding it to the view controller&amp;#8217;s view, we start animating the activity indicator. The activity indicator will automatically display itself since we set its &lt;strong&gt;hidesWhenStopped&lt;/strong&gt; property to YES.&lt;/p&gt;
&lt;p&gt;At the end of our &lt;strong&gt;viewDidLoad&lt;/strong&gt; method, we initialize the &lt;strong&gt;movies&lt;/strong&gt; array. We will use it later to store the results of our search query.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Table View Protocols&lt;/h2&gt;
&lt;p&gt;For this tutorial, we will only implement two methods of the table view data source protocol. Both of these methods are required. This is the minimum implementation required to get our table view up and running. Even though we have set our view controller as the table view&amp;#8217;s delegate, we won&amp;#8217;t use any of the delegate methods in our application. If you have used a table view before, you won&amp;#8217;t find any surprises in the method implementations shown below.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (self.movies &amp;amp;&amp;amp; self.movies.count) {
        return self.movies.count;
    } else {
        return 0;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @&amp;quot;Cell Identifier&amp;quot;;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
    }

    return cell;

}
&lt;/pre&gt;
&lt;p&gt;In &lt;strong&gt;tableView:numberOfRowsInSection:&lt;/strong&gt;, we need to return the number of rows in each section of the table view. In our example, the table view contains only one section (default), which makes everything a bit easier. First we check if our &lt;strong&gt;movies&lt;/strong&gt; variable is not nil and we verify that it contains items. If both of these requirements are met, we return the number of items in the movies array, if not, we return zero.&lt;/p&gt;
&lt;p&gt;Our &lt;strong&gt;tableView:cellForRowAtIndexPath:&lt;/strong&gt; method is basic as well. We start by asking our table view whether there is a cell we can reuse. If this is not the case, we create a new cell with a style and reuse identifier. We end our implementation by returning our cell. This will do for now. You can now build and run your application. If you followed the steps correctly, you should see the activity indicator spinning like crazy and the table view should be hidden.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Adding AFNetworking to the Mix&lt;/h2&gt;
&lt;p&gt;Adding AFNetworking to your project is easy as pie. Start by downloading the library from &lt;a href="https://github.com/AFNetworking/AFNetworking" target="_blank"&gt;GitHub&lt;/a&gt; and extract the archive. The archive contains a folder named &lt;strong&gt;AFNetworking&lt;/strong&gt;, which contains the source files we need to include in our project. Drag this entire folder into your Xcode project and make sure that you check &lt;strong&gt;Copy items into the destination group&amp;#8217;s folder (if needed)&lt;/strong&gt; and add the source files to your target as well.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/iOS-SDK_AFNetworking/iOS-SDK_AFNetworking_figure-3.png" alt="AFNetworking is Fun: Adding AFNetworking to the Mix - Figure 3" /&gt;
&lt;/div&gt;
&lt;p&gt;After adding the AFNetworking library to your project, build and run your application and watch as everything falls apart. What happened to our project? Why do we get all these warnings and errors? When we set up our Xcode project, we enabled &lt;strong&gt;Automatic Reference Counting (ARC)&lt;/strong&gt;. At the time of writing, the AFNetworking library does not use ARC. Don&amp;#8217;t worry, though, we can still use this neat library with very little effort. All we need to do is tell the compiler that all the source files of the AFNetworking library do not use ARC. That&amp;#8217;s it.&lt;/p&gt;
&lt;p&gt;How do we do this? Select your project in the &lt;strong&gt;Project Navigator&lt;/strong&gt; and select your target. Click the &lt;strong&gt;Build Phases&lt;/strong&gt; tab in the top navigation and open the &lt;strong&gt;Compile Sources&lt;/strong&gt; drawer. This table shows you all the source files the compiler will compile at compile time. The left column shows the names of the files and the right column shows the flags the compiler should know about.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/iOS-SDK_AFNetworking/iOS-SDK_AFNetworking_figure-4.png" alt="AFNetworking is Fun: Compiler Flags - Figure 4" /&gt;
&lt;/div&gt;
&lt;p&gt;You can see these flags as instructions or messages for the compiler. All you need to do is add a compiler flag to each source file of the AFNetworking library. To do this, select a source file from the list and double click the cell in the right column. A small window will appear in which you can add one or more compiler flags. In our case, simply type &lt;strong&gt;-fno-objc-arc&lt;/strong&gt; and click &lt;strong&gt;Done&lt;/strong&gt;. This flag tells the compiler that the source file does not use ARC. Make sure that you add this flag to all ten source files of the AFNetworking library.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/iOS-SDK_AFNetworking/iOS-SDK_AFNetworking_figure-5.png" alt="AFNetworking is Fun: Compiler Flags - Figure 5" /&gt;
&lt;/div&gt;
&lt;hr /&gt;
&lt;h2&gt;Querying the iTunes Store Search API&lt;/h2&gt;
&lt;p&gt;AFNetworking is a library that can do a lot for you, but today we are only going to make use of two neat features. Before we can start using the AFNetworking classes, we need to add the following import statement just below the first import statement in your view controller&amp;#8217;s implementation file.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
#import &amp;quot;AFNetworking.h&amp;quot;
&lt;/pre&gt;
&lt;p&gt;This import statement will give us access to all the AFNetworking classes. Head back to our view controller&amp;#8217;s &lt;strong&gt;viewDidLoad&lt;/strong&gt; method and add the following snippet immediately after the initialization of the &lt;strong&gt;movies&lt;/strong&gt; array.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
NSURL *url = [[NSURL alloc] initWithString:@&amp;quot;http://itunes.apple.com/search?term=harry&amp;amp;country=us&amp;amp;entity=movie&amp;quot;];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    NSLog(@&amp;quot;JSON&amp;quot;);

} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
    NSLog(@&amp;quot;Request Failed with Error: %@, %@&amp;quot;, error, error.userInfo);
}];

[operation start];
&lt;/pre&gt;
&lt;p&gt;Let me explain what is going on. In the first line, we create the NSURL for our request. The string we use in the initialization conforms to the format that the iTunes Store Search API expects. The syntax of the Search API is fairly straightforward: The term we are searching for is &amp;#8220;harry&amp;#8221;, we restrict our search to the US iTunes Store, and we are looking only for movies. Easy, Right?&lt;/p&gt;
&lt;p&gt;Next, we initialize a NSURLRequest and pass in the NSURL we just created. Then AFNetworking kicks in. AFNetworking contains a few very specialized classes that make our job very easy. The one we use here is &lt;strong&gt;AFJSONRequestOperation&lt;/strong&gt;. This is a class that is designed to fetch and parse JSON data in the background. As the name implies, this class is a subclass of NSOperation or, to be more precise, one of the superclasses of this class inherits from NSOperation. The class lets you fetch the requested data and it also parses the JSON response. This means that we don&amp;#8217;t have to deal with raw JSON. The data it returns is ready to use in your application. AFNetworking uses the built-in JSON parser on iOS 5 and falls back to its own JSON parser for older iOS versions.&lt;/p&gt;
&lt;p&gt;Using AFJSONRequestOperation is easy since it has only one class method. This class method accepts three arguments: (1) a NSURLRequest, (2) a success block, executed when the request succeeds, and (3) a failure block, executed when the request fails. If blocks are new to you or you are not comfortable using them, then I recommend reading the tutorial by Collin Ruffenach about &lt;a href="http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-blocks-and-enumeration/"&gt;blocks and enumeration&lt;/a&gt; on Mobiletuts+. The success block takes three arguments: (1) our NSURLRequest, (2) the NSHTTPURLResponse of our request, and (3) a parsed JSON object. The failure block is almost identical. The only difference is that it takes an additional argument, an NSError that contains more information about what went wrong in case our request fails.&lt;/p&gt;
&lt;p&gt;For testing purposes, we log the parsed JSON object to see what the iTunes Store Search API sends back to us. In addition, we also log the error in the failure block in case our request happens to fail. Before building and running our application once again, we need to start the operation by calling &lt;strong&gt;start&lt;/strong&gt; on our operation object. Build and run your application and take a look at the output in the console.&lt;/p&gt;
&lt;p&gt;If all went well, you will see the results of our request logged to the console. The parsed JSON object is a dictionary with two keys: (1) &lt;strong&gt;resultCount&lt;/strong&gt;, which contains the number of results returned and (2) the actual &lt;strong&gt;results&lt;/strong&gt; as an array of dictionaries. We not only logged the response to the console to see if our request was successful, we can now see the keys for each item in the results array. We will need these keys to display some information in our table view.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Populating the Table View&lt;/h2&gt;
&lt;p&gt;We are now ready to show the results in our table view. Replace the log statement in the success block with the snippet shown below. We start by assigning the results array of the response object to the movies array. The only thing left to do is hide the activity indicator by stopping it, showing the table view, and reloading the table view with the new data stored in the movies array.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
self.movies = [JSON objectForKey:@&amp;quot;results&amp;quot;];
[self.activityIndicatorView stopAnimating];
[self.tableView setHidden:NO];
[self.tableView reloadData];
&lt;/pre&gt;
&lt;p&gt;Next we amend the &lt;strong&gt;tableView:cellForRowAtIndexPath:&lt;/strong&gt; method. Adjust your implementation to reflect the one below. After obtaining a reference to a cell, we query the movies array for the correct item, and update the labels of the cell with the title and director of the movie. Build and run your application.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @&amp;quot;Cell Identifier&amp;quot;;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
    }

    NSDictionary *movie = [self.movies objectAtIndex:indexPath.row];
    cell.textLabel.text = [movie objectForKey:@&amp;quot;trackName&amp;quot;];
    cell.detailTextLabel.text = [movie objectForKey:@&amp;quot;artistName&amp;quot;];

    return cell;
}
&lt;/pre&gt;
&lt;p&gt;You may have noticed that there are no thumbnails to be seen. Let&amp;#8217;s fix that by adding three extra lines to our &lt;strong&gt;tableView:cellForRowAtIndexPath:&lt;/strong&gt; method. Build and run your application.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
NSURL *url = [[NSURL alloc] initWithString:[movie objectForKey:@&amp;quot;artworkUrl100&amp;quot;]];
NSData *data = [NSData dataWithContentsOfURL:url];
cell.imageView.image = [[UIImage alloc] initWithData:data];
&lt;/pre&gt;
&lt;p&gt;Did you notice that our table view does not scroll smoothly. Why is that? As I mentioned in a &lt;a href="http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_uiactivityindicatorview_mbprogresshud/"&gt;previous tutorial&lt;/a&gt;, you always have to make sure that the main thread of your application remains responsive. In the current implementation of our &lt;strong&gt;tableView:cellForRowAtIndexPath:&lt;/strong&gt; method, we are downloading the thumbnails on the main thread. This means the user interface cannot be updated until a request for a thumbnail is finished. Our thumbnails are tiny so the requests don&amp;#8217;t take too long to complete, but imagine taking the same approach for larger assets. The user experience would be terrible. Even for our simple application, the user experience is unacceptable. However, we can remedy this with a very useful feature of the AFNetworking library.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;AFNetworking to the Rescue&lt;/h2&gt;
&lt;p&gt;The creators of AFNetworking saw the need for downloading assets in the background as well. They therefore created a category for UIImageView. This category allows you to download images in the background with only two lines of code. This category is a true life saver. Have a look at the snippet below.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
NSURL *url = [[NSURL alloc] initWithString:[movie objectForKey:@&amp;quot;artworkUrl100&amp;quot;]];
[cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@&amp;quot;placeholder&amp;quot;]];
&lt;/pre&gt;
&lt;p&gt;The first line of code stays the same. In the second line, we tell the image view where the thumbnail is located by passing an NSURL and we pass in a placeholder image, which is shown as long as our request has not returned a response. How cool is that? All we need to do is add a placeholder image to our project. This can be any image you want, but you can find the image I&amp;#8217;ve used as a placeholder in the download file attached to this tutorial. Once you&amp;#8217;ve added the placeholder image, build and run your application and test for yourself how smooth the table view scrolls!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Note that our application is very basic in its execution as it doesn&amp;#8217;t do any caching and we can only search the iTunes Store for the term &amp;#8220;harry&amp;#8221; in the movies section. However, with very little effort you can make a neat application to search the iTunes Store in a more dynamic way.&lt;/p&gt;
&lt;p&gt;I hope this tutorial has convinced you that the AFNetworking library is a great tool to have in your arsenal. It can do a lot more than what I showed you in this post, but the main goal of this tutorial is to get you up and running with AFNetworking and ready to use it in a real world scenario.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/QjdYhNRrqot5tFrZLCPoqLMV5M8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QjdYhNRrqot5tFrZLCPoqLMV5M8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/QjdYhNRrqot5tFrZLCPoqLMV5M8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QjdYhNRrqot5tFrZLCPoqLMV5M8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_afnetworking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Corona SDK: Create a Balloon Game</title>
		<link>http://mobile.tutsplus.com/tutorials/corona/corona-sdk-create-a-bloons-like-game/</link>
		<comments>http://mobile.tutsplus.com/tutorials/corona/corona-sdk-create-a-bloons-like-game/#comments</comments>
		<pubDate>Tue, 15 May 2012 17:19:12 +0000</pubDate>
		<dc:creator>Carlos Yanez</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[games]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10722</guid>
		<description>&lt;p&gt;In this tutorial series, you&amp;#8217;ll learn how to create a Bloons Inspired game. The objective of the game is to shoot at the balloons to pop them all&amp;#8230;Read on!&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 1:&lt;/span&gt; Application Overview&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
  &lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/1.png" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;Using pre-made graphics we will code  an entertaining game with Lua and the Corona SDK API&amp;#8217;s.&lt;/p&gt;
&lt;p&gt;The player will be able to shoot an acorn at the balloons by touching the screen to charge and releasing to shoot. You can modify the parameters in the code to customize the game.&lt;/p&gt;
&lt;h2&gt;&lt;span&gt;Step 2:&lt;/span&gt; Target Device&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/2.png" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;The first thing we have to do is select the platform we want to run our app within. By doing so, we&amp;#8217;ll be able to choose the size for the images we will use.&lt;/p&gt;
&lt;p&gt;The iOS platform has these characteristics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;iPad:&lt;/strong&gt; 1024x768px, 132 ppi&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;iPhone/iPod Touch:&lt;/strong&gt; 320x480px, 163 ppi&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;iPhone 4:&lt;/strong&gt; 960x640px, 326 ppi&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Because Android is an open platform, there are many different devices and resolutions. A few of the more common screen characteristics are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Google Nexus One:&lt;/strong&gt; 480x800px, 254 ppi&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Motorola Droid X:&lt;/strong&gt; 854x480px, 228 ppi&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;HTC Evo:&lt;/strong&gt; 480x800px, 217 ppi&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In this tutorial, we&amp;#8217;ll be focusing on the iOS platform with the graphic design, specifically developing for distribution to an iPhone/iPod touch, but the code presented here should apply to Android development with the Corona SDK as well.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 3:&lt;/span&gt; Interface&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
&lt;p&gt;&lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/3.png" alt="" /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;A simple and friendly interface will be used. This involves multiple shapes, buttons, bitmaps and more.&lt;/p&gt;
&lt;p&gt;The interface graphic resources necessary for this tutorial can be found in the attached download.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 4:&lt;/span&gt; Export Graphics&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/4.png" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;Depending on the device you have selected, you may need to export the graphics in the recommended PPI. You can do that with your favorite image editor.&lt;/p&gt;
&lt;p&gt;I used the &lt;em&gt;Adjust Size&amp;#8230;&lt;/em&gt; function in the Preview app on Mac OS X.&lt;/p&gt;
&lt;p&gt;Remember to give the images a descriptive name and save them in your project folder.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 5:&lt;/span&gt; Sound&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
  &lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/5.png" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;We&amp;#8217;ll use Sound Effects to enhance the feeling of the game, you can find the sound used in this example in &lt;a href="http://soungle.com/"&gt;Soungle.com&lt;/a&gt; using the keyword &lt;em&gt;pop&lt;/em&gt;.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 6:&lt;/span&gt; App Configuration&lt;/h2&gt;
&lt;p&gt;The &lt;em&gt;config.lua&lt;/em&gt; file will be used to make the application go fullscreen across all devices. This file shows the original screen size and the method used to scale that content in case the app is run in a different resolution.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
application =
{
    content =
    {
        width = 320,
        height = 480,
        scale = &amp;quot;letterbox&amp;quot;
    },
}
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 7:&lt;/span&gt; Main.lua&lt;/h2&gt;
&lt;p&gt;Let&amp;#8217;s write the application!&lt;/p&gt;
&lt;p&gt;Open your prefered Lua editor (any Text Editor will work, but you won&amp;#8217;t have syntax highlighting) and prepare to write your awesome app. Remember to save the file as &lt;em&gt;main.lua&lt;/em&gt; in your project folder.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 8:&lt;/span&gt; Code Structure&lt;/h2&gt;
&lt;p&gt;We&amp;#8217;ll structure our code as if it were a Class. If you know ActionScript or Java, you should find the structure familiar.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
Necesary Classes

Variables and Constants

Declare Functions

    contructor (Main function)

    class methods (other functions)

call Main function
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 9:&lt;/span&gt; Hide Status Bar&lt;/h2&gt;
&lt;pre class="brush: plain; title: ;"&gt;
display.setStatusBar(display.HiddenStatusBar)
&lt;/pre&gt;
&lt;p&gt;This code hides the status bar. The status bar is the bar on top of the device screen that shows the time, signal, and other indicators.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 10:&lt;/span&gt; Import Physics&lt;/h2&gt;
&lt;p&gt;We&amp;#8217;ll use the Physics library to handle collisions. Use this code to import it:&lt;/p&gt;
&lt;pre class="brush: plain; first-line: 14; title: ;"&gt;
local physics = require('physics')
physics.start()
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 11:&lt;/span&gt; Game Background&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
&lt;p&gt;&lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/6.png" alt="" /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;A simple graphic is used as the background for the application interface, the next line of code stores it.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
-- Graphics

-- [Background]

local bg = display.newImage('gameBg.png')
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 12:&lt;/span&gt; Title View&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
&lt;p&gt;&lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/7.png" alt="" /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;This is the Title View, it will be the first interactive screen to appear in our game and these variables will store its components.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
-- [Title View]

local titleBg
local playBtn
local creditsBtn
local titleView
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 13:&lt;/span&gt; Credits View&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/8.png" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;This view will show the credits, version, and copyright of the game. This variable will be used to store it.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
-- [CreditsView]

local creditsView
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 14:&lt;/span&gt; Game View&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
  &lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Balloon-Game/9.png" alt="" /&gt;
&lt;/div&gt;
&lt;p&gt;The game view is composed by the TextFields that store the score, targets, and available acorns. It also displays the balloons, a restart button, and the squirrel that shoots the acorns. Add the following lines to your code to handle these elements. The squirrel and acorn graphics are from &lt;a href="openclipart.org"&gt;openclipart.org&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
-- [Game View]

local gCircle
local squirrel
local infoBar
local restartBtn

-- [TextFields]

local scoreTF
local targetTF
local acornsTF
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 15:&lt;/span&gt; Variables&lt;/h2&gt;
&lt;p&gt;These are the variables we&amp;#8217;ll use. Read the comments in the code to know more about them, some of their names are self-explanatory so there will be no comment there.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
local titleView
local credits
local acorns = display.newGroup() -- stores the acorns thrown
local balloons = {} -- stores the balloons in stage
local impulse = 0 -- used shot the acorn
local dir = 3 -- default direction of the acorn
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 16:&lt;/span&gt; Code Review&lt;/h2&gt;
&lt;p&gt;Here is the full code written in this tutorial alongside with comments to help you identify each part:&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
-- Balloons Physics Game
-- Developed by Carlos Yanez

-- Hide Status Bar

display.setStatusBar(display.HiddenStatusBar)

-- Physics

local physics = require('physics')
physics.start()

-- Graphics

-- [Background]

local bg = display.newImage('gameBg.png')

-- [Title View]

local titleBg
local playBtn
local creditsBtn
local titleView

-- [Credits]

local creditsView

-- [Game View]

local gCircle
local squirrel
local infoBar
local restartBtn

-- [TextFields]

local scoreTF
local targetTF
local acornsTF

-- Load Sound

local pop = audio.loadSound('pop.mp3')

-- Variables

local titleView
local credits
local world
local acorns = display.newGroup()
local contacts
local balloons = {}
local impulse = 0
local dir = 3
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Next Time&amp;#8230;&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;In this part of the series you&amp;#8217;ve learned about the interface and the basic setup of the game. Stay tuned for part two, where we will handle the logic of the application, buttons behavior, and more. See you next time!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_fjAl6ZxPiE-ugAf9nFzx_iWds0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_fjAl6ZxPiE-ugAf9nFzx_iWds0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_fjAl6ZxPiE-ugAf9nFzx_iWds0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_fjAl6ZxPiE-ugAf9nFzx_iWds0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/corona/corona-sdk-create-a-bloons-like-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS SDK: UIView Animations</title>
		<link>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_uiview-animations/</link>
		<comments>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_uiview-animations/#comments</comments>
		<pubDate>Mon, 14 May 2012 18:30:10 +0000</pubDate>
		<dc:creator>C.A. Beninati</dc:creator>
				<category><![CDATA[iOS SDK]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10706</guid>
		<description>&lt;p&gt;This iOS Quick Tip will teach you how to easily animate objects with UIKit. Whether you need sliding menus or flying monkeys, it&amp;#8217;s easy to get it done, and this tip will show you how!&lt;br /&gt;
&lt;!--more--&gt;&lt;br /&gt;
Animation in mobile applications can be a very important feature.  From a practical, UX standpoint, it can let the user know that something has been changed or moved.  From a more entertaining standpoint, it can move game sprites or tile maps around the screen, pulling the user into a fully interactive experience.&lt;/p&gt;
&lt;p&gt;Fortunately, it&amp;#8217;s very easy to get UIView objects moving around in your iOS apps, and you don&amp;#8217;t even have to worry about calculating cryptic geometric equations or other such voodoo!  &lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;UIView Background&lt;/h2&gt;
&lt;p&gt;Before we get into the actual animation, we need to be familiar with the basic animation properties of UIView objects. The following is a list of all such properties as of iOS 5.1:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;center (position on screen)&lt;/li&gt;
&lt;li&gt;frame (position on screen, size, stretching…)&lt;/li&gt;
&lt;li&gt;bounds (size, stretching)&lt;/li&gt;
&lt;li&gt;alpha (transparency)&lt;/li&gt;
&lt;li&gt;transform (rotation, scaling, basically any changes to the UIView)&lt;/li&gt;
&lt;li&gt;backgroundColor&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We don&amp;#8217;t have enough space in this quick tip to go over all of these properties, but we will look at a few of the most common ones: center, alpha, and transform.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Moving UIViews&lt;/h2&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[UIView animateWithDuration:(NSTimeInterval) animations:^(void)animations]
&lt;/pre&gt;
&lt;p&gt;In its most basic form, the above is all you need to animate a UIView.  It’s pretty straightforward- pass a duration (how long the animation will last), and then the properties to be animated (the values that you want the UIView’s properties to have at the end of the animation).&lt;/p&gt;
&lt;p&gt;For a quick example, if we have a UIView called “theView”, and we want to make it fade away until it’s invisible within a .5 second duration, we would call:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[UIView animateWithDuration:0.5f
                            animations:^{
		                    [theView setAlpha:0.0f];
                            }
];
&lt;/pre&gt;
&lt;p&gt;And we’re done! The duration of the animation is set by the &lt;code&gt;animateWithDuration:&lt;/code&gt; parameter, and an Objective-C block of specific animation actions is supplied to the &lt;code&gt;animations:&lt;/code&gt; parameter. It’s just that easy!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Post-Animation Actions&lt;/h2&gt;
&lt;p&gt;Often, we’ll want to do something after the animation finishes.  We’ll take a game for example. Let’s say we want to show a player that they’ve successfully completed an action.  We’ll do this by making a star fly up into the left corner of the screen, and then a point will be added to their score.  There are two things we’ll want to do once the star is finished flying:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Remove the star from the screen (we only want one star visible per point).&lt;/li&gt;
&lt;li&gt;Add a point to the score.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;To do this, we’ll call our animation method with a completion block, like this:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[UIView animateWithDuration:(NSTimeInterval)
                            animations:^(void)animations
                           completion:^(BOOL finished)completion
];
&lt;/pre&gt;
&lt;p&gt;For example, if we have a UIImageView (i.e. a subclass of UIView) called “starImageView”, with an image of a star, and some numeric variable called “points”, we would call:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[UIView animateWithDuration:0.7f
                animations:^
                {
                        [starView setCenter:CGPointMake(0, 0)];
                }
                completion:^(BOOL finished)
                {
                        [starView removeFromSuperView];
                        points++;
                }
];
&lt;/pre&gt;
&lt;p&gt;It&amp;#8217;s worth noting that we’ll need to re-add our “starView” as a subview of our UIView if we want to run this animation again.  You can see this in the sample code provided as an attachment to this Mobiletuts+ tutorial.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Going Beyond&lt;/h2&gt;
&lt;p&gt;Finally, there is a method that will let us define even greater detail on our animation process, including a delay before the animation runs, and setting the type of &amp;#8220;easing&amp;#8221; for our animation.  These &amp;#8220;easing&amp;#8221; types can be found (and described) in the UIView.h header file as enums:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
typedef enum {
    UIViewAnimationCurveEaseInOut,         // slow at beginning and end
    UIViewAnimationCurveEaseIn,            // slow at beginning
    UIViewAnimationCurveEaseOut,           // slow at end
    UIViewAnimationCurveLinear
} UIViewAnimationCurve;
&lt;/pre&gt;
&lt;p&gt;I would encourage you to play around with those, by putting them into the &amp;#8220;options&amp;#8221; parameter of the following animation method:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[UIView animateWithDuration:(NSTimeInterval) delay:(NSTimeInterval) options:(UIViewAnimationOptions)animations:^(void)animations completion:^(BOOL finished)completion];
&lt;/pre&gt;
&lt;p&gt;And once again, using our previous examples combined, we’ll delay our animation by 0.1 seconds, then begin moving it (slowly at first, then speeding up, and then going slowly again at the end).  Also, while we’re moving our image, we’ll fade it out to 0% opacity. Finally, after our animation finishes, we’ll add a point to our score, and remove the image from our UIView.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[UIView animateWithDuration:0.6f
            delay:0.1f
            options:UIViewAnimationCurveEaseInOut
            animations:^{
          	        [starView setCenter:CGPointMake(0, 0)];
           	        [starView setAlpha:0.0f];
            }
            completion:^(BOOL finished){
                        [starView removeFromSuperview];
                        points++;
            }
];
&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;As you can see, it’s super easy to get your UIViews animated, so take some time to play around with the different animatable UIView properties, and see what new things you can discover!&lt;/p&gt;
&lt;p&gt;For extra practice, use the following command to rotate your image:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[starView setTransform:CGAffineTransformRotate(starView.transform, 90.0f)];
&lt;/pre&gt;
&lt;p&gt;Now, see what other things are possible with animations for UIViews!  And remember, there are several subclasses of UIView that can be animated with these same methods and properties, such as (but not limited to):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;UIButton&lt;/li&gt;
&lt;li&gt;UIImageView&lt;/li&gt;
&lt;li&gt;UIButton&lt;/li&gt;
&lt;li&gt;UILabel&lt;/li&gt;
&lt;li&gt;UITableView&lt;/li&gt;
&lt;li&gt;UIScrollView&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2&gt;Resources&lt;/h2&gt;
&lt;p&gt;The star image used in this tutorial was released with a GNU/GPL license from &lt;a href="http://findicons.com/icon/169724/keditbookmarks?id=393835"&gt;FindIcons&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ud6LWrDFn94ngeWN4-V-4vrtqlI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ud6LWrDFn94ngeWN4-V-4vrtqlI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ud6LWrDFn94ngeWN4-V-4vrtqlI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ud6LWrDFn94ngeWN4-V-4vrtqlI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_uiview-animations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working With CorePlot – Tuts+ Premium</title>
		<link>http://mobile.tutsplus.com/tutorials/iphone/working-with-coreplot-tuts-premium-3/</link>
		<comments>http://mobile.tutsplus.com/tutorials/iphone/working-with-coreplot-tuts-premium-3/#comments</comments>
		<pubDate>Sat, 12 May 2012 02:20:47 +0000</pubDate>
		<dc:creator>Aron Bury</dc:creator>
				<category><![CDATA[iOS SDK]]></category>
		<category><![CDATA[CorePlot]]></category>
		<category><![CDATA[Premium]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10702</guid>
		<description>&lt;p&gt;When working with data intensive applications, a developer must often do more than just show lists of data records in a table view. The CorePlot library will allow you to add stunning data visualizations to your applications. Find out how in this Tuts+ Premium series!&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Tutorial Teaser&lt;/h2&gt;
&lt;p&gt;Today we will look at how to make the graph more useful to the user by specifying axis increments and how to format the increment labels. We&amp;#8217;re going to look at different ways we can customize the look and feel of the graph. Finally, we&amp;#8217;re going to discuss how to work with different plots on a single graph. Let&amp;#8217;s get started!&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Step 1: Setting Axis Increments&lt;/h3&gt;
&lt;p&gt;To modify the properties of an X and Y axis we work with the &amp;#8216;CPTXYAxisSet&amp;#8217; and &amp;#8216;CPTXAxis&amp;#8217; objects. Open the STLineGraphViewController.m file and go to the viewDidLoad method. Just below where we work with the plot Space enter the following code:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[[graph plotAreaFrame] setPaddingLeft:20.0f];
[[graph plotAreaFrame] setPaddingTop:10.0f];
[[graph plotAreaFrame] setPaddingBottom:20.0f];
[[graph plotAreaFrame] setPaddingRight:10.0f];
[[graph plotAreaFrame] setBorderLineStyle:nil];

NSNumberFormatter *axisFormatter = [[NSNumberFormatter alloc] init];
[axisFormatter setMinimumIntegerDigits:1];
[axisFormatter setMaximumFractionDigits:0];

CPTMutableTextStyle *textStyle = [CPTMutableTextStyle textStyle];
[textStyle setFontSize:12.0f];

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)[graph axisSet];

CPTXYAxis *xAxis = [axisSet xAxis];
[xAxis setMajorIntervalLength:CPTDecimalFromInt(1)];
[xAxis setMinorTickLineStyle:nil];
[xAxis setLabelingPolicy:CPTAxisLabelingPolicyFixedInterval];
[xAxis setLabelTextStyle:textStyle];
[xAxis setLabelFormatter:axisFormatter];

CPTXYAxis *yAxis = [axisSet yAxis];
[yAxis setMajorIntervalLength:CPTDecimalFromInt(1)];
[yAxis setMinorTickLineStyle:nil];
[yAxis setLabelingPolicy:CPTAxisLabelingPolicyFixedInterval];
[yAxis setLabelTextStyle:textStyle];
[yAxis setLabelFormatter:axisFormatter];
&lt;/pre&gt;
&lt;p&gt;Let&amp;#8217;s go over everything above. First, we are working with a property of the graph called the &amp;#8216;plotAreaFrame&amp;#8217;. With this we are able to set the padding of the area where the graph is actually drawn and it allows us to see the axis labels (which were previously hidden). We then set the Border line style to nil to get rid of the border around the graph.&lt;/p&gt;
&lt;p&gt;We then create an NSNumber formatter which we use to format the axis labels. We also create something called a &amp;#8216;CPTMutableTextStyle&amp;#8217;. When formatting lines, fill section and text for CorePlot objects we use objects such as CPTMutableTextStyle to do it. For now we only set the font size but we can set the font type and color as well.&lt;/p&gt;
&lt;p&gt;We then get a CPTXYAxisSet object from our graph. This axisSet contains an xAxis and a yAxis (both objects of type &amp;#8216;CPTXYAxis&amp;#8217;). We then set a variety of properties on each axis. The major interval length sets what the interval at each main tick will be. We also want to get rid of the minor ticks so we set the line style to nil. We set the labellingPolicy to fixed intervals. We then set the text style for the CPTMutableTextStyle object we created earlier and the label formatter to the NSNumberFormatter we created.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://tutsplus.s3.amazonaws.com/tutspremium/mobile-dev/iOS-SDK_CorePlot/3/graphView.png" title="graph view" /&gt;
&lt;/div&gt;
&lt;p&gt;Now try going to the student view and adding a student. Afterward you can go back to the graph and you should see it change. However, it still looks a bit bland&amp;#8230;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Get the Full Series!&lt;/h2&gt;
&lt;p&gt;This tutorial series is available to &lt;a href="http://tutsplus.com/"&gt;Tuts+ Premium members only&lt;/a&gt;. Read a &lt;a href="http://tutsplus.com/tutorial/working-with-coreplot-styling-and-adding-plots/"&gt;preview of this tutorial&lt;/a&gt; on the Tuts+ Premium web site or &lt;a href="http://tutsplus.com/amember/login.php"&gt;login&lt;/a&gt; to Tuts+ Premium to access the full content. &lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Joining Tuts+ Premium. . .&lt;/h2&gt;
&lt;p&gt;For those unfamiliar, the family of &lt;a href="http://tutsplus.com"&gt;Tuts+&lt;/a&gt; sites runs a premium membership service called Tuts+ Premium. For $19 per month, you gain access to exclusive premium tutorials, screencasts, and freebies from &lt;a href="http://mobile.tutsplus.com"&gt;Mobiletuts+&lt;/a&gt;, &lt;a href="http://net.tutsplus.com"&gt;Nettuts+&lt;/a&gt;, &lt;a href="http://ae.tutsplus.com"&gt;Aetuts+&lt;/a&gt;, &lt;a href="http://audio.tutsplus.com"&gt;Audiotuts+&lt;/a&gt;, &lt;a href="http://vector.tutsplus.com"&gt;Vectortuts+&lt;/a&gt;, and &lt;a href="http://cg.tutsplus.com"&gt;CgTuts+&lt;/a&gt;. You&amp;#8217;ll learn from some of the best minds in the business. &lt;a href="http://tutsplus.com/mobile-premium/"&gt;Become a premium member&lt;/a&gt; to access this tutorial, as well as hundreds of other advanced tutorials and screencasts.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/21DmwOh_jvTH6wGUeuP7KponDH8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/21DmwOh_jvTH6wGUeuP7KponDH8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/21DmwOh_jvTH6wGUeuP7KponDH8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/21DmwOh_jvTH6wGUeuP7KponDH8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/iphone/working-with-coreplot-tuts-premium-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C Categories</title>
		<link>http://mobile.tutsplus.com/tutorials/iphone/objective-c-categories/</link>
		<comments>http://mobile.tutsplus.com/tutorials/iphone/objective-c-categories/#comments</comments>
		<pubDate>Thu, 10 May 2012 14:24:41 +0000</pubDate>
		<dc:creator>Aaron Crabtree</dc:creator>
				<category><![CDATA[iOS SDK]]></category>
		<category><![CDATA[Categories]]></category>
		<category><![CDATA[Objective-C]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10648</guid>
		<description>&lt;p&gt;Categories provide the ability to add functionality to an object without subclassing or changing the actual object. A handy tool, they are often used to add methods to existing classes, such as &lt;code&gt;NSString&lt;/code&gt; or your own custom objects.&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;
Step 1: Set Up Your Project&lt;br /&gt;
&lt;/h2&gt;
&lt;p&gt;Launch Xcode and click File &amp;gt; New &amp;gt; Project. Choose an iOS Single View Application from the window and click &amp;quot;Next.&amp;quot; Name your product &amp;quot;Categories&amp;quot; and enter a name for your Company Identifier, such as &amp;quot;com.companyName.categories.&amp;quot; Choose the iPhone device family and click &amp;quot;Next.&amp;quot; Choose a location to store your project and click &amp;quot;Create.&amp;quot;&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
&lt;img src="https://d339vfjsz5zott.cloudfront.net/Objective-C_Categories/Objective-C_Categories_01.png" /&gt;
&lt;/div&gt;
&lt;hr /&gt;
&lt;h2&gt;
Step 2: Create the Category&lt;br /&gt;
&lt;/h2&gt;
&lt;p&gt;Now that your project is set up, let&amp;#39;s create a category that adds additional functionality to the &lt;code&gt;NSString&lt;/code&gt; class. Click File &amp;gt; New &amp;gt; File and choose a Cocoa Touch Objective-C category from the window. Click &amp;quot;Next.&amp;quot; Name your category &amp;quot;RemoveNums&amp;quot; and select &lt;code&gt;NSString&lt;/code&gt; from the &amp;quot;Category on&amp;quot; drop down menu (you may need to type this in manually). Click &amp;quot;Next&amp;quot; followed by &amp;quot;Create.&amp;quot; &lt;/p&gt;
&lt;div class="tutorial_image"&gt;
&lt;img src="https://d339vfjsz5zott.cloudfront.net/Objective-C_Categories/Objective-C_Categories_02.png" /&gt;
&lt;/div&gt;
&lt;h3&gt;
Declare the Category Method&lt;br /&gt;
&lt;/h3&gt;
&lt;p&gt;Back in your Xcode project, click &amp;quot;NSString+RemoveNums.h&amp;quot; to view the new category&amp;#39;s header file. Add the following code to the interface to declare the method.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
@interface NSString (RemoveNums)
- (NSString *)removeNumbersFromString:(NSString *)string;
@end
&lt;/pre&gt;
&lt;h3&gt;
Implement the Category Method&lt;br /&gt;
&lt;/h3&gt;
&lt;p&gt;Click &amp;quot;NSString+RemoveNums.m&amp;quot; to view the category&amp;#39;s implementation file. Add the following code to create a method that will remove all the numbers from an &lt;code&gt;NSString&lt;/code&gt;. First we define an &lt;code&gt;NSCharacterSet&lt;/code&gt; of the numbers zero through nine which we&amp;#39;ll use as a reference to compare against the original input string. In this case, the original string &amp;quot;ABC 123&amp;quot; will have the numbers &amp;quot;123&amp;quot; removed from the string because the category method uses the &lt;code&gt;NSString&lt;/code&gt; method &lt;code&gt;stringByTrimmingCharactersInSet:&lt;/code&gt;.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (NSString *)removeNumbersFromString:(NSString *)string
{
    NSString *trimmedString = nil;
    NSCharacterSet *numbersSet = [NSCharacterSet characterSetWithCharactersInString:@&amp;quot;0123456789&amp;quot;];
    trimmedString = [string stringByTrimmingCharactersInSet:numbersSet];
    return trimmedString;
}
&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2&gt;
Step 3: Import the Category&lt;br /&gt;
&lt;/h2&gt;
&lt;p&gt;Click &amp;quot;ViewController.h&amp;quot; and import the category by adding the following code.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
#import &amp;quot;NSString+RemoveNums.h&amp;quot;
&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2&gt;
Step 4: Test the Category&lt;br /&gt;
&lt;/h2&gt;
&lt;p&gt;Click &amp;quot;ViewController.m&amp;quot; and add the following code to the &lt;code&gt;viewDidLoad&lt;/code&gt; method. The local variable &lt;code&gt;stringWithNums&lt;/code&gt; contains a combination of letters and numbers. The next line takes the string variable and runs it through the category method &lt;code&gt;removeNumbersFromString&lt;/code&gt;. Finally, &lt;code&gt;NSLog&lt;/code&gt; outputs the returned value of the newly trimmed string without any numbers.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
NSString *stringWithNums = @&amp;quot;ABC 123&amp;quot;;
NSLog(@&amp;quot;stringWithNums         --&amp;gt; %@&amp;quot;,stringWithNums);
stringWithNums = [stringWithNums removeNumbersFromString:stringWithNums];
NSLog(@&amp;quot;trimmed stringWithNums --&amp;gt; %@&amp;quot;,stringWithNums);
&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2&gt;
Step 5: Use the Category Method&lt;br /&gt;
&lt;/h2&gt;
&lt;p&gt;Click Product &amp;gt; Run, or click the &amp;quot;Run&amp;quot; arrow in the top left corner, to test the code. Notice the console shows the original input string, &amp;quot;ABC 123,&amp;quot; as well as the string after it has been altered by the category method and the numbers have been removed.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
 &lt;img src="https://d339vfjsz5zott.cloudfront.net/Objective-C_Categories/Objective-C_Categories_03.png" /&gt;
 &lt;/div&gt;
&lt;h2&gt;
Conclusion&lt;br /&gt;
&lt;/h2&gt;
&lt;p&gt;Subclassing is one way to add functionality to an object, but avoiding unnecessary subclassing by using a category will help reduce the amount of code and keep your projects more organized. There are a number of scenarios where using a category is beneficial. Share your category scenarios in the comments below. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jCPNdLwqeFnLjbER4uX5al74jGo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jCPNdLwqeFnLjbER4uX5al74jGo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jCPNdLwqeFnLjbER4uX5al74jGo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jCPNdLwqeFnLjbER4uX5al74jGo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/iphone/objective-c-categories/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Which Tuts+ Site Should We Launch Next?</title>
		<link>http://mobile.tutsplus.com/articles/news/which-tuts-site-should-we-launch-next/</link>
		<comments>http://mobile.tutsplus.com/articles/news/which-tuts-site-should-we-launch-next/#comments</comments>
		<pubDate>Thu, 10 May 2012 11:30:57 +0000</pubDate>
		<dc:creator>David Appleyard</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[launch]]></category>
		<category><![CDATA[Poll]]></category>
		<category><![CDATA[tuts]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10667</guid>
		<description>&lt;p&gt;We&amp;#8217;re planning our next few Tuts+ sites, and would love your opinion and advice on which topics you think we should cover next! We&amp;#8217;d be really grateful if you could take a minute to answer our quick poll and share your thoughts&amp;#8230;&lt;/p&gt;
&lt;p&gt;&lt;!--more--&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Have Your Say&lt;/h2&gt;
&lt;div style="float:right; margin:0 0 0 20px;"&gt;&lt;script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6211918.js"&gt;&lt;/script&gt;&lt;br /&gt;
&lt;noscript&gt;&lt;a href="http://polldaddy.com/poll/6211918/"&gt;Mobiletuts+ Readers: Which Tuts+ Site Should We Launch Next?&lt;/a&gt;&lt;/noscript&gt;&lt;/div&gt;
&lt;p&gt;We&amp;#8217;ve been considering lots of different ideas for our next Tuts+ sites over the past few weeks, and wanted to also ask the opinion of our awesome community!&lt;/p&gt;
&lt;p&gt;A selection of different concepts are included in the poll to the right, along with the option for you to submit your own ideas as well.&lt;/p&gt;
&lt;p&gt;The important thing to note is that these are just ideas. Some of these are close to making our final cut, and others aren&amp;#8217;t&amp;#8230; We&amp;#8217;d love to hear what you think, to help guide our decision.&lt;/p&gt;
&lt;p&gt;Thanks for taking the time to offer your suggestion — I can&amp;#8217;t wait to see what you have to say!&lt;/p&gt;
&lt;h3&gt;Win a 6-Month Tuts+ Premium Membership&lt;/h3&gt;
&lt;p&gt;Our poll will be running for the next couple of weeks, and we&amp;#8217;ll be choosing one respondent at random to receive a six-month Tuts+ Premium membership!&lt;/p&gt;
&lt;p&gt;To be entered into the giveaway, just leave a comment on this post to go into a bit more detail about your site suggestion. We&amp;#8217;ll choose one comment at random to win the Tuts+ Premium membership when the poll ends.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Best of luck!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/iGKP5MhZrdyzXz3yEK0KstE2NE0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iGKP5MhZrdyzXz3yEK0KstE2NE0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/iGKP5MhZrdyzXz3yEK0KstE2NE0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iGKP5MhZrdyzXz3yEK0KstE2NE0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/articles/news/which-tuts-site-should-we-launch-next/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Analyzing Android Network Traffic</title>
		<link>http://mobile.tutsplus.com/tutorials/android/analyzing-android-network-traffic/</link>
		<comments>http://mobile.tutsplus.com/tutorials/android/analyzing-android-network-traffic/#comments</comments>
		<pubDate>Wed, 09 May 2012 13:54:02 +0000</pubDate>
		<dc:creator>Maria Garcia Cerdeno</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Android SDK]]></category>
		<category><![CDATA[Wireshark]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10663</guid>
		<description>&lt;p&gt;Network traffic analysis can be a vital part of the software debugging and testing process. This tutorial will teach you how to monitor all incoming and outgoing traffic on an Android device in order to better debug your applications!&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;As a developer, one often has to build software that performs HTTP requests, sends messages, or grabs information from incoming or outgoing requests over the network.  When these network transactions work from the very beginning, all is good; we are receiving exactly what is expected and what we are sending is proper formatted and with the correct values.&lt;/p&gt;
&lt;p&gt;However, this frequently does not happen, and one needs to understand exactly what is being sent and received over the network in order to determine what has gone wrong. Who knows, maybe the request is not even being made and we are not aware of it! This is a circumstance in which  knowing how to capture and analyze the network traffic becomes crucial.&lt;/p&gt;
&lt;p&gt;Capturing network traffic for later analysis is good, but it&amp;#8217;s even better if we are able to perform this analysis at the same time the capture is taking place.  By doing so, one can know which request or response corresponds to each use case, thus making the analysis much easier.  In the following steps, I will show you how to capture real time traffic from an Android device and pipe it to a network analyzer like &lt;a href="http://www.wireshark.org"&gt;Wireshark&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 1:&lt;/span&gt; Installing &lt;i&gt;tcpdump&lt;/i&gt;&lt;/h2&gt;
&lt;p&gt;The first step is to install &lt;i&gt;tcpdump&lt;/i&gt; on the device.  &lt;i&gt;tcpdump&lt;/i&gt; is a command-line utility that captures the traffic on a particular network device and dumps it to the filesystem.  &lt;i&gt;tcpdump&lt;/i&gt; can be downloaded from &lt;a href="http://www.tcpdump.org"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Once the &lt;i&gt;tcpdump&lt;/i&gt; binary has been downloaded, all we need to do is use adb to push the file onto the device.  To be able to do so, your handset needs to be connected to and properly identified by your computer.&lt;/p&gt;
&lt;p&gt;First things first, it is important that you update your path adding Android&amp;#8217;s SDK platform-tools directory to it if you haven&amp;#8217;t yet.  In case you have never done it, there are clear instructions on how to do so on the &lt;a href="http://developer.android.com/sdk/installing.html"&gt;android developers page&lt;/a&gt;.  Ready? Open a terminal and type the following:&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
adb devices
&lt;/pre&gt;
&lt;p&gt;The connected device should show up in a list.  If this is not the case, make sure that it is correctly connected and that you have all the drivers needed for that specific handset.&lt;/p&gt;
&lt;p&gt;See the device on the list? Great! We are now ready to push the &lt;i&gt;tcpdump&lt;/i&gt; file onto it:&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
adb push /home/tcpdump /data/local
&lt;/pre&gt;
&lt;p&gt;To perform the next few steps we need to gain root privileges on the device and make sure that &lt;i&gt;tcpdump&lt;/i&gt; is executable:&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
adb shell
cd data/local
su
chmod 777 tcpdump
&lt;/pre&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 2:&lt;/span&gt; Saving the Traffic Dump to File&lt;/h2&gt;
&lt;p&gt;Tcpdump can now be started from the same adb shell and the output saved to a file:&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
./tcpdump -s 0 -v -w out.pcap
&lt;/pre&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/Android-SDK_Wireshark_Traffic-Analysis/tcpdump_to_file.png" /&gt;
&lt;/div&gt;
&lt;p&gt;The complete list of tcpdump options can be found in the man page of &lt;a href="http://www.tcpdump.org/tcpdump_man.html"&gt;&lt;i&gt;tcpdump&lt;/i&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Once the dump is completed, we can stop capturing the data.  In order to do so, you simply need to press Ctrl+C.  The resulting file can be pulled out of the device and saved locally, so that it can get analyzed using &lt;i&gt;Wireshark&lt;/i&gt;.&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
adb pull /data/local/out.pcap /home/out.pcap
&lt;/pre&gt;
&lt;p&gt;But this is not exactly what we wanted, is it? What we want is to be able to pipe it to &lt;i&gt;Wireshark&lt;/i&gt; in real time! Relax, we are getting there.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 3:&lt;/span&gt; Piping Network Traffic to a Port&lt;/h2&gt;
&lt;p&gt;The process of capturing the network packets is basically the same in this case.  However, instead of writing the datagrams to a file, we want to write them to the standard output, so that we can then redirect them using &lt;a href="http://netcat.sourceforge.net"&gt;&lt;i&gt;netcat&lt;/i&gt;&lt;/a&gt; to a specific port on the handset.&lt;/p&gt;
&lt;p&gt;In order to do so, the tcpdump command has to change slightly:&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
adb shell &amp;quot;./data/local/tcpdump -n -s 0 -w - | nc -l -p 12345&amp;quot;
&lt;/pre&gt;
&lt;p&gt;The traffic is now being redirected to the port 12345 in the handset.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 4:&lt;/span&gt; Installing Netcat&lt;/h2&gt;
&lt;p&gt;Before going any further, lets make sure that you have &lt;i&gt;netcat&lt;/i&gt; installed, as we are going to need it.  Type nc in a new console, hit enter and look at what happens.  Do you get the standard message explaining how to use the command? Awesome, you are good to go.  Skip the rest of this section and keep going!&lt;/p&gt;
&lt;p&gt;Still reading? Well, I guess that means you do not have &lt;i&gt;netcat&lt;/i&gt; installed after all.  Do not panic, you can download it from &lt;a href="http://www.securityfocus.com/tools/139"&gt;here&lt;/a&gt; for Windows.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 5:&lt;/span&gt; Piping Traffic to &lt;i&gt;Wireshark&lt;/i&gt;&lt;/h2&gt;
&lt;p&gt;Remember what we mentioned earlier regarding updating the path so that &lt;i&gt;adb&lt;/i&gt; would be available? You want to do that with &lt;i&gt;netcat&lt;/i&gt; and &lt;i&gt;Wireshark&lt;/i&gt; as well.&lt;/p&gt;
&lt;p&gt;Once this is done, we can use &lt;i&gt;adb&lt;/i&gt;&amp;#8216;s forward option, which will forward the packets from the tcp port 12345 in the device to the tcp port 54321 on the PC.  We will again use netcat to grab those incoming packets coming in through port 54321, and pipe them to &lt;i&gt;Wireshark&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;This is done in the following command, typed in a new console:&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
adb forward tcp:12345 tcp:54321 &amp;amp;&amp;amp; nc 127.0.0.1 54321 | wireshark -k -S -i -
&lt;/pre&gt;
&lt;p&gt;Note that the number of the port chosen is irrelevant.  The only reason why different numbers have been chosen is to show how the different commands connect to each other.  The same port number could have been used for both commands (or different numbers from the above, as long as the ports are not being used!) and then they would work just the same.&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
&lt;img src="https://d339vfjsz5zott.cloudfront.net/Android-SDK_Wireshark_Traffic-Analysis/piping_two_terminals_scaled.png"/&gt;
&lt;/div&gt;
&lt;p&gt;You need to make sure that &lt;i&gt;Wireshark&lt;/i&gt; runs with the correct permissions.  Otherwise, even when &lt;i&gt;Wireshark&lt;/i&gt; gets opened, a popup will show up informing you of an exception.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;&lt;span&gt;Step 6:&lt;/span&gt; Making Life Easier&lt;/h2&gt;
&lt;p&gt;Once the different utilities have been set up, the process of capturing the network traffic and piping it into &lt;i&gt;Wireshark&lt;/i&gt; is done through two commands, simultaneously running in two different terminals:&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
adb shell &amp;quot;./data/local/tcpdump -n -s 0 -w - | nc -l -p 12345&amp;quot;
adb forward tcp:12345 tcp:54321 &amp;amp;&amp;amp; nc 127.0.0.1 54321 | wireshark -k -S -i -
&lt;/pre&gt;
&lt;p&gt;Now, this process is still pretty manual.  One has to manually open two terminals and type all those instructions, making sure nothing is left behind for this to work.  This is a nuisance.  Well, that problem is easily solved by putting these instructions onto a script, so that it does all the work for us.&lt;/p&gt;
&lt;p&gt;Windows users can automate the process using the script in the download file attached to this post.&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
start adb shell &amp;quot;./data/local/tcpdump -n -s 0 -w - | nc -l -p 12345&amp;quot;
adb forward tcp:12345 tcp:54321 &amp;amp;&amp;amp; nc 127.0.0.1 54321 | wireshark -k -S -i -
&lt;/pre&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/Android-SDK_Wireshark_Traffic-Analysis/piping_one_terminal_scaled.png"/&gt;
    &lt;/div&gt;
&lt;hr /&gt;
&lt;h2&gt;Notes for Mac Users&lt;/h2&gt;
&lt;p&gt;If you&amp;#8217;ve been following this tutorial on a Mac, you are probably scratching your head, thinking why the above process does not really seem to be working for you.  There are a couple of reasons why this might be the case.  Let&amp;#8217;s try to fix that.&lt;/p&gt;
&lt;p&gt;First of all, make sure that you are using the right path of &lt;i&gt;Wireshark&lt;/i&gt;! This might seem trivial, but is is not.  You do not want to use the path to the app, but the whole path to the actual &lt;i&gt;Wireshark&lt;/i&gt; executable (e.g. &amp;#8220;/Applications/Wireshark.app/Contents/Resources/bin/wireshark&amp;#8221;).&lt;/p&gt;
&lt;p&gt;Fixed? Good! Just a couple more things to go.  When invoking &lt;i&gt;Wireshark&lt;/i&gt; through the command line, we are using a minus sign at the end.  This represents the standard input and in Windows it will work just fine.  However, this will not work on a Mac.  Luckily, this can be substituted with the name of a pipe.  You want to specify 2 (corresponding to lo0) as the pipe to use.  Besides, you might need to grant super user permissions in order to be able to execute &lt;i&gt;Wireshark&lt;/i&gt;.  This is the resulting command that you want to use:&lt;/p&gt;
&lt;pre class="brush: bash; title: ;"&gt;
adb forward tcp:12345 tcp:54321 &amp;amp;&amp;amp; nc 127.0.0.1 54321 | sudo wireshark -k -S -i 2
&lt;/pre&gt;
&lt;p&gt;This is the perl script that will work for Mac users (it is also attached as a download to this post):
&lt;pre class="brush: perl; title: ;"&gt;

#!/usr/bin/perl

# Perform adb command on shell
# to check if the device is attached
$netstat = `adb shell 'netstat' 2&amp;gt;&amp;amp;1`;
if($netstat =~ m/error: device not found/)
{
die(&amp;quot;Plug in your phone!\n&amp;quot;);
}

# Gain root priviledges
open(SUDO, &amp;quot;|sudo echo ''&amp;quot;);
close(SUDO);

# Redirect STDERR output to STDOUT
open STDERR, '&amp;gt;&amp;amp;STDOUT';

# Perform tcpdump and nc in background
open(COMMAND1, &amp;quot;(adb shell \&amp;quot;data/local/tcpdump -n -s 0 -w - | nc -l -p 12345\&amp;quot;) |&amp;quot;);

# Perform piping to wireshark
open(COMMAND2, &amp;quot;((adb forward tcp:12345 tcp:54321 &amp;amp;&amp;amp; nc 127.0.0.1 54321 | sudo wireshark -k -S -i 2) &amp;amp;) 2&amp;gt;&amp;amp;1 &amp;gt; /dev/null |&amp;quot;);

# Make sure the exit message appears after wireshark has been launched (hacky)
sleep(5);
print(&amp;quot;Press ctrl-c to exit...&amp;quot;);
&amp;lt;STDIN&amp;gt;;
&lt;/pre&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/g1bmQ0NuHHvPhQjyQdA-_wk-OKY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/g1bmQ0NuHHvPhQjyQdA-_wk-OKY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/g1bmQ0NuHHvPhQjyQdA-_wk-OKY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/g1bmQ0NuHHvPhQjyQdA-_wk-OKY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/android/analyzing-android-network-traffic/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Working With CorePlot – Tuts+ Premium</title>
		<link>http://mobile.tutsplus.com/tutorials/iphone/working-with-coreplot-tuts-premium-2/</link>
		<comments>http://mobile.tutsplus.com/tutorials/iphone/working-with-coreplot-tuts-premium-2/#comments</comments>
		<pubDate>Tue, 08 May 2012 04:12:26 +0000</pubDate>
		<dc:creator>Aron Bury</dc:creator>
				<category><![CDATA[iOS SDK]]></category>
		<category><![CDATA[Premium]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10657</guid>
		<description>&lt;p&gt;When working with data intensive applications, a developer must often do more than just show lists of data records in a table view. The CorePlot library will allow you to add stunning data visualisations to your applications. Find out how in this Tuts+ Premium series!&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Tutorial Teaser&lt;/h2&gt;
&lt;h3&gt;Where We Left Off&lt;/h3&gt;
&lt;p&gt;Last time &lt;a href="http://tutsplus.com/tutorial/working-with-coreplot-project-setup/"&gt;we introduced the CorePlot framework&lt;/a&gt; and discussed what it can do and how we can use it to enhance data visualisation in our applications. We also explored the sample application we&amp;#8217;re going to create in the series and how to add CorePlot to our Application. For a code snapshot of where we left off last time, download the source code for this tutorial (otherwise feel free to use your existing code base and save yourself the download time!).&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Step 1. Setting Things Up&lt;/h3&gt;
&lt;p&gt;Before we can create a graph we&amp;#8217;ll need a view to do it in. We&amp;#8217;re going to allow the user to click on a UIBarButtonItem in the &amp;#8216;Students&amp;#8217; tab that will bring up an action sheet containing a list of graphs for the user to choose. Once a selection is made a modal view will display a graph with the relevant data on it.&lt;/p&gt;
&lt;p&gt;We&amp;#8217;re going to create a new group called &amp;#8216;Graphing&amp;#8217; underneath the &amp;#8216;StudentTracker&amp;#8217; group. Create a &amp;#8216;Views&amp;#8217; and &amp;#8216;Controllers&amp;#8217; group underneath this like in the &amp;#8216;Student Listing&amp;#8217; and &amp;#8216;Subject Listing&amp;#8217;.&lt;/p&gt;
&lt;p&gt;Create a new class called &amp;#8216;STLineGraphViewController&amp;#8217; (subclassing UIViewController) in the &amp;#8216;View Controllers&amp;#8217; group. When choosing where to add the files the best place to put them is the &amp;#8216;Classes/Graphing/View Controllers&amp;#8217; folder (You will have to create the &amp;#8216;Graphing/View Controllers&amp;#8217; directory).&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
&lt;img src="https://tutsplus.s3.amazonaws.com/tutspremium/mobile-dev/iOS-SDK_CorePlot/2/addingTheVC.png" title="Adding the View Controller" /&gt;
&lt;/div&gt;
&lt;p&gt;We are going to come back and work on customizing this later. Right now we&amp;#8217;re going to implement that code that allows the user to select a graph to look at.&lt;/p&gt;
&lt;p&gt;First open up STStudentListViewController.h and add the &amp;#8216;UIActionSheetDelegate&amp;#8217; and &amp;#8216;STLineGraphViewControllerDelegate&amp;#8217; protocol declarations. This protocol doesn&amp;#8217;t exist yet but we will create it later (Also make sure you import the &amp;#8216;STLineGraphViewController.h&amp;#8217; file).&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
@interface STStudentListViewController : UIViewController &amp;lt;UITableViewDelegate, UITableViewDataSource, AddStudentViewControllerDelegate, UIActionSheetDelegate, STLineGraphViewControllerDelegate&amp;gt;
&lt;/pre&gt;
&lt;p&gt;Next, open the .m file and implement the &amp;#8216;actionSheet: clickedButtonAtIndex:&amp;#8217; method with the following code:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        STLineGraphViewController *lineGraphVC = [[STLineGraphViewController alloc] init];
        [lineGraphVC setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
        [lineGraphVC setDelegate:self];
        [lineGraphVC setManagedObjectContext:[self managedObjectContext]];

        [self presentModalViewController:lineGraphVC animated:YES];
        [lineGraphVC release];
    }
}
&lt;/pre&gt;
&lt;p&gt;This code shouldn&amp;#8217;t need too much explaining. We are simply creating a LineGraph View Controller and presenting it modally. We set ourselves as the delegate so that we know when to dismiss the modal view. We also give the view controller a managed object context to work with so it can interface with core data. These last two methods will create a warning (or error if using ARC) because the properties don&amp;#8217;t exist yet, but we will be creating them later.&lt;/p&gt;
&lt;p&gt;Next we&amp;#8217;ll create a method to call the action sheet and add a UITabBarItem to call it from. Add a method declaration in the .m interface called &amp;#8216;graphButtonWasSelected:&amp;#8217;:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
@interface STStudentListViewController ()
@property (nonatomic, strong) NSArray *studentArray;

- (void)addStudent:(id)sender;
- (void)graphButtonWasSelected:(id)sender;
@end
&lt;/pre&gt;
&lt;p&gt;Next, add the method implementation:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)graphButtonWasSelected:(id)sender
{
UIActionSheet *graphSelectionActionSheet = [[[UIActionSheet alloc] initWithTitle:@&amp;quot;Choose a graph&amp;quot; delegate:self cancelButtonTitle:@&amp;quot;Cancel&amp;quot; destructiveButtonTitle:nil otherButtonTitles:@&amp;quot;Enrolment over time&amp;quot;, nil] autorelease];

	[graphSelectionActionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
}
&lt;/pre&gt;
&lt;p&gt;Next we need to add a UIBarButtonItem for the user to select when they want to view the graph. We&amp;#8217;ll do this in the viewDidLoad method underneath where we create the right bar button item:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
[[self navigationItem] setLeftBarButtonItem:[[[UIBarButtonItem alloc] initWithTitle:@&amp;quot;Graphs&amp;quot; style:UIBarButtonItemStylePlain target:self action:@selector(graphButtonWasSelected:)] autorelease] animated:NO];
&lt;/pre&gt;
&lt;p&gt;Finally, we need to implement a STLineGraphViewController protocol method that will tell the controller to dismiss the modal view when the user is done looking at the graph:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)doneButtonWasTapped:(id)sender
{
    [self dismissModalViewControllerAnimated:YES];
}
&lt;/pre&gt;
&lt;p&gt;Now we&amp;#8217;re ready to start creating the graph!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Get the Full Series!&lt;/h2&gt;
&lt;p&gt;This tutorial series is available to &lt;a href="http://tutsplus.com/"&gt;Tuts+ Premium members only&lt;/a&gt;. Read a &lt;a href="http://tutsplus.com/tutorial/working-with-coreplot-coreplot-fundamentals/"&gt;preview of this tutorial&lt;/a&gt; on the Tuts+ Premium web site or &lt;a href="http://tutsplus.com/amember/login.php"&gt;login&lt;/a&gt; to Tuts+ Premium to access the full content. &lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;Joining Tuts+ Premium. . .&lt;/h2&gt;
&lt;p&gt;For those unfamiliar, the family of &lt;a href="http://tutsplus.com"&gt;Tuts+&lt;/a&gt; sites runs a premium membership service called Tuts+ Premium. For $19 per month, you gain access to exclusive premium tutorials, screencasts, and freebies from &lt;a href="http://mobile.tutsplus.com"&gt;Mobiletuts+&lt;/a&gt;, &lt;a href="http://net.tutsplus.com"&gt;Nettuts+&lt;/a&gt;, &lt;a href="http://ae.tutsplus.com"&gt;Aetuts+&lt;/a&gt;, &lt;a href="http://audio.tutsplus.com"&gt;Audiotuts+&lt;/a&gt;, &lt;a href="http://vector.tutsplus.com"&gt;Vectortuts+&lt;/a&gt;, and &lt;a href="http://cg.tutsplus.com"&gt;CgTuts+&lt;/a&gt;. You&amp;#8217;ll learn from some of the best minds in the business. &lt;a href="http://tutsplus.com/mobile-premium/"&gt;Become a premium member&lt;/a&gt; to access this tutorial, as well as hundreds of other advanced tutorials and screencasts.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/EPvseY1sE0i5e_zZ2aTW9Rqxo_Q/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EPvseY1sE0i5e_zZ2aTW9Rqxo_Q/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/EPvseY1sE0i5e_zZ2aTW9Rqxo_Q/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/EPvseY1sE0i5e_zZ2aTW9Rqxo_Q/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/iphone/working-with-coreplot-tuts-premium-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS SDK: NSNotification</title>
		<link>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_nsnotificationcenter/</link>
		<comments>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_nsnotificationcenter/#comments</comments>
		<pubDate>Mon, 07 May 2012 14:47:27 +0000</pubDate>
		<dc:creator>Aaron Crabtree</dc:creator>
				<category><![CDATA[iOS SDK]]></category>
		<category><![CDATA[NSNotification]]></category>
		<category><![CDATA[NSNotificationCenter]]></category>
		<category><![CDATA[Tips]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10619</guid>
		<description>&lt;p&gt;In today&amp;#8217;s quick tip, you&amp;#8217;ll learn about the NSNotification class while building a demo project to monitor changes in the device orientation. Let&amp;#8217;s get started!&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;
&lt;p&gt;Ordering from a food cart is a lot like working with an &lt;code&gt;NSNotification&lt;/code&gt;. You walk up to the counter, place your order, get a number, and wait for your number to be called. You usually stand around with five other people who are waiting for their number to be called, too. And when the chef is finished preparing your meal, the person behind the counter calls your number, and you sit down to eat. With &lt;code&gt;NSNotification&lt;/code&gt;, you become an observer for &amp;quot;your number,&amp;quot; and when the object posting the notification is done &amp;quot;making your food,&amp;quot; &lt;code&gt;NSNotificationCenter&lt;/code&gt; calls your number so you can come get your &amp;quot;food&amp;quot;. In this tutorial, instead of waiting for food, we&amp;#39;re going to wait for the device to rotate and then send the current orientation to the observer. We&amp;#39;ll talk about how to register to receive a notification, post a notification, and pass a string object along with the notification using &lt;code&gt;userInfo&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Step 1: Set Up Your Project&lt;/h3&gt;
&lt;p&gt;Launch Xcode and click File &amp;gt; New &amp;gt; Project. Select an iOS Single View Application and click &amp;quot;Next&amp;quot;. Name your product &amp;quot;Notifications&amp;quot; and enter a name for your Company Identifier, such as &amp;quot;com.companyName.notifications.&amp;quot; Choose the iPhone device family and click &amp;quot;Next.&amp;quot; Choose a location to store your project and click &amp;quot;Create.&amp;quot;&lt;/p&gt;
&lt;div class="tutorial_image"&gt;
    &lt;img src="https://d339vfjsz5zott.cloudfront.net/iOS-SDK_NSNotification/iOS-SDK_NSNotification_NoteTut_01.png" /&gt;
&lt;/div&gt;
&lt;hr /&gt;
&lt;h3&gt;Step 2: Register to Receive a Notification&lt;/h3&gt;
&lt;p&gt;Declare the methods used to post and receive the notification by typing the following code in the &amp;quot;ViewController.m&amp;quot; file.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
@interface ViewController ()
    - (void)postNotificationWithString:(NSString *)orientation;
    - (void)useNotificationWithString:(NSNotification*)notification;
@end
&lt;/pre&gt;
&lt;h4&gt;Receiving the Notification&lt;/h4&gt;
&lt;p&gt;Now we can register the &lt;code&gt;ViewController&lt;/code&gt; object to receive notifications. Type the following code into the &lt;code&gt;viewDidLoad&lt;/code&gt; method.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
NSString *notificationName = @&amp;quot;MTPostNotificationTut&amp;quot;;

[[NSNotificationCenter defaultCenter]
    addObserver:self
    selector:@selector(useNotificationWithString:)
    name:notificationName
    object:nil];
&lt;/pre&gt;
&lt;p&gt;There are four important parts of the &lt;code&gt;NSNotificationCenter&lt;/code&gt; method &lt;code&gt;addObserver:selector:name:object:&lt;/code&gt;. The argument for &lt;code&gt;addObserver:&lt;/code&gt; is the object that wants to know when a certain notification happens. The argument for &lt;code&gt;selector:&lt;/code&gt; is the method that gets called when the notification happens. The argument for &lt;code&gt;name:&lt;/code&gt; is the title of the notification the observer wants to know about; it must be unique. The final piece of the method is &lt;code&gt;object:&lt;/code&gt;. Its argument is the object attached to the notification and is often &lt;code&gt;nil&lt;/code&gt; depending on the context of the notification.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Step 3: Post a Notification&lt;/h3&gt;
&lt;p&gt;Next we&amp;#39;ll generate the logic for posting a notification. Type the following code in the &amp;quot;ViewController.m&amp;quot; file. The custom method &lt;code&gt;postNotificationWithString:&lt;/code&gt; that was declared earlier takes one argument that represents the orientation of the device.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)postNotificationWithString:(NSString *)orientation //post notification method and logic
{
    NSString *notificationName = @&amp;quot;MTPostNotificationTut&amp;quot;;
    NSString *key = @&amp;quot;OrientationStringValue&amp;quot;;
    NSDictionary *dictionary = [NSDictionary dictionaryWithObject:orientation forKey:key];
    [[NSNotificationCenter defaultCenter] postNotificationName:notificationName object:nil userInfo:dictionary];
}
&lt;/pre&gt;
&lt;p&gt;There are three important parts of the &lt;code&gt;NSNotificationCenter&lt;/code&gt; method &lt;code&gt;postNotificationName:object:userInfo:&lt;/code&gt;. The argument for &lt;code&gt;postNotificationName:&lt;/code&gt; is the title of the notification that was registered in the previous &lt;code&gt;addObserver:selector:name:object:&lt;/code&gt; method. The argument for &lt;code&gt;object:&lt;/code&gt;, again, is the object posting the notification and in this case is &lt;code&gt;nil&lt;/code&gt;. The argument for &lt;code&gt;userInfo&lt;/code&gt; is an &lt;code&gt;NSDictionary&lt;/code&gt; that can be used to send additional information with the notification. &lt;code&gt;userInfo&lt;/code&gt; can be &lt;code&gt;nil&lt;/code&gt;, but in this instance we want to know the orientation of the device. In order to send it with the notification the information is packaged inside a dictionary.&lt;/p&gt;
&lt;h4&gt;Getting the Device&amp;#39;s Orientation&lt;/h4&gt;
&lt;p&gt;In order to get the device&amp;#39;s orientation, override the &lt;code&gt;UIViewController&lt;/code&gt; method &lt;code&gt;willAnimateRotationToInterfaceOrientation:duration:&lt;/code&gt; by typing the following code inside the braces. Each time the device is rotated, the method &lt;code&gt;postNotificationWithString:&lt;/code&gt; is called and passes in either &amp;quot;Portrait&amp;quot; or &amp;quot;Landscape&amp;quot; depending on the device&amp;#39;s orientation.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
    if (interfaceOrientation == UIInterfaceOrientationPortrait) {
        [self postNotificationWithString:@&amp;quot;Portrait&amp;quot;];
    }
    else {
        [self postNotificationWithString:@&amp;quot;Landscape&amp;quot;];
    }
}
&lt;/pre&gt;
&lt;h4&gt;Using the Notification&lt;/h4&gt;
&lt;p&gt;The custom method &lt;code&gt;useNotificationWithString:&lt;/code&gt; was declared earlier and registered as the selector to be called when the notification happens. Type the following code which  gets the device orientation string from &lt;code&gt;userInfo&lt;/code&gt;. By using &lt;code&gt;NSLog&lt;/code&gt; to display its value, each orientation change logs that another notification has been posted.&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)useNotificationWithString:(NSNotification *)notification //use notification method and logic
{
    NSString *key = @&amp;quot;OrientationStringValue&amp;quot;;
    NSDictionary *dictionary = [notification userInfo];
    NSString *stringValueToUse = [dictionary valueForKey:key];
    NSLog(@&amp;quot;Device orientation --&amp;gt; %@&amp;quot;,stringValueToUse);
}
&lt;/pre&gt;
&lt;h4&gt;Memory Management&lt;/h4&gt;
&lt;p&gt;Lastly, the observer must be removed when the object is deallocated. Type the following code in the &lt;code&gt;dealloc&lt;/code&gt; method:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
&lt;/pre&gt;
&lt;p&gt;If you are &lt;strong&gt;not using ARC&lt;/strong&gt;, you&amp;#8217;ll need to explicitly call &lt;code&gt;[super dealloc]&lt;/code&gt; as well, like so:&lt;/p&gt;
&lt;pre class="brush: objc; title: ;"&gt;
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}
&lt;/pre&gt;
&lt;hr /&gt;
&lt;h3&gt;Step 4: Run the Project&lt;/h3&gt;
&lt;p&gt;Click Product &amp;gt; Run, or click the &amp;quot;Run&amp;quot; arrow in the top left corner. If you are using the iOS Simulator, click Hardware &amp;gt; Rotate Left to simulate device rotation. Notice that &amp;quot;Device orientation &amp;#8211;&amp;gt; Landscape&amp;quot; is logged to the console.&lt;/p&gt;
&lt;hr /&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;Triggering methods in disconnected objects would require some hefty coding without notifications and the &lt;code&gt;NSNotificationCenter&lt;/code&gt;. By adding observers to listen for specific posts to the notification center, your objects can communicate and pass data easily.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/h6dJx8CGP0253HMsZxR1OgkUyMg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/h6dJx8CGP0253HMsZxR1OgkUyMg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/h6dJx8CGP0253HMsZxR1OgkUyMg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/h6dJx8CGP0253HMsZxR1OgkUyMg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_nsnotificationcenter/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Corona SDK: Create an Alphabet Soup Game – Final Steps</title>
		<link>http://mobile.tutsplus.com/tutorials/corona/corona-sdk-create-an-alphabet-soup-game-final-steps/</link>
		<comments>http://mobile.tutsplus.com/tutorials/corona/corona-sdk-create-an-alphabet-soup-game-final-steps/#comments</comments>
		<pubDate>Thu, 03 May 2012 18:04:03 +0000</pubDate>
		<dc:creator>Carlos Yanez</dc:creator>
				<category><![CDATA[Corona SDK]]></category>
		<category><![CDATA[games]]></category>
		<guid isPermaLink="false">http://mobile.tutsplus.com/?p=10607</guid>
		<description>&lt;div class="seriesmeta"&gt;This entry is part 3 of 3 in the series &lt;a href="http://mobile.tutsplus.com/series/create-an-alphabet-soup-game/" class="series-790" title="Create an Alphabet Soup Game"&gt;Create an Alphabet Soup Game&lt;/a&gt;&lt;/div&gt;&lt;p&gt;Welcome to the final tutorial in our Alphabet Soup game series! In this tutorial, we&amp;#8217;ll handle word selection and the steps necessary to build the final app.&lt;/p&gt;
&lt;p&gt;&lt;!--more--&gt;&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 1:&lt;/span&gt; Hit Test Objects Function&lt;/h2&gt;
&lt;p&gt;We&amp;#8217;ll use an excellent and useful function for collision detection without physics. You can find the original example and source at the Ansca &lt;a href="http://developer.anscamobile.com/code/flashs-hittestobject-emulated-using-contentbounds"&gt;Code Exchange&lt;/a&gt; website.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
-- by jhocking
function hitTestObjects(obj1, obj2)
        local left = obj1.contentBounds.xMin &amp;lt;= obj2.contentBounds.xMin and obj1.contentBounds.xMax &amp;gt;= obj2.contentBounds.xMin
        local right = obj1.contentBounds.xMin &amp;gt;= obj2.contentBounds.xMin and obj1.contentBounds.xMin &amp;lt;= obj2.contentBounds.xMax
        local up = obj1.contentBounds.yMin &amp;lt;= obj2.contentBounds.yMin and obj1.contentBounds.yMax &amp;gt;= obj2.contentBounds.yMin
        local down = obj1.contentBounds.yMin &amp;gt;= obj2.contentBounds.yMin and obj1.contentBounds.yMin &amp;lt;= obj2.contentBounds.yMax
        return (left or right) and (up or down)
end
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 2:&lt;/span&gt; Detect Letters&lt;/h2&gt;
&lt;p&gt;The next function will run when the user lifts the finger used to select the word. It will calculate the selected letters using the function created in the previous step.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
function detectLetters:touch(e)
	-- Code...
end
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 3:&lt;/span&gt; Get Selected Letters&lt;/h2&gt;
&lt;p&gt;A string variable is created to store the letters highlighted by the line.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
	-- Get selected letters

		local selectedWord = ''

		for i = 1, tfs.numChildren do
			if(hitTestObjects(lines[lines.numChildren], tfs[i])) then
				selectedWord = selectedWord .. tfs[i].text
			end
		end
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 4:&lt;/span&gt; Check If Word is On List&lt;/h2&gt;
&lt;p&gt;This code checks the generated string and compares it to the elements in the words table. If the word is found a sound is played and the counter rises.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
-- Check if word is on list 

		for j = 0, 5 do
			if(selectedWord == L1[j]) then
				audio.play(bell)
				currentWords.text = currentWords.text .. ' ' .. selectedWord
				currentWords:setReferencePoint(display.TopLeftReferencePoint)
				currentWords.x = 5
				correct = correct + 1
			end
		end
	end
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 5:&lt;/span&gt; Check for Game Over&lt;/h2&gt;
&lt;p&gt;When the counter reaches the same amount of words in the table an alert is called.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
	if(correct == #L1) then
		alert()
	end
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 6:&lt;/span&gt; Alert&lt;/h2&gt;
&lt;p&gt;The alert function stops the game, removes the listeners, and displays a game status message.&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
function alert()
	gameListeners('rm')

	alert = display.newImage('alert.png')
end
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 7:&lt;/span&gt; Call Main Function&lt;/h2&gt;
&lt;p&gt;In order to initially start the game, the &lt;em&gt;Main&lt;/em&gt; function needs to be called. With the above code in place, we&amp;#8217;ll do that here:&lt;/p&gt;
&lt;pre class="brush: plain; title: ;"&gt;
Main()
&lt;/pre&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 8:&lt;/span&gt; Loading Screen&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
&lt;p&gt;&lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Alphabet/3/1.png" /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The Default.png file is an image that will be displayed right when you start the application while iOS loads the basic data to show the Main Screen. Add this image to your project source folder, it will be automatically added by the Corona compiler.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 9:&lt;/span&gt; Icon&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
&lt;p&gt;&lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Alphabet/3/2.png" /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Using the graphics you created before you can now create a nice and good looking icon. The icon size for the non-retina iPhone icon is 57x57px, but the retina version is 114x114px and the iTunes store requires a 512x512px version. I suggest creating the 512&amp;#215;512 version first and then scaling down for the other sizes.&lt;/p&gt;
&lt;p&gt;It doesn&amp;#8217;t need to have the rounded corners or the transparent glare, iTunes and the iPhone will do that for you.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 10:&lt;/span&gt; Testing in Simulator&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
&lt;p&gt;&lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Alphabet/3/3.png" /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;It&amp;#8217;s time to do the final test. Open the Corona Simulator, browse to your project folder, and then click open. If everything works as expected, you are ready for the final step!&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Step 11:&lt;/span&gt; Build&lt;/h2&gt;
&lt;div class="tutorial_image"&gt;
&lt;p&gt;&lt;img src="https://d339vfjsz5zott.cloudfront.net/Corona-SDK_Alphabet/3/4.png" alt="" /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;In the Corona Simulator go to &lt;em&gt;File &amp;gt; Build&lt;/em&gt; and select your target device. Fill the required data and click &lt;em&gt;build&lt;/em&gt;. Wait a few seconds and your app will be ready for device testing and/or submission for distribution!&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;Experiment with the final result and try to make your custom version of the game!&lt;/p&gt;
&lt;p&gt;I hope you liked this tutorial series and find it helpful. Thank you for reading!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-qZfJDqbCja6LlOmOK9tGQ0EWNU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-qZfJDqbCja6LlOmOK9tGQ0EWNU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-qZfJDqbCja6LlOmOK9tGQ0EWNU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-qZfJDqbCja6LlOmOK9tGQ0EWNU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;</description>
		<wfw:commentRss>http://mobile.tutsplus.com/tutorials/corona/corona-sdk-create-an-alphabet-soup-game-final-steps/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<series:name><![CDATA[Create an Alphabet Soup Game]]></series:name>
	</item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.505 seconds -->

