<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>The Agile Warrior</title>
	<atom:link href="http://agilewarrior.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://agilewarrior.wordpress.com</link>
	<description>A blog about creating valuable software</description>
	<lastBuildDate>Mon, 30 Jan 2012 18:19:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='agilewarrior.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/f5507dfac8bd5cc9a12c654ee97e46fe?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>The Agile Warrior</title>
		<link>http://agilewarrior.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://agilewarrior.wordpress.com/osd.xml" title="The Agile Warrior" />
	<atom:link rel='hub' href='http://agilewarrior.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to add a spinner for long operation on iPhone</title>
		<link>http://agilewarrior.wordpress.com/2012/01/30/how-to-add-a-spinner-for-long-operation-on-iphone/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/30/how-to-add-a-spinner-for-long-operation-on-iphone/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 18:19:28 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[blocking]]></category>
		<category><![CDATA[GCD]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iPhone App Dev]]></category>
		<category><![CDATA[spinner]]></category>
		<category><![CDATA[threading]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2715</guid>
		<description><![CDATA[Say you’ve got an operation that takes a long time and you don’t want to block the main thread. Here’s how you can add a spinner to show the user an update is happening. Hook up the refresh button Control drag the refresh button into your custom view. Then just hook up as follows: ViewController.m <a href="http://agilewarrior.wordpress.com/2012/01/30/how-to-add-a-spinner-for-long-operation-on-iphone/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2715&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://agilewarrior.files.wordpress.com/2012/01/refresh-button.png?w=500" alt="" title="refresh-button"   class="alignnone size-full wp-image-2716" />Say you’ve got an operation that takes a long time and you don’t want to block the main thread.</p>
<p>Here’s how you can add a spinner to show the user an update is happening.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/spinner.png?w=500" alt="" title="spinner"   class="alignnone size-full wp-image-2717" /></p>
<h3>Hook up the refresh button</h3>
<p>Control drag the refresh button into your custom view.</p>
<p>Then just hook up as follows:</p>
<p><strong>ViewController.m</strong></p>
<p><pre class="brush: objc;">
- (IBAction)refresh:(id)sender {

    // replace right bar button 'refresh' with spinner
    UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    [spinner startAnimating];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:spinner];

    // how we stop refresh from freezing the main UI thread
    dispatch_queue_t downloadQueue = dispatch_queue_create(&quot;flickr downloader&quot;, NULL);
    dispatch_async(downloadQueue, ^{
        NSArray *photos = [FlickrFetcher recentGeoreferencedPhotos];

        // do any UI stuff on the main UI thread
        dispatch_async(dispatch_get_main_queue(), ^{
            // put rightbar button back
            self.navigationItem.rightBarButtonItem = sender; // sender because that's the element that called us by clicking refresh
            self.photos = photos;
        });

    });
    dispatch_release(downloadQueue);

}
</pre></p>
<p>For the complete story on this demo checkout Lecture 10 52min mark of Paul Hegarty’s <a href="http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id473757255">iPhone App Dev course</a>.</p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/ios/'>iOS</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/blocking/'>blocking</a>, <a href='http://agilewarrior.wordpress.com/tag/gcd/'>GCD</a>, <a href='http://agilewarrior.wordpress.com/tag/ios-2/'>ios</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone-app-dev/'>iPhone App Dev</a>, <a href='http://agilewarrior.wordpress.com/tag/spinner/'>spinner</a>, <a href='http://agilewarrior.wordpress.com/tag/threading/'>threading</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2715/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2715/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2715/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2715/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2715/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2715/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2715/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2715/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2715/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2715/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2715/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2715/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2715/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2715/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2715&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/30/how-to-add-a-spinner-for-long-operation-on-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/refresh-button.png" medium="image">
			<media:title type="html">refresh-button</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/spinner.png" medium="image">
			<media:title type="html">spinner</media:title>
		</media:content>
	</item>
		<item>
		<title>iOS Objective-C Grand Central Dispatch</title>
		<link>http://agilewarrior.wordpress.com/2012/01/30/ios-objective-c-grand-central-dispatch/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/30/ios-objective-c-grand-central-dispatch/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 18:04:08 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[GCD]]></category>
		<category><![CDATA[Grand Central Dispatch]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iPhone App Dev]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2712</guid>
		<description><![CDATA[These are personal notes from Lecture 10 of Paul Hegarty’s excellent iPhone App Dev course. Go there for the full monty on GCD you will want to go there. What is Grand Central Dispatch. Is a C API. Basic idea is you have queues of operations. Operations are specificed using blocks. Most queues run serially <a href="http://agilewarrior.wordpress.com/2012/01/30/ios-objective-c-grand-central-dispatch/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2712&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>These are personal notes from Lecture 10 of Paul Hegarty’s excellent iPhone App Dev course. Go there for the full monty on GCD you will want to go there.</p>
<h3>What is Grand Central Dispatch.</h3>
<p>Is a C API.<br />
Basic idea is you have queues of operations.<br />
Operations are specificed using blocks.<br />
Most queues run serially (a true queue).</p>
<p>The operations are going to be pulled off the queue and run in some other thread.</p>
<p>There is no guarantee about where and when is will happen.<br />
Good thing is that if your operation blocks, only that queue will block.<br />
Other queues (like the main UI queue) will continue to run.</p>
<p>So we are going to queue up blocks things that take a long time to run in other threads, and from those threads we’ll queue up blocks back on the main ui thread to update the ui.</p>
<p>Example assume we fetched an image from the network:</p>
<p><pre class="brush: objc;">
-(void)viewWillAppear:(BOOL) animated
{
   NSData *imageData = [NSData dataWithContentsOfURL:networkURL]; // long time!
   UIImage *image = [UIImage imageWithData:imageData];
   self.imageView.image = image;
   self.imageView.frame = CGRectMake(0,0, image.size.width, image.size.height);
   self.scrollView.contentSize = image.size;
}
</pre></p>
<p>We don’t want the fetching of that image happening on the main queue. UI will be non-responsive.</p>
<p>And any rendering of the main ui, needs to be done on the main ui thread.</p>
<p>So we are going to need x2 queues.<br />
One to do the long work of getting the image.<br />
Another to update the UI.</p>
<p><pre class="brush: objc;">
-(void)viewWillAppear:(BOOL) animated
{

   dispatch_queue_t downloadQueue = dispatch_queue_create(“image loader”, NULL);
   dispatch_async(downloadQueue, ^{	
      NSData *imageData = [NSData dataWithContentsOfURL:networkURL]; // long time!
      dispatch_async(dispatch_get_main_queue(), ^ {
         UIImage *image = [UIImage imageWithData:imageData];
         self.imageView.image = image;
         self.imageView.frame = CGRectMake(0,0, image.size.width, image.size.height);
         self.scrollView.contentSize = image.size;
      });
   });
   dispatch_release(downloadQueue);
}
</pre></p>
<p>This is the power of GCD. You can think linearly about your program right in time. Run times linear here.</p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/ios/'>iOS</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/gcd/'>GCD</a>, <a href='http://agilewarrior.wordpress.com/tag/grand-central-dispatch/'>Grand Central Dispatch</a>, <a href='http://agilewarrior.wordpress.com/tag/ios-2/'>ios</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone-app-dev/'>iPhone App Dev</a>, <a href='http://agilewarrior.wordpress.com/tag/threads/'>threads</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2712/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2712/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2712/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2712/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2712/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2712/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2712/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2712/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2712/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2712/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2712/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2712/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2712/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2712/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2712&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/30/ios-objective-c-grand-central-dispatch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>
	</item>
		<item>
		<title>iOS Objective-C blocks</title>
		<link>http://agilewarrior.wordpress.com/2012/01/30/ios-objective-c-blocks/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/30/ios-objective-c-blocks/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 17:10:48 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[blocks]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iPhone App Dev]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2709</guid>
		<description><![CDATA[These are some notes I took from Lecture 10 of Paul Hegarty&#8217;s excellent iPhone App Dev course. Go there for the full story. What is a block? Is a chunk of code that is usually inlined, but can be passed around like an argument to methods. It&#8217;s very smart about local variables, referenced objects. What <a href="http://agilewarrior.wordpress.com/2012/01/30/ios-objective-c-blocks/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2709&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>These are some notes I took from <a href="http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id473757255">Lecture 10 of Paul Hegarty&#8217;s excellent iPhone App Dev course</a>. Go there for the full story.</p>
<p><strong>What is a block?</strong></p>
<p>Is a chunk of code that is usually inlined, but can be passed around like an argument to methods.<br />
It&#8217;s very smart about local variables, referenced objects.</p>
<p><strong>What does it look like?</strong></p>
<p>Here&#8217;s a method I want to pass a block to:</p>
<p>[aDictionary enumerateKeysAndObjectUsingBlock:^(id key, id value, BOOL *stop) {<br />
  NSLog(@"value for key %@ is %@", key, value);<br />
  if (([@"ENOUGH" isEqualToString:key]) {<br />
    *stop = YES;<br />
  }<br />
}];</p>
<p>This method exists in NSDictionary. It basically enumerates through each element in a Dictionary and allows you to pass it a block with will be applied on each element.</p>
<p>Block starts with magical caret ^. Means a block.</p>
<p>Can use local variables declared before the block inside the block</p>
<p>double stopValue = 53.5;<br />
[aDictionary enumerateKeysAndObjectUsingBlock:^(id key, id value, BOOL *stop) {<br />
  NSLog(@"value for key %@ is %@", key, value);<br />
  if (([@"ENOUGH" isEqualToString:key] || ([value doubleValue] == stopValue) {<br />
    *stop = YES;<br />
  }<br />
}];</p>
<p>But they are read only.<br />
Unless you put underbar underbar &#8211; then it becomes read/write.</p>
<p>__block BOOL stoppedEarly = NO;<br />
double stopValue = 53.5;<br />
[aDictionary enumerateKeysAndObjectUsingBlock:^(id key, id value, BOOL *stop) {<br />
    stoppedEarly = YES; // this is legal now<br />
}];</p>
<p><strong>What about objects messaged inside the block?</strong></p>
<p>NSString *stopkey = [@"Enough uppercaseString];<br />
&#8230;<br />
if ([stopKey isEqualToString: key] ||</p>
<p>Any outside pointers are held onto strong by the block until the block goes off the heap.<br />
So if the block needs it, it keeps it.</p>
<h3>typedefs</h3>
<p>To make our lives easier we sometimes user typedefs with blocks.</p>
<p>typedef double (^unary_operation_t)(double op);</p>
<p>_t is convention for telling us it’s a type (takes a double returns a double).</p>
<p>Now we can declare a variable of that type called square:</p>
<p>unary_operation_t square;<br />
square = ^(double operand) { // value of square is a block<br />
   return operand * operand;<br />
}</p>
<p>Now we can use:</p>
<p>double sequareOfFive = square(5.0);</p>
<p>We could then use the unary_operation_t to define a method</p>
<p>@property (nonatomic, strong) NSMutableDictionary *unaryOperations;<br />
typedef double (^unary_operation_t)(double op);<br />
-(void) addUnaryOperation: (NSString *)op whichExecutesBlock:(unary_operation_t)opBlock {<br />
   [self.unaryOperations setObject:opBlock forKey:op];<br />
}</p>
<p>What this does is associate a block with an operation and store it in a dictionary.</p>
<p>Look at how beautifully these reads though: </p>
<p>addUnaryOperation (a string called op) whichExecutesBlock: unary_operation_t</p>
<p>Really nice syntax the way you can define variables right beside the variable declarations themselves.</p>
<p>Blocks are managed in iOS5 by ARC (so you don’t have to worry about memory management around these).</p>
<p>Then we could use this later on like:</p>
<p>-(double)performOperation:(NSString *)operation<br />
{<br />
   unary_operation_t unaryOp = [self.unaryOperations objectForKey:operation];<br />
   if (unaryOp) {<br />
      self.operand = unaryOp(self.operand);<br />
   }<br />
}</p>
<p><strong>We don’t always typedef</strong></p>
<p>When a block is an argument to a method and is used immediately, often there is no typedef. We just inline it.</p>
<p>-(void)enerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, BOOL *stop))block;</p>
<p>Here block is the local variable name.</p>
<p>Some shorthand allowed when defining a block</p>
<p>1. You do not have to declare the return type if it can be inferred.<br />
2. If there are no args don’t need parentheses.</p>
<p>NSNumber *secret = [NSNumber numberWithDouble:42.0];<br />
[brain addUnaryOperation:@”MoLtUaE” whichExecutesBlock:^(double operand) {<br />
   return operand * [secret doubleValue];<br />
}];</p>
<p>And</p>
<p>[UIView animateWithDuration:5.0 animations:^{<br />
   view.opactity = 0.5;<br />
}];</p>
<p>No args to this block. No need to say ^() { …}</p>
<h3>Memory Cycles (bad thing)</h3>
<p>What if you had a block that referred to itself?</p>
<p>@property (nonatomic, strong) NSArray *myBlocks;</p>
<p>[self.myBlocks addObject:^() {<br />
   [self doSomething];<br />
}];</p>
<p>The block here has a strong pointer to itself.<br />
But self has a strong point to block (through it’s property!).</p>
<p>This is a serious problem.</p>
<p>Neither self non block can ever escape the heap now because they will both be pointing to each other.<br />
Called a memory “cycle”.</p>
<p>There is a magic underbar underbar weak.<br />
Says this variable is weak.</p>
<p>__weak Myclass *weakSelf = self;<br />
[self.myBlocks addObject:^() {<br />
   [weakSelf doSomething];<br />
}];</p>
<p>Solves the problem because now the block only has a weak pointer to self.<br />
Self still has a strong point to the block, but that’s OK.</p>
<h3>When do we use blocks in iOS?</h3>
<p>Enumeration<br />
View animations<br />
Sorting<br />
Notification (when something happens execute this block)<br />
Error handlers<br />
Completion handlers</p>
<p>But mostly it’s for multithreading. Do this using GCD (Grand Central Dispatch).</p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/ios/'>iOS</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/blocks/'>blocks</a>, <a href='http://agilewarrior.wordpress.com/tag/ios-2/'>ios</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone/'>iphone</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone-app-dev/'>iPhone App Dev</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2709/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2709/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2709/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2709&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/30/ios-objective-c-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>
	</item>
		<item>
		<title>How to display image on iPhone using UIImageView and UIScrollView</title>
		<link>http://agilewarrior.wordpress.com/2012/01/25/how-to-display-image-on-iphone-using-uiimageview-and-uiscrollview/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/25/how-to-display-image-on-iphone-using-uiimageview-and-uiscrollview/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 17:26:16 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[ios5]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iPhone App Dev]]></category>
		<category><![CDATA[iphone application development]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2678</guid>
		<description><![CDATA[These are abbreviated notes from the Lecture 8 Imaginarium demo of Paul Hegarty&#8217;s excellent iPhone course. For the full walk through go there. After you&#8217;ve created a blank single view project with an ImaginariumViewController&#8230;. Drag an Image View into the ViewController view area. Drag an image into your project. Add image to display. Note &#8211; <a href="http://agilewarrior.wordpress.com/2012/01/25/how-to-display-image-on-iphone-using-uiimageview-and-uiscrollview/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2678&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> These are abbreviated notes from the Lecture 8 Imaginarium demo of Paul Hegarty&#8217;s excellent <a href="http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id473757255">iPhone course</a>. For the full walk through go there.</p>
<p>After you&#8217;ve created a blank single view project with an ImaginariumViewController&#8230;.</p>
<p>Drag an Image View into the ViewController view area.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/dragimageview.png?w=500&#038;h=441" alt="" title="dragImageView" width="500" height="441" class="alignnone size-full wp-image-2682" /></p>
<p>Drag an image into your project.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/dragimageintoproject.png?w=500" alt="" title="dragImageIntoProject"   class="alignnone size-full wp-image-2683" /></p>
<p>Add image to display.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/addimagetodisplay.png?w=500&#038;h=97" alt="" title="addImageToDisplay" width="500" height="97" class="alignnone size-full wp-image-2684" /></p>
<p>Note &#8211; it will automatically scale the image to fit the view (will change the aspect ratio).</p>
<p>Change to only show top left</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/showtopleft.png?w=500&#038;h=288" alt="" title="showTopLeft" width="500" height="288" class="alignnone size-full wp-image-2685" /></p>
<p>Now the image aspect ratio is respected, but the image is so big we only start showing the top left. So now we&#8217;ll add a scroll bar.</p>
<p>Select the image view (use doc view pop out on right of story board if you need to make sure you have the right view).</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/docview.png?w=500&#038;h=416" alt="" title="docView" width="500" height="416" class="alignnone size-full wp-image-2686" /></p>
<p>And click Editor -&gt; Embed In -&gt; Scroll View</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/embedscrollview.png?w=500" alt="" title="embedscrollview"   class="alignnone size-full wp-image-2687" /></p>
<p>Note how imageView is now embedded in scrollView.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/imageviewnowscrollview.png?w=500" alt="" title="imageViewNowScrollView"   class="alignnone size-full wp-image-2688" /></p>
<p>Our scroll view struts and springs are now out of wack.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/scrollviewstrutsandspringsbad.png?w=500" alt="" title="scrollViewStrutsAndSpringsBad"   class="alignnone size-full wp-image-2689" /></p>
<p>Fix them so they expand and use the entire area.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/scrollviewwholearea.png?w=500" alt="" title="scrollViewWholeArea"   class="alignnone size-full wp-image-2690" /></p>
<p>If we run this now we&#8217;ll see our image but no scrolling. </p>
<p><strong>ScrollView has to have it&#8217;s content size set.</strong></p>
<p>This scroll view currently doesn&#8217;t know how big an area to scroll over. So we need to set it (set the content area, and then set the frame of the image view so it&#8217;s in the right spot).</p>
<p>Going to talk to these guys from our ViewController. Therefore we need outlets.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/outletcode.png?w=500" alt="" title="outletCode"   class="alignnone size-full wp-image-2691" /></p>
<p>Note you can drag the outlets from the docView we saw earlier.<br />
Call them imageView and scrollView and stick them in the private interface of the ViewController.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/draimageviewfromdocview.png?w=500&#038;h=95" alt="" title="draImageViewFromDocView" width="500" height="95" class="alignnone size-full wp-image-2692" /></p>
<p>Note when you do this it will auto create the synthesize and it will also add itself to the ViewDidUnload() the low memory thing.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/outletcode1.png?w=500" alt="" title="outletCode"   class="alignnone size-full wp-image-2693" /></p>
<p>Now use viewDidLoad to set your content size (the size of the image) and it&#8217;s frame to be the full size.</p>
<p><strong>ImaginariumViewController.m</strong></p>
<p><pre class="brush: objc;">
-(void)viewDidLoad
{
    [super viewDidLoad];
    self.scrollView.contentSize = self.imageView.image.size;
    self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);
}
</pre></p>
<p>Now when we run should work.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/shouldwork.png?w=500" alt="" title="shouldWork"   class="alignnone size-full wp-image-2694" /></p>
<p><strong>Bonus points &#8211; zoom</strong></p>
<p>So how to we get this thing to zoom?</p>
<p>Set the min and max zoom on the scrollView.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/setscrollzoom.png?w=500" alt="" title="setScrollZoom"   class="alignnone size-full wp-image-2695" /></p>
<p>Set the delegate.</p>
<p><pre class="brush: objc;">
@interface ImaginariumViewController()  
</pre></p>
<p>Implement the zoom method.</p>
<p><pre class="brush: objc;">
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    // return which subview we want to zoom
    return self.imageView;
}
</pre></p>
<p>Now set ourselves as the delegate.</p>
<p><pre class="brush: objc;">
-(void)viewDidLoad
{
    [super viewDidLoad];
    self.scrollView.delegate = self;
</pre></p>
<p>Note you can also set the delegate entirely within the story board using the doc view by dragging the scrollView to the controller.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/settingdelegateinstoryboard.png?w=500" alt="" title="settingDelegateInStoryBoard"   class="alignnone size-full wp-image-2696" /></p>
<p>Should now be able to zoom.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/zoomed.png?w=500" alt="" title="zoomed"   class="alignnone size-full wp-image-2697" /></p>
<p>Code in it&#8217;s entirety.</p>
<p><strong>ImaginariumViewController.m</strong></p>
<p><pre class="brush: objc;">
#import &quot;ImaginariumViewController.h&quot;

@interface ImaginariumViewController()  &lt;UIScrollViewDelegate&gt;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@end

@implementation ImaginariumViewController
@synthesize imageView;
@synthesize scrollView;

-(void)viewDidLoad
{
    [super viewDidLoad];
    self.scrollView.delegate = self;
    self.scrollView.contentSize = self.imageView.image.size;
    self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);
}

-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    // return which subview we want to zoom
    return self.imageView;
}

- (void)viewDidUnload {
    [self setImageView:nil];
    [self setScrollView:nil];
    [super viewDidUnload];
}
@end

</pre></p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/ios/'>iOS</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/ios-2/'>ios</a>, <a href='http://agilewarrior.wordpress.com/tag/ios5/'>ios5</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone/'>iphone</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone-app-dev/'>iPhone App Dev</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone-application-development/'>iphone application development</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2678/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2678&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/25/how-to-display-image-on-iphone-using-uiimageview-and-uiscrollview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/dragimageview.png" medium="image">
			<media:title type="html">dragImageView</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/dragimageintoproject.png" medium="image">
			<media:title type="html">dragImageIntoProject</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/addimagetodisplay.png" medium="image">
			<media:title type="html">addImageToDisplay</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/showtopleft.png" medium="image">
			<media:title type="html">showTopLeft</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/docview.png" medium="image">
			<media:title type="html">docView</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/embedscrollview.png" medium="image">
			<media:title type="html">embedscrollview</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/imageviewnowscrollview.png" medium="image">
			<media:title type="html">imageViewNowScrollView</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/scrollviewstrutsandspringsbad.png" medium="image">
			<media:title type="html">scrollViewStrutsAndSpringsBad</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/scrollviewwholearea.png" medium="image">
			<media:title type="html">scrollViewWholeArea</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/outletcode.png" medium="image">
			<media:title type="html">outletCode</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/draimageviewfromdocview.png" medium="image">
			<media:title type="html">draImageViewFromDocView</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/outletcode1.png" medium="image">
			<media:title type="html">outletCode</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/shouldwork.png" medium="image">
			<media:title type="html">shouldWork</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/setscrollzoom.png" medium="image">
			<media:title type="html">setScrollZoom</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/settingdelegateinstoryboard.png" medium="image">
			<media:title type="html">settingDelegateInStoryBoard</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/zoomed.png" medium="image">
			<media:title type="html">zoomed</media:title>
		</media:content>
	</item>
		<item>
		<title>How to iPhone protocol and delegate</title>
		<link>http://agilewarrior.wordpress.com/2012/01/25/how-to-iphone-protocol-and-delegate/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/25/how-to-iphone-protocol-and-delegate/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 15:20:31 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[delegates]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iPhone App Dev]]></category>
		<category><![CDATA[iphone application development]]></category>
		<category><![CDATA[protocol]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2668</guid>
		<description><![CDATA[This material is based on Paul Hegarty&#8217;s Lecture 5 and 6 iPhone course. For full explanation go there &#8211; these are abbreviated notes. Say we have a View (FaceView) which knows how to draw a happy face but the level of it&#8217;s happiness (or smile) is currently hardwired to be 0 (not very happy). And <a href="http://agilewarrior.wordpress.com/2012/01/25/how-to-iphone-protocol-and-delegate/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2668&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><em>This material is based on <a href="http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id473757255">Paul Hegarty&#8217;s Lecture 5 and 6 iPhone course.</a> For full explanation go there &#8211; these are abbreviated notes.</em> </p>
<p>Say we have a View (FaceView) which knows how to draw a happy face but the level of it&#8217;s happiness (or smile) is currently hardwired to be 0 (not very happy).</p>
<p>And we&#8217;d like some externtal delegate to be able to set it for us. </p>
<p>Because Views can&#8217;t talk directly to controllers in iOS one way to do this is using protocols and delegates. </p>
<p>The view defines a protocol, which the controller implements thereby acting as the datasource for the view. Here&#8217;s how you hook it up.</p>
<h3>1. Define the protocol and property.</h3>
<p><strong>FaceView.h</strong></p>
<p><pre class="brush: objc;">
#import &lt;UIKit/UIKit.h&gt; 

@class FaceView;

@protocol FaceViewDataSource
- (float)smileForFaceView:(FaceView *)sender;
@end

@interface FaceView : UIView
@property (nonatomic, weak) IBOutlet id  dataSource;
@end
</pre><br />
NB: Remember to synthesize the datasource in your .m file.</p>
<p><strong>FaceView.m</strong></p>
<p><pre class="brush: objc;">
@implementation FaceView
@synthesize dataSource = _dataSource;
</pre></p>
<p>What this basically says is create a protocol called smileForFaceView which returns a float (our smiliness) and takes as an input ourselves as the sender. </p>
<p>And then make that a publicly consumable property that others can register themselves for.</p>
<h3>2. Use the delegate in your implementation.</h3>
<p> For us our delegate is going to be used when we draw the smile in our drawRect function. So we replace the hard coded smile with:</p>
<p><strong>FaceView.m</strong></p>
<p><pre class="brush: objc;">
    //float smile = 100;
    float smile = [self.dataSource smileForFaceView:self];
</pre></p>
<h3>3. Set controller as delegate.</h3>
<p>So now FaceView is hooked up to use it&#8217;s delegate. Now we need to set our controller up to act as the delegate. This means having our controller say that they implement our FaceView protocol.</p>
<p>We could put in in our header file but because it&#8217;s private to our controller we stick it in our private interface.</p>
<p><strong>HappinessViewController.m</strong></p>
<p><pre class="brush: objc;">
@interface HappinessViewController() &lt;FaceViewDataSource&gt;
</pre></p>
<h3>4. Do the implementation.</h3>
<p><strong>HappinessViewController.m</strong></p>
<p><pre class="brush: objc;">
- (float)smileForFaceView:(FaceView *)sender {
    // set smile
}
</pre></p>
<h3>5. Set delegate to be the controller.</h3>
<p>Good time to do this is in the setter for our view in our controller.</p>
<p><strong>HappinessViewController.m</strong></p>
<p><pre class="brush: objc;">
-(void) setFaceView:(FaceView *)faceView
{
    _faceView = faceView;
    self.faceView.dataSource = self;
}
</pre></p>
<p>Voila! Now our controller is hooked up and ready to serve our view as it&#8217;s datasource.</p>
<p><strong>Test</strong></p>
<p>Add a button called refresh that when pressed sets the happiness.</p>
<p><pre class="brush: objc;">
- (IBAction)refresh:(id)sender {
    self.happiness = 100;
}
</pre></p>
<p>Should now see smile instead of frown (default of 0).</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/smile.png?w=500" alt="" title="smile"   class="alignnone size-full wp-image-2670" /></p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/ios/'>iOS</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/delegates/'>delegates</a>, <a href='http://agilewarrior.wordpress.com/tag/ios-2/'>ios</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone/'>iphone</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone-app-dev/'>iPhone App Dev</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone-application-development/'>iphone application development</a>, <a href='http://agilewarrior.wordpress.com/tag/protocol/'>protocol</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2668/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2668&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/25/how-to-iphone-protocol-and-delegate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/smile.png" medium="image">
			<media:title type="html">smile</media:title>
		</media:content>
	</item>
		<item>
		<title>How segue in iOS and pass data from one ViewController to another</title>
		<link>http://agilewarrior.wordpress.com/2012/01/25/how-segue-in-ios-and-pass-data-from-one-viewcontroller-to-another/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/25/how-segue-in-ios-and-pass-data-from-one-viewcontroller-to-another/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 13:24:54 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[objective c]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2660</guid>
		<description><![CDATA[Say we have a ViewController (Doctor), and we want to segue to another (Happiness) when the user clicks a Happy or Sad button. How could we do it? Add segues. While holding down the &#8216;control&#8217; key we can drag from the buttons on the left MVC to the MVC on the right and select the <a href="http://agilewarrior.wordpress.com/2012/01/25/how-segue-in-ios-and-pass-data-from-one-viewcontroller-to-another/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2660&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Say we have a ViewController (Doctor), and we want to segue to another (Happiness) when the user clicks a Happy or Sad button.</p>
<p>How could we do it?</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/setup.png?w=500&#038;h=358" alt="" title="setup" width="500" height="358" class="alignnone size-full wp-image-2661" /></p>
<h3>Add segues.</h3>
<p>While holding down the &#8216;control&#8217; key we can drag from the buttons on the left MVC to the MVC on the right and select the &#8216;push&#8217; model.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/push.png?w=500&#038;h=351" alt="" title="push" width="500" height="351" class="alignnone size-full wp-image-2662" /></p>
<h3>Give segues identifier names.</h3>
<p>Assign each segue a name so we can tell one from the other (i.e Happy, Sad).</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/segueindentifiers.png?w=500&#038;h=113" alt="" title="segueIndentifiers" width="500" height="113" class="alignnone size-full wp-image-2663" /></p>
<h3>Add Navigation Controller.</h3>
<p>If you ran this now it wouldn&#8217;t work. Segues only work when they are within some kind of navigation controller.</p>
<p>Click on the MVC on the left (the one that is going to start the application and go) </p>
<p>Editor -&gt; Embed in -&gt; Navigation Controller</p>
<p>If you run now you should see transitions when you click on Happy/Sad buttons.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/addnavigationcontroller.png?w=500&#038;h=534" alt="" title="addNavigationController" width="500" height="534" class="alignnone size-full wp-image-2664" /></p>
<h3>Prepare for segue</h3>
<p>To pass data to our new MVC we need to set stuff up in our prepareForSeque method.</p>
<p><strong>DoctorViewController.m</strong></p>
<p><pre class="brush: objc;">

#import &quot;DoctorViewController.h&quot;
#import &quot;HappinessViewController.h&quot;

@implementation DoctorViewController

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSLog(@&quot;prepareForSegue: %@&quot;, segue.identifier);

    if ([segue.identifier isEqualToString:@&quot;Happy&quot;]) {
        [segue.destinationViewController setHappiness:100];
    } else if ([segue.identifier isEqualToString:@&quot;Sad&quot;]) {
        [segue.destinationViewController setHappiness:0];
    }
}

@end
</pre></p>
<p>In here the segue.destinationViewController points to the ViewController we are going to navigate to and it is of type &#8216;id&#8217; (a special type in iOS objective C which could be any object).</p>
<p>Because we know where we are navigating to HappinessViewController we can treat segue.destinationViewController as if it were our HappinessViewController and call methods on it like setHappiness.</p>
<p>That&#8217;s how we pass data from one MVC to another. Through the segue by calling set property methods directly on our new ViewController.</p>
<p>And we can test that this gets passed by placing a log call in our HappinessViewController.</p>
<p><strong>HappinessViewController.m</strong></p>
<p><pre class="brush: objc;">
-(void)setHappiness:(int)happiness
{
    _happiness = happiness;
    NSString* result = [NSString stringWithFormat:@&quot;%d&quot;, happiness];
    NSLog(@&quot;Got happy %@&quot;, result);
    self.display.text = result; 
}
</pre></p>
<p>Now there&#8217;s one bug I haven&#8217;t been able to figure out yet. Which is how to refresh the view once it gets set here.</p>
<p>The self.display label is nil but once I figure it out I will come back up here and update.</p>
<p>For a much better walk through of who segues work check out <a href="http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id473757255">Paul Hegarty&#8217;s Lecture 6</a> as part of the Stanford iPhone class series.</p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/ios/'>iOS</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/ios-2/'>ios</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone/'>iphone</a>, <a href='http://agilewarrior.wordpress.com/tag/objective-c/'>objective c</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2660/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2660/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2660/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2660&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/25/how-segue-in-ios-and-pass-data-from-one-viewcontroller-to-another/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/setup.png" medium="image">
			<media:title type="html">setup</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/push.png" medium="image">
			<media:title type="html">push</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/segueindentifiers.png" medium="image">
			<media:title type="html">segueIndentifiers</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/addnavigationcontroller.png" medium="image">
			<media:title type="html">addNavigationController</media:title>
		</media:content>
	</item>
		<item>
		<title>How to add a model to a ViewController</title>
		<link>http://agilewarrior.wordpress.com/2012/01/24/how-to-add-a-model-to-a-viewcontroller/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/24/how-to-add-a-model-to-a-viewcontroller/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 20:06:04 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2653</guid>
		<description><![CDATA[Add the property to the ViewController header. CircleViewController.h And synthesize it in our code .m file. CircleViewController.m You can also optionally reset your view for display if you model changes like so: Filed under: iOS<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2653&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Add the property to the ViewController header.</p>
<p><strong>CircleViewController.h</strong></p>
<p><pre class="brush: objc;">
#import &lt;UIKit/UIKit.h&gt;

@interface CircleViewController : UIViewController
@property (nonatomic) int radius; // 1 small circle, 100 big
@end
</pre></p>
<p>And synthesize it in our code .m file.</p>
<p><strong>CircleViewController.m</strong></p>
<p><pre class="brush: objc;">
#import &quot;CircleViewController.h&quot;
@implementation CircleViewController
@synthesize radius = _radius;
@end
</pre></p>
<p>You can also optionally reset your view for display if you model changes like so:</p>
<p><pre class="brush: objc;">
-(void)setHappiness:(int)happiness
{
    NSLog(@&quot;setHappiness: %@&quot;, @&quot;1&quot;);
    _happiness = happiness;
    [self.faceView setNeedsDisplay];
}
</pre></p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/ios/'>iOS</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2653/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2653/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2653/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2653/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2653/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2653/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2653/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2653/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2653/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2653/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2653/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2653/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2653/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2653/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2653&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/24/how-to-add-a-model-to-a-viewcontroller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create a new iPhone ViewController and View</title>
		<link>http://agilewarrior.wordpress.com/2012/01/24/how-to-create-a-new-iphone-viewcontroller-and-view/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/24/how-to-create-a-new-iphone-viewcontroller-and-view/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 19:29:10 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[ios5]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2636</guid>
		<description><![CDATA[Here&#8217;s a cheat sheet I use to remind myself how to create a ViewController and View in iOS5. 1. Create the View Controller. Drag View Controller control onto story board. Create View Controller class. Assign the class to the controller. 2. Create the View. Drag generic view onto View Controller. Create View class. Assign view <a href="http://agilewarrior.wordpress.com/2012/01/24/how-to-create-a-new-iphone-viewcontroller-and-view/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2636&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a cheat sheet I use to remind myself how to create a ViewController and View in iOS5.</p>
<h3>1. Create the View Controller.</h3>
<p>Drag View Controller control onto story board.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/viewcontroller1.png?w=500&#038;h=400" alt="" title="viewController1" width="500" height="400" class="alignnone size-full wp-image-2638" /></p>
<p>Create View Controller class.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/viewcontrollerclass.png?w=500" alt="" title="viewControllerClass"   class="alignnone size-full wp-image-2639" /></p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/viewcontrollerclassname.png?w=500" alt="" title="viewControllerClassName"   class="alignnone size-full wp-image-2640" /></p>
<p>Assign the class to the controller.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/assignclasstocontroller.png?w=500&#038;h=170" alt="" title="assignClassToController" width="500" height="170" class="alignnone size-full wp-image-2641" /></p>
<h3>2. Create the View.</h3>
<p>Drag generic view onto View Controller.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/addgenericview.png?w=500&#038;h=429" alt="" title="addGenericView" width="500" height="429" class="alignnone size-full wp-image-2643" /></p>
<p>Create View class.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/addgenericviewclass.png?w=500&#038;h=331" alt="" title="addGenericViewClass" width="500" height="331" class="alignnone size-full wp-image-2644" /></p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/viewcontrollerclassname1.png?w=500" alt="" title="viewControllerClassName"   class="alignnone size-full wp-image-2645" /></p>
<p>Assign view class to generic view.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/hookclassuptoview.png?w=500&#038;h=112" alt="" title="hookClassUpToView" width="500" height="112" class="alignnone size-full wp-image-2650" /></p>
<h3>3. Connect View Controller to View.</h3>
<p>Do this via a private interface on the View Controller. Note this property has an IBOutlet marker to support XCode dragging of controller onto view.</p>
<p><strong>PhotoViewController.m</strong></p>
<p><pre class="brush: objc;">
#import &quot;PhotoViewController.h&quot;
#import &quot;PhotoView.h&quot;

@interface PhotoViewController()
@property (nonatomic, weak) IBOutlet PhotoView *photoView;
@end

@implementation PhotoViewController
@synthesize photoView = _photoView;
@end
</pre></p>
<p>Now go back to the story board and, holding down the &#8216;control&#8217; key, drag the yellow circle with the white paper inside up into the view.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/draggingcontrollerontoview.png?w=500" alt="" title="draggingControllerOntoView"   class="alignnone size-full wp-image-2646" /></p>
<p>Optional: Move AppDelegate classes to Supporting Files.</p>
<p>You don&#8217;t really need these cluttering up your file structure so you can optionally move them into &#8216;Supporting Files&#8217;.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/moveappdelegatefiles.png?w=500" alt="" title="moveAppDelegateFiles"   class="alignnone size-full wp-image-2647" /></p>
<p>That&#8217;s it! You&#8217;ve now got a controller hooked up to it&#8217;s view.</p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/ios/'>iOS</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/ios-2/'>ios</a>, <a href='http://agilewarrior.wordpress.com/tag/ios5/'>ios5</a>, <a href='http://agilewarrior.wordpress.com/tag/ipad/'>ipad</a>, <a href='http://agilewarrior.wordpress.com/tag/iphone/'>iphone</a>, <a href='http://agilewarrior.wordpress.com/tag/xcode/'>xcode</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2636/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2636/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2636/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2636/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2636/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2636/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2636/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2636/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2636/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2636/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2636/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2636/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2636/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2636/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2636&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/24/how-to-create-a-new-iphone-viewcontroller-and-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/viewcontroller1.png" medium="image">
			<media:title type="html">viewController1</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/viewcontrollerclass.png" medium="image">
			<media:title type="html">viewControllerClass</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/viewcontrollerclassname.png" medium="image">
			<media:title type="html">viewControllerClassName</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/assignclasstocontroller.png" medium="image">
			<media:title type="html">assignClassToController</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/addgenericview.png" medium="image">
			<media:title type="html">addGenericView</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/addgenericviewclass.png" medium="image">
			<media:title type="html">addGenericViewClass</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/viewcontrollerclassname1.png" medium="image">
			<media:title type="html">viewControllerClassName</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/hookclassuptoview.png" medium="image">
			<media:title type="html">hookClassUpToView</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/draggingcontrollerontoview.png" medium="image">
			<media:title type="html">draggingControllerOntoView</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/moveappdelegatefiles.png" medium="image">
			<media:title type="html">moveAppDelegateFiles</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create background color gradient using adobe illustrator</title>
		<link>http://agilewarrior.wordpress.com/2012/01/21/how-to-create-background-color-gradient-using-adobe-illustrator/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/21/how-to-create-background-color-gradient-using-adobe-illustrator/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 19:56:17 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[adobe illustrator]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[gradient]]></category>
		<category><![CDATA[hackers]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2619</guid>
		<description><![CDATA[To create a repeating background for your website using a gradient affect that looks something like this: do the following. Adobe illustrator CS5 Draw a square. Open the gradient window (Window -&#62; Gradient) Click the gradient box (will apply black to white gradient). Open the color pallette (Window -&#62; Color) and get both the color <a href="http://agilewarrior.wordpress.com/2012/01/21/how-to-create-background-color-gradient-using-adobe-illustrator/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2619&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To create a repeating background for your website using a gradient affect that looks something like this:</p>
<p><a href="http://agilewarrior.files.wordpress.com/2012/01/screen-shot-2012-01-21-at-12-51-52-pm.png"><img src="http://agilewarrior.files.wordpress.com/2012/01/screen-shot-2012-01-21-at-12-51-52-pm.png?w=500" alt="" title="Screen Shot 2012-01-21 at 12.51.52 PM"   class="alignnone size-full wp-image-2629" /></a></p>
<p>do the following.</p>
<h3>Adobe illustrator CS5</h3>
<p>Draw a square.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/draw-square.png?w=500" alt="" title="draw-square"   class="alignnone size-full wp-image-2621" /></p>
<p>Open the gradient window (Window -&gt; Gradient)</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/open-gradient.png?w=500" alt="" title="open-gradient"   class="alignnone size-full wp-image-2622" /></p>
<p>Click the gradient box (will apply black to white gradient).</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/apply-gradient.png?w=500" alt="" title="apply-gradient"   class="alignnone size-full wp-image-2623" /></p>
<p>Open the color pallette (Window -&gt; Color) and get both the color and gradient window on screen at the same time (tricky because Adobe UI is terrible).</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/open-color.png?w=500" alt="" title="open-color"   class="alignnone size-full wp-image-2624" /></p>
<p>Once you’ve got them both up, click and drag the colors you want for your gradient from the color palette down to the ends of the gradient.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/pick-and-drag.png?w=500&#038;h=386" alt="" title="pick-and-drag" width="500" height="386" class="alignnone size-full wp-image-2626" /></p>
<p>Transform and slim the gradient until your happy. Save this image somewhere you can access from your website. Remember to reduce the size of your canvas (Shift -O) to make sure your image is slim when you export it.</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/transform-and-rotate.png?w=500" alt="" title="transform-and-rotate"   class="alignnone size-full wp-image-2627" /></p>
<h3>CSS</h3>
<p>Now apply the following CSS to the body of your website:</p>
<p><pre class="brush: css;">
body {
		background-image: url('../images/bg_body.png');
		background-repeat: repeat-x;
		background-color: #c9efed;
		height: 100%;
}
</pre></p>
<p>This takes the gradient we just created, and repeats it across the screen and applies a default color to anything below your gradient image where is runs out.</p>
<p>Voila! That’s it. You’ve now got a nice background to build off of.</p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/adobe-illustrator/'>adobe illustrator</a>, <a href='http://agilewarrior.wordpress.com/category/design/'>design</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/adobe-illustrator/'>adobe illustrator</a>, <a href='http://agilewarrior.wordpress.com/tag/design/'>design</a>, <a href='http://agilewarrior.wordpress.com/tag/gradient/'>gradient</a>, <a href='http://agilewarrior.wordpress.com/tag/hackers/'>hackers</a>, <a href='http://agilewarrior.wordpress.com/tag/web-design/'>web design</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2619/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2619/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2619/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2619&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/21/how-to-create-background-color-gradient-using-adobe-illustrator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/screen-shot-2012-01-21-at-12-51-52-pm.png" medium="image">
			<media:title type="html">Screen Shot 2012-01-21 at 12.51.52 PM</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/draw-square.png" medium="image">
			<media:title type="html">draw-square</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/open-gradient.png" medium="image">
			<media:title type="html">open-gradient</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/apply-gradient.png" medium="image">
			<media:title type="html">apply-gradient</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/open-color.png" medium="image">
			<media:title type="html">open-color</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/pick-and-drag.png" medium="image">
			<media:title type="html">pick-and-drag</media:title>
		</media:content>

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/transform-and-rotate.png" medium="image">
			<media:title type="html">transform-and-rotate</media:title>
		</media:content>
	</item>
		<item>
		<title>WordPress 2011 in review report</title>
		<link>http://agilewarrior.wordpress.com/2012/01/19/wordpress-2011-in-review-report/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/19/wordpress-2011-in-review-report/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 18:50:40 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[good stuff]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2614</guid>
		<description><![CDATA[The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog. Here&#8217;s an excerpt: The Louvre Museum has 8.5 million visitors per year. This blog was viewed about 77,000 times in 2011. If it were an exhibit at the Louvre Museum, it would take about 3 days for that many people to see <a href="http://agilewarrior.wordpress.com/2012/01/19/wordpress-2011-in-review-report/" class="excerpt-more-link">[&#8230;]</a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2614&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The WordPress.com stats helper monkeys prepared a 2011 annual report for this blog.</p>
<p>	<a href="http://agilewarrior.wordpress.com/2011/annual-report/"><img src="http://www.wordpress.com/wp-content/mu-plugins/annual-reports/img/emailteaser.jpg" width="100%" alt="" /></a></p>
<p>Here&#8217;s an excerpt:</p>
</p>
<blockquote><p>The Louvre Museum has 8.5 million visitors per year.  This blog was viewed about <strong>77,000</strong> times in 2011. If it were an exhibit at the Louvre Museum, it would take about 3 days for that many people to see it.</p></blockquote>
<p><a href="http://agilewarrior.wordpress.com/2011/annual-report/">Click here to see the complete report.</a></p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/good-stuff/'>good stuff</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2614/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2614/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2614/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2614&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/19/wordpress-2011-in-review-report/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a2f56c04b26d45c057a7fb525c398852?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">JR</media:title>
		</media:content>

		<media:content url="http://www.wordpress.com/wp-content/mu-plugins/annual-reports/img/emailteaser.jpg" medium="image" />
	</item>
	</channel>
</rss>
