<?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 &#187; Mobile</title>
	<atom:link href="http://derekneely.com/category/mobile/feed/" rel="self" type="application/rss+xml" />
	<link>http://derekneely.com</link>
	<description>...what I care to share...</description>
	<lastBuildDate>Thu, 06 Oct 2011 15:10:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MJPEG to H.264 Streaming for Mobile with VLC</title>
		<link>http://derekneely.com/2011/10/mjpeg-h264-streaming-mobile-vlc/</link>
		<comments>http://derekneely.com/2011/10/mjpeg-h264-streaming-mobile-vlc/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 15:10:17 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Streaming]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[Encoding]]></category>
		<category><![CDATA[H.264]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[MJPEG]]></category>
		<category><![CDATA[MPMoviePlayerController]]></category>
		<category><![CDATA[Video Encoding]]></category>
		<category><![CDATA[Video Streaming]]></category>
		<category><![CDATA[VLC]]></category>
		<category><![CDATA[VLC Media Player]]></category>
		<category><![CDATA[Web Cam]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=634</guid>
		<description><![CDATA[Dang! Its been a while since I&#8217;ve been able to get out here and post something new. We&#8217;ve been busy, busy, busy here at v4 living the dream. Anyhow, as of recently its been tasked upon us to work with some streaming video. Now, the hardware we will be using for our client are some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://derekneely.com/2011/10/mjpeg-h264-streaming-mobile-vlc/largevlc/" rel="attachment wp-att-651"><img class="alignright size-full wp-image-651" title="VLC Icon" src="http://derekneely.com/wp-content/uploads/2011/10/largeVLC.png" alt="VLC Media Player" width="168" height="168" /></a>Dang! Its been a while since I&#8217;ve been able to get out here and post something new. We&#8217;ve been busy, busy, busy here at <a title="v4 Development" href="http://v4development.com">v4</a> living the dream.</p>
<p>Anyhow, as of recently its been tasked upon us to work with some streaming video. Now, the hardware we will be using for our client are some nice IP/H.264 compatible cameras. Well, I personally do not have one but needed a solution by which I could test and work with. I have one of those little eye ball looking cameras and found some free software (<a title="WebCampXP" href="http://www.webcamxp.com/" target="_blank">WebCamXP</a>) that would run a simple MJPEG stream. (Yea, yea&#8230;its windows but who doesn&#8217;t have a windows box to hack and slash on? Ha!) After this is up and running you have a basic MJPEG stream that is running and accessible via http://10.0.0.99:8080/webcamp_1.cgi (or whatever your internal IP is and the port you configured in the software)</p>
<p><strong>** Note:</strong> This tutorial uses iPhone references as thats what I worked with first. I&#8217;ll update with the Android version later. I am also using Linux (Ubuntu) to do the encoding and serving of the new video stream. Also assuming you have Apache or another web server up and running.</p>
<p>Now, this .cgi page/script &#8216;can&#8217; be placed as the source of a UIWebview and works ok.</p>
<pre>NSString *urlAddress = @"http://10.0.0.99:8080/cam_1.cgi";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[streamWebView loadRequest:requestObj];</pre>
<p>But, ultimately this is not what we&#8217;re looking for. We need to get a nice H.264 compatible stream rolling out so that we can play this directly to the iPhone (MPMoivePlayerController) or be able to hook into a streaming server (as we&#8217;re planning on doing) so that we can re-broadcast to several devices at once.</p>
<p>So&#8230;how might we convert this MJPEG (.cgi) into an H.264 compatible stream? <a title="VideoLan (VLC Media Player)" href="http://www.videolan.org/" target="_blank">VLC Media Player</a> to the rescue.</p>
<p>On your Linux box install VLC and the x264 libraries.</p>
<pre># apt-get install vlc x264</pre>
<p>A few of the tutorials you read on this all reference using the command: <em><strong>vlc</strong></em>. However, if you don&#8217;t have X11 installed on your system (as I do not) you will run into a few errors with regards to this. But, have no fear, VLC provided a command line option: <em><strong>cvlc</strong></em>.</p>
<p>Now what we need to do is fire up VLC with a bunch of options that will read in the MJPEG (.cgi) convert it to H.264 and then provide us with a means of accessing the stream (via the Linux server &#8211; 10.0.0.69). So, on the command prompt do something like:</p>
<pre>cvlc --intf=rc http://10.0.0.99:8080/cam_1.cgi --sout '#transcode{fps=25,
vcodec=h264,venc=x264{aud,profile=baseline,level=30,keyint=30,
bframes=0,ref=1,nocabac},acodec=mp3,ab=56,audio-sync,deinterlace}
:standard{mux=ts,access=http,dst=10.0.0.69:8090/myStream.mp4}'</pre>
<p>Now, on the command prompt you&#8217;ll see a bunch of stuff start scrolling by. This is what you want. Its reading in frames from the original MJPEG stream and converting them. But, you&#8217;re not done yet. In order to get this to play via MPMoviePlayerController on the iPhone, we need to setup the .m3u8 or the playlist file.</p>
<p>In your web server directory create a file myStream.m3u8 and put the following in and save:</p>
<pre>
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10, 

http://10.0.0.69:8090/myStream.mp4
</pre>
<p>Now you&#8217;re ready for some iPhone code to show the stream.</p>
<pre>NSURL *url = [NSURL URLWithString:@"http://10.0.0.69/myStream.m3u8"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
player.controlStyle = MPMovieControlStyleNone;
[player.view setFrame:CGRectMake(0, 120, 320 , 200)];
[self.view addSubview:player.view];
[player play];</pre>
<p>This should basically do it. I don&#8217;t believe I left out any steps. I&#8217;ll update if I run across any missing steps or you guys let me know. When you run the app, it can sometimes take a few seconds before the video starts playing. At one point I set a background color to the mpmovieplayercontroller&#8217;s view so that I could tell where it was being</p>
<p>With MPMoviePlayerController there are several other options you may be interested in using/implementing.</p>
<p>When setting up the player you can have your containing view controller listen for some of the playback events (can help with some debugging) with:</p>
<pre>//Defined in the above MPMoviePlayerController allocation
[[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(moviePlayerPlaybackStateDidChange:)  name:MPMoviePlayerPlaybackStateDidChangeNotification  object:nil];</pre>
<pre>//NSNotification callback function
- (void)moviePlayerPlaybackStateDidChange:(NSNotification*)notification {
     NSLog(@"playbackDidChanged");
     MPMoviePlayerController *moviePlayer = notification.object;

     MPMoviePlaybackState playbackState = moviePlayer.playbackState;

     if(playbackState == MPMoviePlaybackStateStopped) {
          NSLog(@"MPMoviePlaybackStateStopped");
     } else if(playbackState == MPMoviePlaybackStatePlaying) {
          NSLog(@"MPMoviePlaybackStatePlaying");
     } else if(playbackState == MPMoviePlaybackStatePaused) {
          NSLog(@"MPMoviePlaybackStatePaused");
     } else if(playbackState == MPMoviePlaybackStateInterrupted) {
          NSLog(@"MPMoviePlaybackStateInterrupted");
     } else if(playbackState == MPMoviePlaybackStateSeekingForward) {
          NSLog(@"MPMoviePlaybackStateSeekingForward");
     } else if(playbackState == MPMoviePlaybackStateSeekingBackward) {
          NSLog(@"MPMoviePlaybackStateSeekingBackward");
     }
}</pre>
<p>Please <a href="mailto:feedback@derekneely.com">let me know</a> if I&#8217;ve left out any steps or you have any issues and I&#8217;ll be happy to help and work through it with you. This was a quick and dirty how-to with a ways to go before I push anything out to production. Just wanted to share my research and discovery. Good luck!</p>
<p>References:<br />
<a title="Apple - Reference:MPMoviePlayerController" href="http://developer.apple.com/LIBRARY/IOS/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html">Apple &#8211; Reference: MPMoviePlayerController</a><br />
<a title="StackOverflow" href="http://stackoverflow.com/questions/2663637/http-stream-without-extension-in-mpmovieplayercontroller">StackOverflow &#8211; HTTP stream without extension in MPMoviePlayerController</a></p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2011/10/mjpeg-h264-streaming-mobile-vlc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Size-to-Fit Text in UITextView (iPhone)</title>
		<link>http://derekneely.com/2011/04/size-to-fit-text-in-uitextview-iphone/</link>
		<comments>http://derekneely.com/2011/04/size-to-fit-text-in-uitextview-iphone/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 16:44:43 +0000</pubDate>
		<dc:creator>derek</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Fit Text]]></category>
		<category><![CDATA[Font Size]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Resize Text]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[UITextView]]></category>

		<guid isPermaLink="false">http://derekneely.com/?p=615</guid>
		<description><![CDATA[The UITextView is a very useful view. You&#8217;re able to show and interact with large amounts of text. However, I recently found the need to size the UITextView in Interface Builder to fit nicely in a pre-layed out interface. Well, low-and-behold the client I was working for started sending large amounts of text that was [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://derekneely.com/wp-content/uploads/2009/11/xcode-icon.png"><img class="alignright size-full wp-image-479" title="xcode-icon" src="http://derekneely.com/wp-content/uploads/2009/11/xcode-icon.png" alt="" width="143" height="143" /></a>The UITextView is a very useful view. You&#8217;re able to show and interact with large amounts of text. However, I recently found the need to size the UITextView in Interface Builder to fit nicely in a pre-layed out interface. Well, low-and-behold the client I was working for started sending large amounts of text that was to be displayed here. We didn&#8217;t want scrolling but needed to display all the text. So, we needed to resize the text until it would fit and all would be displayed. Below is a very simple way of resizing the text in the UITextView to fit within its current bounds.</p>
<p>At some point define the max size you want the font to be. I typically put this in my .h file</p>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #7b482f} span.s1 {color: #2f2fcf} --></p>
<pre>#define kDefaultFontSize 24.0</pre>
<p>Then in your .m file where you add the text to the UITextView you would place something like:</p>
<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #488186} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008426} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #753ea3} p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo} span.s1 {color: #000000} span.s2 {color: #753ea3} span.s3 {color: #411f7c} span.s4 {color: #d92823} span.s5 {color: #c22a9c} span.s6 {color: #488186} span.s7 {color: #2f2fcf} span.s8 {color: #7b482f} --></p>
<pre>myTextView.text = @"Some long string that will be in the UITextView";
myTextView.font = [UIFont systemFontOfSize:kDefaultFontSize];

//setup text resizing check here
if (myTextView.contentSize.height &gt; myTextView.frame.size.height) {
    int fontIncrement = 1;
    while (myTextView.contentSize.height &gt; myTextView.frame.size.height) {
        myTextView.font = [UIFont systemFontOfSize:kDefaultFontSize-fontIncrement];
        fontIncrement++;
    }
}</pre>
<p>Hope this helps! Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://derekneely.com/2011/04/size-to-fit-text-in-uitextview-iphone/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>
	</channel>
</rss>

