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

<channel>
	<title>Derek Neely</title>
	<atom:link href="http://derekneely.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://derekneely.com</link>
	<description>...what I care to share...</description>
	<lastBuildDate>Sat, 24 Jul 2010 17:39:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ubuntu 10.04 USB Lock-Ups</title>
		<link>http://derekneely.com/2010/07/ubuntu-10-04-usb-lock-ups/</link>
		<comments>http://derekneely.com/2010/07/ubuntu-10-04-usb-lock-ups/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 17:39:18 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Freeze]]></category>
		<category><![CDATA[Lock-up]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=589</guid>
		<description><![CDATA[I recently installed Ubuntu 10.04 LTS on one of my desktop PCs here at home. Love Ubuntu. Easy to use, very compatible with most devices, good plug and play. Don&#8217;t get me wrong (for those hardcore Linux folks) I like tinkering with Linux as much as anyone, but I also have work to get done. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://derekneely.com/wp-content/uploads/2010/07/ubuntu_icon.png"><img class="alignright size-full wp-image-588" title="Ubuntu" src="http://derekneely.com/wp-content/uploads/2010/07/ubuntu_icon.png" alt="" width="143" height="143" /></a>I recently installed Ubuntu 10.04 LTS on one of my desktop PCs here at home. Love Ubuntu. Easy to use, very compatible with most devices, good plug and play. Don&#8217;t get me wrong (for those hardcore Linux folks) I like tinkering with Linux as much as anyone, but I also have work to get done. Fighting for hours getting dual monitors or the right drivers working keeps me from getting that work done. Ok, sorry for the quick rant, back to the subject.</p>
<p>I noticed after installation when I would go to start plugging in some of my external devices via USB the dang thing would lock up on me. That is, desktop completely frozen, unable to remotely ssh into the box, just plain dead.</p>
<p>So, I tried various things and what have you and nothing appeared to help.</p>
<p>My solution was:</p>
<blockquote><p>apt-get remove modemmanager</p></blockquote>
<p>Simple as that. I haven&#8217;t had any lock-ups, system has been up for several days and I&#8217;ve been able to add my alfa wireless and my magic jack to the box without any crashes. Hope this may help you too!</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2010/07/ubuntu-10-04-usb-lock-ups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom User-Agent Safari</title>
		<link>http://derekneely.com/2010/06/custom-user-agent-safari/</link>
		<comments>http://derekneely.com/2010/06/custom-user-agent-safari/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 18:43:12 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Google Bot]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[User-Agent]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=568</guid>
		<description><![CDATA[Safari offers a pretty nice Developer toolbar (once enabled under Safari-&#62;Preferences-&#62;Advanced-&#62;Show develop menu&#8230;). As part of the developer toolbar they offer a User-Agent switcher to allow you to seemingly be using a different browser. Now, if you&#8217;re familiar with the User-Agent Switcher on Firefox, you know you can add additional/custom user agents. However, Safari doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-283" title="Apple" src="http://derekneely.com/wp-content/uploads/2009/06/apple.jpg" alt="Apple" width="124" height="140" />Safari offers a pretty nice Developer toolbar (once enabled under Safari-&gt;Preferences-&gt;Advanced-&gt;Show develop menu&#8230;). As part of the developer toolbar they offer a User-Agent switcher to allow you to seemingly be using a different browser. Now, if you&#8217;re familiar with the User-Agent Switcher on Firefox, you know you can add additional/custom user agents. However, Safari doesn&#8217;t make it as easy to add additional/custom agents. Rest assured, there is still away.</p>
<p>The file you will be looking for is:</p>
<blockquote><p>/Applications/Safari.app/Contents/Resources/UserAgent.plist</p></blockquote>
<p>What I have done is copy this file off to my home directory. Open the file with the Property List Editor (provided with Apple&#8217;s developer tools). I will add 2 entries into this file. One to give a nice divider for my custom agents and another for the Google Bot Agent.</p>
<p><strong>For the divider:</strong></p>
<ol>
<li>Select the last &#8216;Item&#8217; (be sure the &#8216;Item&#8217; is not expanded) and click the &#8216;+&#8217; sign to add a new &#8216;Item&#8217;</li>
<li>Change this &#8216;Item&#8217; to a &#8216;Dictionary&#8217; under the &#8216;Type&#8217; column.</li>
<li>Expand this &#8216;Item&#8217; and press the &#8216;Add sub-item button&#8217; (replaced the &#8216;+&#8217; sign after expanding)</li>
<li>Rename this sub-item&#8217;s key to &#8216;separator&#8217;, change the type to Boolean, and select the Value checkbox.</li>
</ol>
<p><img class="alignnone size-full wp-image-574" title="User-Agent Separator Config" src="http://derekneely.com/wp-content/uploads/2010/06/Screen-shot-2010-06-09-at-2.34.49-PM.png" alt="User-Agent Separator Config" width="599" height="37" /></p>
<p><strong>For the new User-Agent:</strong></p>
<ol>
<li>Add a new &#8216;Item&#8217; as you did in step 1 above.</li>
<li>Change this &#8216;Item&#8217; to a &#8216;Dictionary&#8217; under the &#8216;Type&#8217; column.</li>
<li>Expand this &#8216;Item&#8217; and press the &#8216;Add sub-item button&#8217; (replaced the &#8216;+&#8217; sign after expanding) 4 times.</li>
<li>Set the key, type, value for each as follows:</li>
</ol>
<ul>
<blockquote>
<li>name, String, Google Bot</li>
<li>version, String, 2.1</li>
<li>platform, String, Mac (not sure if this matters or not)</li>
<li>user-agent, String, Googlebot/2.1 (+http://www.google.com/bot.html)</li>
</blockquote>
</ul>
<p><img class="alignnone size-full wp-image-577" title="User-Agent Custom Config" src="http://derekneely.com/wp-content/uploads/2010/06/Screen-shot-2010-06-09-at-2.35.31-PM.png" alt="User-Agent Custom Config" width="643" height="89" /></p>
<p>Save this file. Quit Safari. Replace the original with the new one.</p>
<blockquote><p>$ sudo su -</p>
<p># rm /Applications/Safari.app/Contents/Resources/UserAgents.plist</p>
<p># cp /Users/derek/UserAgents.plist /Applications/Safari.app/Contents/Resources/</p></blockquote>
<p>Fire Safari back up and there you have it. A new custom user-agent. Repeat as necessary to add more.</p>
<p><img class="alignnone size-full wp-image-583" title="User-Agent Menu" src="http://derekneely.com/wp-content/uploads/2010/06/Screen-shot-2010-06-09-at-2.46.07-PM.png" alt="User-Agent Menu" width="545" height="551" /></p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2010/06/custom-user-agent-safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Site Posting Hiatus</title>
		<link>http://derekneely.com/2010/05/site-posting-hiatus/</link>
		<comments>http://derekneely.com/2010/05/site-posting-hiatus/#comments</comments>
		<pubDate>Wed, 26 May 2010 15:22:31 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=550</guid>
		<description><![CDATA[Wow, I made it by my own blog today and realized I haven&#8217;t been around in quite some time. I&#8217;ve been quite busy working on a startup company &#8211; Blue Shoe Mobile Solutions. Check us out! Also, since my last post I&#8217;ve had several apps go into the store. Check them out! I&#8217;ll be back soon! [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, I made it by my own blog today and realized I haven&#8217;t been around in quite some time. I&#8217;ve been quite busy working on a startup company &#8211; <a title="Blue Shoe Mobile Solutions" href="http://blueshoemobile.com/" target="_blank">Blue Shoe Mobile Solutions</a>. Check us out!</p>
<p>Also, since my last post I&#8217;ve had several apps go into the store. Check them out!</p>
<p><a title="iGetloaded" href="http://itunes.apple.com/us/artist/getloaded-com/id355498190" target="_blank"><img class="alignleft size-full wp-image-555" title="Getloaded-AppIcon" src="http://derekneely.com/wp-content/uploads/2010/05/Getloaded-AppIcon.png" alt="Getloaded-AppIcon" width="72" height="71" /></a> <a title="Big-A*s Sandwiches" href="http://itunes.apple.com/us/artist/blue-shoe-mobile-solutions/id363992961" target="_blank"><img class="alignnone size-full wp-image-553" title="BigAssSandwiches-AppIcon" src="http://derekneely.com/wp-content/uploads/2010/05/BigAssSandwiches-AppIcon.png" alt="BigAssSandwiches-AppIcon" width="74" height="73" /></a> <a title="Valentino's" href="http://itunes.apple.com/us/artist/blue-shoe-mobile-solutions/id363992961" target="_blank"><img class="alignnone size-full wp-image-557" title="Valentinos-AppIcon" src="http://derekneely.com/wp-content/uploads/2010/05/Valentinos-AppIcon.png" alt="Valentinos-AppIcon" width="74" height="70" /></a> <a title="Vesuvio Bay Ridge" href="http://itunes.apple.com/us/artist/blue-shoe-mobile-solutions/id363992961" target="_blank"><img class="alignnone size-full wp-image-558" title="Vesuvio-AppIcon" src="http://derekneely.com/wp-content/uploads/2010/05/Vesuvio-AppIcon.png" alt="Vesuvio-AppIcon" width="71" height="71" /></a> <a title="Sticky Rice" href="http://itunes.apple.com/us/artist/blue-shoe-mobile-solutions/id363992961" target="_blank"><img class="alignnone size-full wp-image-556" title="StickyRice-AppIcon" src="http://derekneely.com/wp-content/uploads/2010/05/StickyRice-AppIcon.png" alt="StickyRice-AppIcon" width="68" height="71" /></a> <a title="Gator's Sports Grille" href="http://itunes.apple.com/us/artist/blue-shoe-mobile-solutions/id363992961" target="_blank"><img class="alignnone size-full wp-image-554" title="GatorsSportsBar-AppIcon" src="http://derekneely.com/wp-content/uploads/2010/05/GatorsSportsBar-AppIcon.png" alt="GatorsSportsBar-AppIcon" width="71" height="69" /></a></p>
<p>I&#8217;ll be back soon! Got a ton going on and more apps coming out daily. I&#8217;m now moving into the Android Universe as well, to port the above apps over. Feel free to contact me if you have any specific questions or inquiries at me@derekneely.com.</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2010/05/site-posting-hiatus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone &#8211; UITableViewCell Custom Selection Style Color</title>
		<link>http://derekneely.com/2010/01/uitableviewcell-custom-selection-style-color/</link>
		<comments>http://derekneely.com/2010/01/uitableviewcell-custom-selection-style-color/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 04:16:59 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Custom UITableView]]></category>
		<category><![CDATA[Custom UITableViewCell]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Selection Style]]></category>
		<category><![CDATA[Selection Style Color]]></category>
		<category><![CDATA[UITableView]]></category>
		<category><![CDATA[UITableViewCell]]></category>
		<category><![CDATA[UITableViewCellSelectionStyle]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=516</guid>
		<description><![CDATA[Oddly, Apple has given you the ability to vastly customize the primary view of  a UITableViewCell. However, the selection style view is much more difficult to do such. Apple kindly gave us UITableViewSelectionStyleBlue/Gray/None. Well, that doesn&#8217;t always cut it does it? There are already some very good tutorials on revamping the whole table view.  Google [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-479" title="xcode-icon" src="http://derekneely.com/wp-content/uploads/2009/11/xcode-icon.png" alt="xcode-icon" width="154" height="154" />Oddly, Apple has given you the ability to vastly customize the primary view of  a UITableViewCell. However, the selection style view is much more difficult to do such. Apple kindly gave us UITableViewSelectionStyleBlue/Gray/None. Well, that doesn&#8217;t always cut it does it?</p>
<p>There are already some very good tutorials on revamping the whole table view.  <a title="Google - Custom UITableView" href="http://www.google.com/search?q=custom+uitableview&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a" target="_blank">Google it!</a> The best I came across was from <a title="Cocoa with Love - Custom UITableView" href="http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html" target="_blank">Cocoa with Love &#8211; Custom UITableView</a>.</p>
<p>However, this can be a bit overkill for some situations. It can also take a good bit of time to setup all the necessary images. What I needed was a quick and easy way to &#8216;theme&#8217; the application and thus the selection style for a UITableViewCell. This needed to work with both plain and grouped table view styles and custom cells as well. You can see now why this may take  a while using the above methods.</p>
<p>Here is a quick and easy method to do just that.</p>
<p><strong>SomeViewController.h</strong></p>
<pre>#import &lt;UIKit/UIKit.h&gt;

@interface SomeViewController : UITableViewController {
     UITableViewCell *currentSelectedCell;
}

@property (nonatomic, retain) UITableViewCell *currentSelectedCell;

- (void)setSelectedCell:(UITableViewCell *)selectedCell
     deselectedCell:(UITableViewCell *)deselectedCell;

@end</pre>
<p><strong>SomeViewController.m</strong></p>
<pre>#import "SomeViewController.h"

@implementation SomeViewController

@synthesize currentSelectedCell;

- (void)setSelectedCell:(UITableViewCell *)selectedCell deselectedCell:(UITableViewCell *)deselectedCell {
     //revert deselected cell
     if (deselectedCell != nil) {
          deselectedCell.backgroundColor = [UIColor whiteColor];
          for (UIView *subView in [deselectedCell.contentView subviews]) {
               if ([subView isKindOfClass:[UILabel class]]) {
                    UILabel *label = (UILabel *)subView;
                    label.textColor = [UIColor blackColor];
               }

               if ([subView isKindOfClass:[UITextField class]]) {
                    UITextField *textField = (UITextField *)subView;
                    textField.textColor = [UIColor blackColor];
               }
          }
     }

     //setup selected cell
     selectedCell.backgroundColor = [UIColor redColor]; //Some defined UIColor
     for (UIView *subView in [selectedCell.contentView subviews]) {
          if ([subView isKindOfClass:[UILabel class]]) {
               UILabel *label = (UILabel *)subView;
               label.textColor = [UIColor whiteColor];
          }

          if ([subView isKindOfClass:[UITextField class]]) {
               UITextField *textField = (UITextField *)subView;
               textField.textColor = [UIColor whiteColor];
          }
     }
}

#pragma mark -
#pragma mark Table View Delegate Methods

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
     (NSIndexPath *)indexPath {

     setSelectedCell:[tableView cellForRowAtIndexPath:indexPath]
          deselectedCell:currentSelectedCell];

     currentSelectedCell = [tableView cellForRowAtIndexPath:indexPath];
}

#pragma mark -
#pragma mark Table View Data Source Methods

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath {

     //........Setup UITableViewCell...........//

     cell.selectionStyle = UITableViewCellSelectionStyleNone;

     return cell;
}

- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:
     (NSInteger)section {

     return count;
}

@end</pre>
<p>Now, I&#8217;ve provided this in one class but what I&#8217;ve done is setup an &#8216;application&#8217; singleton that has this function and is called from each UITableView&#8217;s didSelectRowAtIndexPath delegate. Works great on standard, custom, plain, and grouped views.</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2010/01/uitableviewcell-custom-selection-style-color/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Development &#8211; Continuous Picker</title>
		<link>http://derekneely.com/2009/12/iphone-development-continuous-picker/</link>
		<comments>http://derekneely.com/2009/12/iphone-development-continuous-picker/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 21:42:21 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Continuous Picker]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Picker]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=513</guid>
		<description><![CDATA[Coming soon&#8230;been hard at work on some projects.]]></description>
			<content:encoded><![CDATA[<p>Coming soon&#8230;been hard at work on some projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/12/iphone-development-continuous-picker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Development &#8211; Global Variables (Singleton)</title>
		<link>http://derekneely.com/2009/11/iphone-development-global-variables/</link>
		<comments>http://derekneely.com/2009/11/iphone-development-global-variables/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 15:20:41 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[App Delegate]]></category>
		<category><![CDATA[Global]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Singleton]]></category>
		<category><![CDATA[Variables]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=480</guid>
		<description><![CDATA[In iPhone development, if/when you need a single instance of a variable that can be shared and manipulated where and how should you implement this. Thus far I have found 2 ways of doing so. The first would be to add the global variables to your AppDelegate (which can be done and will be explained [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-479" title="xcode-icon" src="http://derekneely.com/wp-content/uploads/2009/11/xcode-icon.png" alt="xcode-icon" width="143" height="143" />In iPhone development, if/when you need a single instance of a variable that can be shared and manipulated where and how should you implement this. Thus far I have found 2 ways of doing so. The first would be to add the global variables to your AppDelegate (which can be done and will be explained but isn&#8217;t the preferred method). The second and &#8216;correct&#8217; way of going about globals is to create a Singleton.</p>
<p>For the following examples we will assume the global variable you are trying to implement is a User object.</p>
<p>User.h</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #df0002;"><span style="color: #7d4726;">#import </span>&lt;Foundation/Foundation.h&gt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@interface</span> User : NSObject {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>NSString<span style="color: #000000;"><span style="white-space: pre;"> </span>*</span><span style="color: #438288;">username</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>NSString<span style="color: #000000;"><span style="white-space: pre;"> </span>*</span><span style="color: #438288;">password</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008d00;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span><span style="color: #7a0eac;">NSString</span><span style="color: #000000;"><span style="white-space: pre;"> </span>*</span><span style="color: #438288;">accountType</span><span style="color: #000000;">; </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>) NSString *username;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>) NSString *password;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>) NSString *accountType;</p>
</blockquote>
<p>User.m</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;">#import <span style="color: #df0002;">&#8220;User.h&#8221;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@implementation<span style="color: #000000;"> User</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@synthesize<span style="color: #000000;"> username;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@synthesize<span style="color: #000000;"> password;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@synthesize</span> accountType;</p>
</blockquote>
<hr /><strong>App Delegate Method</strong></p>
<p>ApplicationAppDelegate.h</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;">#import <span style="color: #df0002;">&#8220;User.h&#8221;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;"><span style="color: #df0002;"><br />
</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@interface</span> ApplicationAppDelegate : NSObject &lt;UIApplicationDelegate&gt; {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;"> </span>NSManagedObjectModel<span style="color: #000000;"> *</span><span style="color: #438288;">managedObjectModel</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;"> </span>NSManagedObjectContext<span style="color: #000000;"> *</span><span style="color: #438288;">managedObjectContext</span><span style="color: #000000;">;<span style="white-space: pre;"> </span> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;"> </span>NSPersistentStoreCoordinator<span style="color: #000000;"> *</span><span style="color: #438288;">persistentStoreCoordinator</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;"> </span>UIWindow<span style="color: #000000;"> *</span><span style="color: #438288;">window</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #438288;">User</span> *user;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>, <span style="color: #c900a4;">readonly</span>) NSManagedObjectModel *managedObjectModel;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>, <span style="color: #c900a4;">readonly</span>) NSManagedObjectContext *managedObjectContext;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>, <span style="color: #c900a4;">readonly</span>) NSPersistentStoreCoordinator *persistentStoreCoordinator;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@property<span style="color: #000000;"> (</span>nonatomic<span style="color: #000000;">, </span>retain<span style="color: #000000;">) </span>IBOutlet<span style="color: #000000;"> UIWindow *window;</span></p>
<div><span style="font-family: Menlo, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: small;"><span style="line-height: normal;"> </span></span></div>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@property<span style="color: #000000;"> (</span>nonatomic<span style="color: #000000;">, </span>retain<span style="color: #000000;">) User *user;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;"><span style="color: #000000;"><br />
</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">
</blockquote>
<p>ApplicationAppDelegate.m</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #df0002;"><span style="color: #7d4726;">#import </span>&#8220;ApplicationAppDelegate.h&#8221;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@implementation</span> ApplicationAppDelegate</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@synthesize<span style="color: #000000;"> window;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@synthesize</span> user;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;">#pragma mark -</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;">#pragma mark Application lifecycle</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">- (<span style="color: #c900a4;">void</span>)applicationDidFinishLaunching:(<span style="color: #7a0eac;">UIApplication</span> *)application {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #438288;"><span style="color: #000000;"> [</span>window<span style="color: #000000;"> </span><span style="color: #450084;">addSubview</span><span style="color: #000000;">:</span>tabBarController<span style="color: #000000;">.</span><span style="color: #450084;">view</span><span style="color: #000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"><span style="white-space: pre;"> </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008d00;"><span style="color: #000000;"> </span>// Override point for customization after app launch</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #450084;"><span style="color: #000000;"><span style="white-space: pre;"> </span>[</span><span style="color: #438288;">window</span><span style="color: #000000;"> </span>makeKeyAndVisible<span style="color: #000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #450084;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;"> </span>user = [[<span style="color: #438288;">User</span> <span style="color: #450084;">alloc</span>] <span style="color: #450084;">init</span>];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
</blockquote>
<p>Then from any view controller you can access the Delegate variable as such.</p>
<p>SomeViewController.m</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;">UIApplication<span style="color: #000000;"> *app = [</span>UIApplication<span style="color: #000000;"> </span><span style="color: #450084;">sharedApplication</span><span style="color: #000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;">app.user.username = @&#8221;Username&#8221;;</span></p>
</blockquote>
<p>While this can be done and will work. The overall use of the AppDelegate for this functionality is incorrect. The AppDelegate should be used for the following 2 reasons:</p>
<ul style="padding-left: 26px;">
<li>implemenations of the <code style="font-family: Courier, monospace; font-size: 12px;">NSApplication</code> delegate methods (including<code style="font-family: Courier, monospace; font-size: 12px;">applicationDidFinishLaunching:</code> to finalize application construction)</li>
<li>handling menu items for items that don&#8217;t exist in a window (for example, opening the application Preferences window)</li>
</ul>
<p>So, on that note, lets implement a Singleton. The &#8216;correct&#8217; way of creating a single global instance of an object that can be accessed and manipulated by the view controllers.</p>
<hr /><strong>Singleton Method</strong></p>
<p>First we need to make some changes to our User class as such:</p>
<p>User.h</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #df0002;"><span style="color: #7d4726;">#import </span>&lt;Foundation/Foundation.h&gt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@interface</span> User : NSObject {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>NSString<span style="color: #000000;"><span style="white-space: pre;"> </span>*</span><span style="color: #438288;">username</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7a0eac;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>NSString<span style="color: #000000;"><span style="white-space: pre;"> </span>*</span><span style="color: #438288;">password</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008d00;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span><span style="color: #7a0eac;">NSString</span><span style="color: #000000;"><span style="white-space: pre;"> </span>*</span><span style="color: #438288;">accountType</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>) NSString *username;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>) NSString *password;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@property</span> (<span style="color: #c900a4;">nonatomic</span>, <span style="color: #c900a4;">retain</span>) NSString *accountType;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">+ (<span style="color: #438288;">User</span> *)sharedUser;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@end</p>
</blockquote>
<p>User.m</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;">#import <span style="color: #df0002;">&#8220;User.h&#8221;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">static</span> User *sharedUser = <span style="color: #c900a4;">nil</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@implementation<span style="color: #000000;"> User</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@synthesize<span style="color: #000000;"> username;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@synthesize<span style="color: #000000;"> password;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="color: #c900a4;">@synthesize</span> accountType;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;">#pragma mark -</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;">#pragma mark Singleton Methods</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">+ (<span style="color: #438288;">User</span> *)sharedUser {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #438288;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span><span style="color: #c900a4;">if</span><span style="color: #000000;">(</span>sharedUser<span style="color: #000000;"> == </span><span style="color: #c900a4;">nil</span><span style="color: #000000;">){</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #450084;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span><span style="color: #438288;">sharedUser</span><span style="color: #000000;"> = [[</span><span style="color: #c900a4;">super</span><span style="color: #000000;"> </span>allocWithZone<span style="color: #000000;">:</span><span style="color: #c900a4;">NULL</span><span style="color: #000000;">] </span>init<span style="color: #000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"><span style="white-space: pre;"> </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #438288;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span><span style="color: #c900a4;">return</span><span style="color: #000000;"> </span>sharedUser<span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">+ (<span style="color: #c900a4;">id</span>)allocWithZone:(<span style="color: #7a0eac;">NSZone</span> *)zone {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #275a5e;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span><span style="color: #c900a4;">return</span><span style="color: #000000;"> [[</span><span style="color: #c900a4;">self</span><span style="color: #000000;"> </span>sharedManager<span style="color: #000000;">] </span><span style="color: #450084;">retain</span><span style="color: #000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">- (<span style="color: #c900a4;">id</span>)copyWithZone:(<span style="color: #7a0eac;">NSZone</span> *)zone {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>return<span style="color: #000000;"> </span>self<span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">- (<span style="color: #c900a4;">id</span>)retain {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>return<span style="color: #000000;"> </span>self<span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">- (<span style="color: #c900a4;">unsigned</span>)retainCount {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;"><span style="color: #c900a4;"> return</span><span style="color: #000000;"> </span>NSUIntegerMax<span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">- (<span style="color: #c900a4;">void</span>)release {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008d00;">//do nothing</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">- (<span style="color: #c900a4;">id</span>)autorelease {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>return<span style="color: #000000;"> </span>self<span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@end</p>
</blockquote>
<p>Now, in any view controller we need to access/manipulate the &#8216;global&#8217; user we can do:</p>
<p>SomeViewController.m</p>
<blockquote>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #df0002;"><span style="color: #7d4726;">#import </span>&#8220;SomeViewController.h&#8221;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7d4726;">#import <span style="color: #df0002;">&#8220;User.h&#8221;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@implementation<span style="color: #000000;"> SomeViewController</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">- (<span style="color: #c900a4;">void</span>)someFunction{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #438288;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>User<span style="color: #000000;"> *</span>user<span style="color: #000000;"> = [</span>User<span style="color: #000000;"> </span><span style="color: #275a5e;">sharedUser</span><span style="color: #000000;">];</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #438288;"><span style="color: #000000;"><span style="white-space: pre;"> </span></span>user<span style="color: #000000;">.</span>username<span style="color: #000000;"> = </span><span style="color: #df0002;">@&#8221;Username&#8221;</span><span style="color: #000000;">;</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;">}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;">
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #c900a4;">@end</p>
</blockquote>
<p>References and resources that made this post and my learning possible.</p>
<ul>
<li><a title="Cocoa Fundamentals Guide" href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html" target="_blank">Cocoa&#8217;s Fundamentals Guide</a> (by Apple)</li>
<li><a title="Cocoa With Love" href="http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html" target="_blank">Cocoa With Love</a></li>
<li><a title="Matt Galloway" href="http://iphone.galloway.me.uk/iphone-sdktutorials/singleton-classes/" target="_blank">Matt Galloway</a></li>
<li><a title="Stack Overflow" href="http://stackoverflow.com/questions/338734/iphone-proper-usage-of-application-delegate" target="_blank">Stack Overflow</a></li>
</ul>
<p>- Updated: 11.17.09 &#8211; Reviewed Apple&#8217;s documentation on singletons and made the proper changes. <a title="Apple's Singleton Documentation" href="http://developer.apple.com/iphone/library/DOCUMENTATION/General/Conceptual/DevPedia-CocoaCore/Singleton.html" target="_blank">Apple&#8217;s Singleton Documentation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/11/iphone-development-global-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nginx (Mini How-to)</title>
		<link>http://derekneely.com/2009/10/nginx-mini-how-to/</link>
		<comments>http://derekneely.com/2009/10/nginx-mini-how-to/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 19:40:02 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Load balancer]]></category>
		<category><![CDATA[Nginx]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=440</guid>
		<description><![CDATA[Nginx (Engine-X) is a very light-weight powerful web proxy server and load balancer. This is a quick how-to on configuring a weighted load balancer using Nginx. I&#8217;ll skip past the installation on your system. Mine is currently running on an OpenBSD firewall using Packet Filter, and is how I will be covering the configuration. Nginx [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Nginx Home Page" href="http://wiki.nginx.org/Main" target="_blank"><img class="alignright size-full wp-image-311" title="Nginx" src="http://derekneely.com/wp-content/uploads/2009/06/nginx-logo.png" alt="Nginx" width="245" height="63" />Nginx</a> (Engine-X) is a very light-weight powerful web proxy server and load balancer. This is a quick how-to on configuring a weighted load balancer using Nginx. I&#8217;ll skip past the installation on your system. Mine is currently running on an OpenBSD firewall using Packet Filter, and is how I will be covering the configuration. Nginx is available and work on both Unix and Linux.</p>
<p>Configuring Nginx to start on system boot:</p>
<blockquote><p># vi /etc/rc.local</p>
<pre># start nginx
if [ -x /usr/local/sbin/nginx ]; then
   echo -n ' nginx'; /usr/local/sbin/nginx
fi</pre>
</blockquote>
<p>Load balance configuration (one public ip -&gt; 3 private servers):</p>
<blockquote><p># vi /etc/nginx/nginx.conf</p>
<pre>user  nobody;
worker_processes  2;
worker_rlimit_nofile 10240;

error_log  /var/log/nginx/error.log;

events {
   worker_connections  8192;
}

http {

   upstream  site {
        server 192.168.1.100:80 max_fails=2 fail_timeout=15 weight=3;
        server 192.168.1.101:80 max_fails=2 fail_timeout=15 weight=3;
        server 192.168.1.102:80 max_fails=2 fail_timeout=15 weight=1;
   }

   upstream  site_ssl {
        server 192.168.1.100:443 max_fails=2 fail_timeout=15 weight=3;
        server 192.168.1.101:443 max_fails=2 fail_timeout=15 weight=3;
        server 192.168.1.102:443 max_fails=2 fail_timeout=15 weight=1;
   }

   server {
        listen  AAA.BBB.CCC.DDD:80;

        location / {
             access_log off;
             proxy_connect_timeout 15;
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_pass http://site;
        }
   }

   server {
        listen  AAA.BBB.CCC.DDD:443;

        ssl on;
        ssl_certificate /etc/ssl/ssl.cert/site.com.crt;
        ssl_certificate_key /etc/ssl/ssl.key/site.com.key;

        server_name site.com;

        location / {
             access_log off;
             proxy_connect_timeout 15;
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header X_FORWARDED_PROTO https;
             proxy_pass http://site_ssl;
        }
   }
}</pre>
</blockquote>
<p>Should you have a chain file you need to add it to the end of the certificate file as such:</p>
<blockquote><p># cat /path/to/chain.file &gt;&gt; /etc/ssl/ssl.cert/site.com.crt</p></blockquote>
<p>Packet Filter Firewall Rules:</p>
<blockquote><p># vi /etc/pf.conf</p>
<pre>site_ext="AAA.BBB.CCC.DDD"
site_int1="192.168.1.100"
site_int2="192.168.1.101"
site_int3="192.168.1.102"

pass in quick log on $ext_if inet proto tcp from any to $site_ext port 80 keep state
pass in quick log on $ext_if inet proto tcp from any to $corp_ext port 443 keep state
pass out quick log on $int_if inet proto tcp from any to $site_int1 port 80 keep state
pass out quick log on $int_if inet proto tcp from any to $site_int1 port 443 keep state
pass out quick log on $int_if inet proto tcp from any to $site_int2 port 80 keep state
pass out quick log on $int_if inet proto tcp from any to $site_int2 port 443 keep state
pass out quick log on $int_if inet proto tcp from any to $site_int3 port 80 keep state
pass out quick log on $int_if inet proto tcp from any to $site_int3 port 443 keep state</pre>
</blockquote>
<p>Helpful Nginx server management commands:</p>
<p>Test Nginx Config file:</p>
<blockquote><p># nginx -t -c /etc/nginx/nginx.conf</p></blockquote>
<p>Restart Nginx server:</p>
<blockquote><p># kill -HUP `cat /var/run/nginx.pid`</p></blockquote>
<p>Stop Nginx server:</p>
<blockquote><p># kill -QUIT `cat /var/run/nginx.pid`</p></blockquote>
<p>If your like me and want to keep tabs on the load balancing (as in ipvsadm for Linux ldirectord) you can add a label to the end of each of your firewall rules:</p>
<blockquote><p>label &#8220;[some unique label for this rule]&#8221; (i.e. label &#8220;site-ext&#8221;)</p></blockquote>
<p>Then using pftop -v label you will see:</p>
<blockquote>
<pre>RULE LABEL           PKTS     BYTES     STATES MAX  ACTION   DIR
....
16   site-ext        867991   630495K   11833       Pass     In  ...
17   site-ext-ssl    29427    13315230  847         Pass     In  ...
18   site-int-1      13761450 6842062   813483      Pass     Out ...
19   site-int-1-ssl  234678   12345     12344       Pass     Out ...
....</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/10/nginx-mini-how-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun With Active/Passive FTP and a PF Firewall</title>
		<link>http://derekneely.com/2009/09/fun-with-activepassive-ftp-and-a-pf-firewall/</link>
		<comments>http://derekneely.com/2009/09/fun-with-activepassive-ftp-and-a-pf-firewall/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 17:58:22 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Active FTP]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[OpenBSD]]></category>
		<category><![CDATA[Packet Filter]]></category>
		<category><![CDATA[Passive FTP]]></category>
		<category><![CDATA[PF]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=399</guid>
		<description><![CDATA[Here at work we&#8217;ve recently been moving off of a Linux/IPTables firewall setup to an OpenBSD/PF firewall. Well, anyone who has worked with firewalls knows the fun time you have with getting FTP to work through them. This includes client and server side. Well, this is my little &#8216;how-to&#8217; on doing just that with PF [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-281" title="OpenBSD" src="http://derekneely.com/wp-content/uploads/2009/06/openbsd.gif" alt="OpenBSD" width="168" height="140" />Here at work we&#8217;ve recently been moving off of a Linux/IPTables firewall setup to an OpenBSD/PF firewall. Well, anyone who has worked with firewalls knows the fun time you have with getting FTP to work through them. This includes client and server side. Well, this is my little &#8216;how-to&#8217; on doing just that with PF and PureFTP.</p>
<p>I originally started with <a title="PF: Issues with FTP" href="http://www.openbsd.org/faq/pf/ftp.html" target="_blank">this tutorial from OpenBSD</a> and was a good starting point but I felt it left out a few things.</p>
<p>First off. The tutorial above uses the ftp-proxy server on the box to allow proxying down to the ftp server. However, I didn&#8217;t exactly see any benefit of using it and didn&#8217;t seem to make anything easier. If I&#8217;m completely misunderstanding the usage of it please contact me and help me out. I DO want to do things right.</p>
<p>Here&#8217;s the overall layout of what is to happen:</p>
<blockquote><p>[Client] &lt;&#8212;&gt; [PF Firewall] &lt;&#8212;&gt; [FTP Server]</p></blockquote>
<p>Now, a few observations I&#8217;ve made while working with the firewall and maybe a bit clearer for others.</p>
<p>Here&#8217;s a great explanation of the overall FTP process from <a title="FTP Explained - Tech Republic" href="http://articles.techrepublic.com.com/5100-10878_11-5031026.html" target="_blank">Tech Republic</a>. Here&#8217;s the overall communication ports for the 2 different modes (as the PF firewall sees it &#8211; at least in my experience).</p>
<blockquote><p><strong>Active FTP:</strong><br />
-Inbound-<br />
&#8212; Authentication/Commands &#8212;<br />
Incoming:  21 (External interface &#8211; FW)<br />
Outgoing: 21 (Internal interface &#8211; FW)<br />
Incoming: 21 (FTP Server Interface)</p>
<p>-Outbound-<br />
&#8212; Data Transfer &#8212;<br />
Outgoing: &gt; 30000 (FTP Server Interface)<br />
Outgoing: &gt; 30000 (External interface &#8211; FW)</p>
<p><strong>Passive FTP:</strong><br />
-Inbound-<br />
&#8212; Authentication/Commands &#8212;<br />
Incoming:  21 (External interface &#8211; FW)<br />
Outgoing: 21 (Internal interface &#8211; FW)<br />
Incoming: 21 (FTP Server Interface)<br />
&#8212; Data Transfer &#8212;<br />
Incoming:  49000-51000 (External interface &#8211; FW)<br />
Outgoing: 49000-50000 (Internal interface &#8211; FW)<br />
Incoming: 49000-50000 (FTP Server Interface)</p>
<p>-Outbound-<br />
Outgoing: 49000-50000 (FTP Server Interface)<br />
Outgoing: 49000-50000 (External interface &#8211; FW)</p></blockquote>
<p>Alright enough chat and on to the code. First we need to configure the ftp server. In the  below examples I&#8217;ll cover PureFTP and ProFTPd for just the primary pieces of passive port configuration (I&#8217;ll give a nice ProFTP advanced configuration in a post to come). We&#8217;ll also assume the default &#8216;listening&#8217; port 21 of any standard FTP install/configuration. This is also on a Gentoo server so modify accordingly for your given distro.</p>
<p><strong>PureFTPd:</strong></p>
<blockquote><p>MISC_OTHER=&#8221;[various options/flags] -p 49000:51000 -P [Public IP]&#8220;</p></blockquote>
<p><strong>ProFTPd:</strong></p>
<blockquote><p>PassivePorts 49000 51000<br />
MasqueradeAddress [Public IP]</p></blockquote>
<p><strong>PF Firewall Rules:</strong> (Just the FTP Rules)</p>
<blockquote><p># Interface Definitions:<br />
ftp_ext=&#8221;[Public IP]&#8221;<br />
ftp_int=&#8221;[Private IP]&#8221;</p>
<p># NAT Rules<br />
nat on $ext_if from { $ftp_int } to any -&gt; $ftp_ext</p>
<p># Redirect Rules<br />
rdr pass on $ext_if inet proto tcp from any to $ftp_ext port 21 -&gt; $ftp_int port 21<br />
rdr pass on $ext_if inet proto tcp from any to $ftp_ext port 49000:51000 -&gt; $ftp_int</p>
<p># Firewall Rules<br />
pass out quick on $ext_if inet proto tcp from $ftp_ext to any port &gt; 1024 keep state</p>
<p>pass out quick log on $int_if inet proto tcp from any to $ftp_int port 21 keep state tag FTP label &#8220;ftp&#8221;<br />
pass out quick log on $int_if inet proto tcp from any to $ftp_int port 49000:51000 keep state tag FTP_PASV label &#8220;ftp-passive&#8221;</p></blockquote>
<p>That should be all you need for the PF rules and configuration on the FTP servers to get everything working and passing through. Feel free to contact me should you have any additional fixes or have a good explanation of how the ftp-proxy works and benefits of. I&#8217;ve just gotta find the time to do some experimenting.</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/09/fun-with-activepassive-ftp-and-a-pf-firewall/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MacFUSE Fix for Snow Leopard</title>
		<link>http://derekneely.com/2009/08/macfuse-fix-for-snow-leopard/</link>
		<comments>http://derekneely.com/2009/08/macfuse-fix-for-snow-leopard/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 00:11:57 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=392</guid>
		<description><![CDATA[I recently upgraded to Snow Leopard (Mac OS X 10.6). I&#8217;m quite used to using MacFUSE to remotely mount (via SSH) development systems for ease of coding. However, I just noticed that MacFUSE now refuses to establish a connection to the remote server. So, here is a fix for just that. 1) Quit Macfusion 2) [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-283" title="Apple" src="http://derekneely.com/wp-content/uploads/2009/06/apple.jpg" alt="Apple" width="120" height="136" />I recently upgraded to Snow Leopard (Mac OS X 10.6). I&#8217;m quite used to using MacFUSE to remotely mount (via SSH) development systems for ease of coding. However, I just noticed that MacFUSE now refuses to establish a connection to the remote server. So, here is a fix for just that.</p>
<p>1) Quit Macfusion</p>
<p>2) Open System Preferences and then open the MacFUSE pane. Check the “Show Beta Versions” box and click “Check For Updates”. Go ahead and update MacFUSE.</p>
<p>3) Open a terminal and copy and past the following:</p>
<blockquote><p>rm /Applications/Macfusion.app/Contents/PlugIns/sshfs.mfplugin/Contents/Resources/sshnodelay.so</p></blockquote>
<p>Enjoy!</p>
<p>Fix provided from: <a title="Racker Hacker - MacFUSE Fix" href="http://rackerhacker.com/2009/08/28/fix-macfusion-on-snow-leopard/" target="_blank">Racker Hacker</a></p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/08/macfuse-fix-for-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pure-FTP with Database Authentication</title>
		<link>http://derekneely.com/2009/07/pure-ftp-with-database-authentication/</link>
		<comments>http://derekneely.com/2009/07/pure-ftp-with-database-authentication/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 12:35:18 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Authentication]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Postgres]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Pure-FTP]]></category>
		<category><![CDATA[User Accounts]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=374</guid>
		<description><![CDATA[Pure-FTP is  a powerful ftp server. If you are like me however, you don&#8217;t like to create system accounts for each individual user. Well, this is where we are in luck! Pure-FTP has the ability to tie into both PostgreSQL and MySQL.  In this example I have tied it into a PostgreSQL database. I will [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-284" title="Linux" src="http://derekneely.com/wp-content/uploads/2009/06/linux.jpg" alt="Linux" width="113" height="142" />Pure-FTP is  a powerful ftp server. If you are like me however, you don&#8217;t like to create system accounts for each individual user. Well, this is where we are in luck! Pure-FTP has the ability to tie into both PostgreSQL and MySQL.  In this example I have tied it into a PostgreSQL database. I will also include the MySQL snippet of the configuration but it hasn&#8217;t been tested by me. Also note that this is a Gentoo based installation but the general configuration should be the same.</p>
<p>Install Pure-FTP with MySQL and/or PostgreSQL support:</p>
<blockquote><p># &gt; vi /etc/make.conf<br />
&#8211; add &#8216;postgres&#8217; and/or &#8216;mysql&#8217; to the USE flag or:</p>
<p>#&gt; USE=&#8221;mysql postgres&#8221; emerge -av net-ftp/pure-ftpd</p></blockquote>
<p>Now that Pure-FTP is installed with the various database support, we can configure Pure-FTP to authenticate off of a database. You may need to tailor the SQL queries to match the schema of your database.</p>
<p>PostgreSQL:</p>
<blockquote><p>#&gt;  vi /etc/pureftpd-pgsql.conf</p>
<p># If PostgreSQL listens to a TCP socket<br />
PGSQLServer localhost<br />
PGSQLPort 5432<br />
# *or* if PostgreSQL can only be reached through a local Unix socket<br />
# PGSQLServer /tmp<br />
# PGSQLPort .s.PGSQL.5432<br />
# Mandatory : user to bind the server as.<br />
PGSQLUser [pureftpd]<br />
# Mandatory : user password. You *must* have a password.<br />
PGSQLPassword [pureftpd_password]<br />
# Mandatory : database to open.<br />
PGSQLDatabase [pureftpd_database]<br />
# Mandatory : how passwords are stored<br />
# Valid values are : &#8220;cleartext&#8221;, &#8220;crypt&#8221;, &#8220;md5&#8243; and &#8220;any&#8221;<br />
#PGSQLCrypt cleartext<br />
PGSQLCrypt crypt</p>
<p># In the following directives, parts of the strings are replaced at<br />
# run-time before performing queries :<br />
#<br />
# \L is replaced by the login of the user trying to authenticate.<br />
# \I is replaced by the IP address the user connected to.<br />
# \P is replaced by the port number the user connected to.<br />
# \R is replaced by the IP address the user connected from.<br />
# \D is replaced by the remote IP address, as a long decimal number.<br />
#<br />
# Very complex queries can be performed using these substitution strings,<br />
# especially for virtual hosting.<br />
# Query to execute in order to fetch the password<br />
PGSQLGetPW SELECT password FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
# Query to execute in order to fetch the system user name or uid<br />
PGSQLGetUID SELECT uid FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
# Optional : default UID &#8211; if set this overrides PGSQLGetUID<br />
#PGSQLDefaultUID 1000<br />
# Query to execute in order to fetch the system user group or gid<br />
PGSQLGetGID SELECT gid FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
# Optional : default GID &#8211; if set this overrides PGSQLGetGID<br />
#PGSQLDefaultGID 1000<br />
# Query to execute in order to fetch the home directory<br />
PGSQLGetDir SELECT dir FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
#########OPTIONAL SETTINGS#############<br />
# Optional : query to get the maximal number of files<br />
# Pure-FTPd must have been compiled with virtual quotas support.<br />
# PGSQLGetQTAFS SELECT QuotaFiles FROM users WHERE User=&#8217;\L&#8217;<br />
# Optional : query to get the maximal disk usage (virtual quotas)<br />
# The number should be in Megabytes.<br />
# Pure-FTPd must have been compiled with virtual quotas support.<br />
# PGSQLGetQTASZ SELECT QuotaSize FROM users WHERE User=&#8217;\L&#8217;<br />
# Optional : ratios. The server has to be compiled with ratio support.<br />
PGSQLGetRatioUL SELECT ul_ratio FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
PGSQLGetRatioDL SELECT dl_ratio FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
# Optional : bandwidth throttling.<br />
# The server has to be compiled with throttling support.<br />
# Values are in KB/s .<br />
PGSQLGetBandwidthUL SELECT ul_bandwidth FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;<br />
PGSQLGetBandwidthDL SELECT dl_bandwidth FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;</p></blockquote>
<p>Now we need to modify the pure-ftpd config file (keep in mind this is Gentoo)</p>
<blockquote><p>#&gt; vi /etc/conf.d/pure-ftpd</p>
<p>Look for the line: AUTH=&#8221;-l unix&#8221; and change to:</p>
<p>AUTH=&#8221;-l pgsql:/etc/pureftpd-pgsql.conf</p>
<p>#&gt; /etc/init.d/pure-ftpd restart</p></blockquote>
<p>This should conclude your intstallation of Pure-FTP with Postgres database support.</p>
<p>MySQL Config File:</p>
<blockquote><p>Coming Soon!</p></blockquote>
<p>A couple of little tweaks that I&#8217;ve had to use for some of the configurations.</p>
<p>If you want all users to go to the same directory and don&#8217;t have or want to store the directory information in the database you can change this line in the pureftpd-pgsql.conf:</p>
<blockquote><p>PGSQLGetDir SELECT &#8216;/home/ftpdir&#8217; FROM ftp_users WHERE ftp_user=&#8217;\L&#8217;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2009/07/pure-ftp-with-database-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
