<?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>Wed, 25 Jan 2012 18:50:29 +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 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>
		<item>
		<title>How to break on any raised exception while debugging iPhone app</title>
		<link>http://agilewarrior.wordpress.com/2012/01/18/how-to-break-on-any-raised-exception-while-debugging-iphone-app/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/18/how-to-break-on-any-raised-exception-while-debugging-iphone-app/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 14:56:41 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone application development]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2606</guid>
		<description><![CDATA[In Paul Hegarty&#8217;s excellent CS 193 iPhone Application Development lectures, #40 has some great tips on debugging. In it Paul shows a really cool way of configuring the XCode debugger so that any time an exception is raised, the debugger stops instantly and shows you the offending line of code. Simply open up your XCode <a href="http://agilewarrior.wordpress.com/2012/01/18/how-to-break-on-any-raised-exception-while-debugging-iphone-app/" 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=2606&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In Paul Hegarty&#8217;s excellent CS 193 <a href="http://itunes.apple.com/itunes-u/ipad-iphone-application-development/id473757255">iPhone Application Development lectures</a>, #40 has some great tips on debugging.</p>
<p>In it Paul shows a really cool way of configuring the XCode debugger so that any time an exception is raised, the debugger stops instantly and shows you the offending line of code.</p>
<p>Simply open up your XCode (4.2.1) breakpoint navigator:</p>
<p><a href="http://agilewarrior.files.wordpress.com/2012/01/show-breakpoint-navigator.png"><img src="http://agilewarrior.files.wordpress.com/2012/01/show-breakpoint-navigator.png?w=500" alt="" title="show-breakpoint-navigator"   class="alignnone size-full wp-image-2607" /></a></p>
<p>Click the plus sign at the bottom and add an Exception Break Point:</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/debugger-exception.png?w=500" alt="" title="debugger-exception"   class="alignnone size-full wp-image-2608" /></p>
<p>And then just take the default All Exceptions, Break On Throw</p>
<p><img src="http://agilewarrior.files.wordpress.com/2012/01/default-debugger-selction.png?w=500&#038;h=124" alt="" title="default-debugger-selction" width="500" height="124" class="alignnone size-full wp-image-2609" /></p>
<p>Voila! Now whenever an exception is raised, your debugger will stop instantly and point out the offending line.</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/iphone-application-development/'>iphone application development</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2606/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2606/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2606/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2606&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/18/how-to-break-on-any-raised-exception-while-debugging-iphone-app/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/show-breakpoint-navigator.png" medium="image">
			<media:title type="html">show-breakpoint-navigator</media:title>
		</media:content>

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

		<media:content url="http://agilewarrior.files.wordpress.com/2012/01/default-debugger-selction.png" medium="image">
			<media:title type="html">default-debugger-selction</media:title>
		</media:content>
	</item>
		<item>
		<title>How do rails environments work?</title>
		<link>http://agilewarrior.wordpress.com/2012/01/13/how-do-rails-environments-work/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/13/how-do-rails-environments-work/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 15:05:35 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2599</guid>
		<description><![CDATA[Rails environments are wonderful. But they can be a bit confusing do to some inconsistency in terms of which environments are affected when you run certain rake tasks. After some digging I think I figured it out. db:create &#8211; affects both development and test environments db:drop &#8211; only affected development (though this has changed) db:migration <a href="http://agilewarrior.wordpress.com/2012/01/13/how-do-rails-environments-work/" 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=2599&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Rails environments are wonderful.  But they can be a bit confusing do to some inconsistency in terms of which environments are affected when you run certain rake tasks.</p>
<p>After some digging I think I figured it out.</p>
<p><strong>db:create</strong> &#8211; affects both development and test environments<br />
<strong>db:drop</strong> &#8211; only affected development (though this has changed)<br />
<strong>db:migration</strong> &#8211; runs against your current environment (usually development) </p>
<p>hence the need for<br />
<strong>db:test:prepare</strong> (to apply migrations against your test environment)</p>
<p>So in summary, you always need to specify the environment your rake tasks run against </p>
<p>$ rake foo RAILS_ENV=test</p>
<p>With the exception of db:create and db:drop above.</p>
<p>Links that helped:</p>
<p><a href="https://github.com/rails/rails/pull/2419">https://github.com/rails/rails/pull/2419</a><br />
<a href="http://railsforum.com/viewtopic.php?id=6648">http://railsforum.com/viewtopic.php?id=6648</a><br />
<a href="http://jasonseifer.com/2010/04/06/rake-tutorial">http://jasonseifer.com/2010/04/06/rake-tutorial</a></p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/rails/'>rails</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/rails/'>rails</a>, <a href='http://agilewarrior.wordpress.com/tag/ror/'>RoR</a>, <a href='http://agilewarrior.wordpress.com/tag/rubyonrails/'>rubyonrails</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2599/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2599/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2599/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2599&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/13/how-do-rails-environments-work/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 setup Rails3 postgres on mac</title>
		<link>http://agilewarrior.wordpress.com/2012/01/11/how-to-setup-rails3-postgres-on-mac/</link>
		<comments>http://agilewarrior.wordpress.com/2012/01/11/how-to-setup-rails3-postgres-on-mac/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 15:25:06 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[rubyonrails]]></category>

		<guid isPermaLink="false">http://agilewarrior.wordpress.com/?p=2586</guid>
		<description><![CDATA[Wanting to align with Heroku I decided to setup a local instance of postgres. It was more complicated than I would have liked, but here are some sketchy notes that might help if you need to go through the same thing. Install postgres $ brew install postgresql After trying the EnterpriseDB one click deploy I <a href="http://agilewarrior.wordpress.com/2012/01/11/how-to-setup-rails3-postgres-on-mac/" 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=2586&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Wanting to align with Heroku I decided to setup a local instance of postgres.<br />
It was more complicated than I would have liked, but here are some sketchy notes that might help if you need to go through the same thing.</p>
<h3>Install postgres</h3>
<p>$ brew install postgresql</p>
<p>After trying the EnterpriseDB one click deploy I found the <a href="https://github.com/mxcl/homebrew/wiki/installation">homebrew</a> install most stable.</p>
<h3>Create Rails3 app with postgres as database</h3>
<p>$ rails new pg -d postgres</p>
<h3>Create new postgres database user</h3>
<p>$ cd<br />
$ sudo su postgres<br />
Password:<br />
$ createuser jr<br />
$ Shall the new role be a superuser? (y/n) y<br />
$ exit</p>
<p>if you get a <em>getcwd: cannot access parent directories: Permission denied</em><br />
just type &#8216;cd&#8217; or &#8216;cd /&#8217; and goto a directory where permissions aren&#8217;t an issue.</p>
<h3>Create databases</h3>
<p>$ sudo su postgres<br />
Password:<br />
$ psql template1<br />
Password: </p>
<p>template1=# \l<br />
template1=# CREATE DATABASE pg_development;<br />
template1=# CREATE DATABASE pg_test;<br />
template1=# \q</p>
<h3>Login to terminal</h3>
<p>$ psql -U postgres -d pg_development<br />
Password: </p>
<h3>config/database.yml</h3>
<p>development:<br />
  adapter: postgresql<br />
  encoding: unicode<br />
  database: pg_development<br />
  pool: 5<br />
  username: postgres<br />
  password: root</p>
<p>test:<br />
  adapter: postgresql<br />
  encoding: unicode<br />
  database: pg_test<br />
  pool: 5<br />
  username: postgres<br />
  password: root</p>
<p>This was all setup and pre-populated. Only had to set username and password.</p>
<h3>Test</h3>
<p>$ rake db:create<br />
$ rails generate scaffold Post name:string title:string content:text<br />
$ rake db:migrate</p>
<p>Should be good to go. If you run into problems let me know and I will try to keep this up to do.</p>
<h3>kill hanging postgres processes</h3>
<p>Sometimes I have to manually kill postgres instances when I do a redeploy.<br />
Pattern I follow is:<br />
&gt; db.sh (rebuild database)<br />
&gt; sudo kill -9<br />
&gt; manually restart server using pgadmin<br />
&gt; restart local rails server</p>
<p>&#8211; it&#8217;s a pain and I will update this when I find a better way</p>
<p><a href="http://stackoverflow.com/questions/2369744/rails-postgres-drop-error-database-is-being-accessed-by-other-users">stackoverflow</a><br />
<a href="http://www.question-defense.com/2008/11/12/postgres-error-database-dev-is-being-accessed-by-other-users">postgres</a></p>
<p><strong>Links that helped</strong><br />
<a href="http://www.funonrails.com/2011/03/getting-started-with-rails-3-postgres.html">http://www.funonrails.com/2011/03/getting-started-with-rails-3-postgres.html</a><br />
<a href="http://www.mcbsys.com/techblog/2011/10/set-up-postgresql-for-rails-3-1/">http://www.mcbsys.com/techblog/2011/10/set-up-postgresql-for-rails-3-1/</a><br />
<a href="http://devcenter.heroku.com/articles/local-postgresql#macintosh">http://devcenter.heroku.com/articles/local-postgresql#macintosh</a></p>
<br />Filed under: <a href='http://agilewarrior.wordpress.com/category/rails/'>rails</a> Tagged: <a href='http://agilewarrior.wordpress.com/tag/postgres/'>postgres</a>, <a href='http://agilewarrior.wordpress.com/tag/postgresql/'>postgresql</a>, <a href='http://agilewarrior.wordpress.com/tag/rails/'>rails</a>, <a href='http://agilewarrior.wordpress.com/tag/ror/'>RoR</a>, <a href='http://agilewarrior.wordpress.com/tag/rubyonrails/'>rubyonrails</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/agilewarrior.wordpress.com/2586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/agilewarrior.wordpress.com/2586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/agilewarrior.wordpress.com/2586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/agilewarrior.wordpress.com/2586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/agilewarrior.wordpress.com/2586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/agilewarrior.wordpress.com/2586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/agilewarrior.wordpress.com/2586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/agilewarrior.wordpress.com/2586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/agilewarrior.wordpress.com/2586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/agilewarrior.wordpress.com/2586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/agilewarrior.wordpress.com/2586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/agilewarrior.wordpress.com/2586/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/agilewarrior.wordpress.com/2586/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/agilewarrior.wordpress.com/2586/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=agilewarrior.wordpress.com&amp;blog=6931535&amp;post=2586&amp;subd=agilewarrior&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://agilewarrior.wordpress.com/2012/01/11/how-to-setup-rails3-postgres-on-mac/feed/</wfw:commentRss>
		<slash:comments>2</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>
	</channel>
</rss>
