<?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>iCodeBlog &#187; objective-c</title>
	<atom:link href="/category/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://icodeblog.com</link>
	<description>iPhone Programming Tutorials</description>
	<lastBuildDate>Wed, 22 Sep 2010 00:14:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Floodgates opened for iPhone development</title>
		<link>http://icodeblog.com/2009/10/12/floodgates-opened-for-iphone-development/</link>
		<comments>http://icodeblog.com/2009/10/12/floodgates-opened-for-iphone-development/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 18:56:30 +0000</pubDate>
		<dc:creator>rick</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone Articles]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=1418</guid>
		<description><![CDATA[<a href="/2009/10/12/floodgates-opened-for-iphone-development/"><img align="left" hspace="5" width="150" height="150" src="/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>For as active as iPhone application development community is, achieving success in iTunes has been an elusive affair for those who participate in this vertical.  The two main obstacles presented to anyone who wants to create an iPhone applications are: one, finding resources/developers with the right skill set; and two, marketing the application after the application has been submitted.  The bad news is Apple keeps iTunes a black box.  Unless your application has been reviewed or mentioned on review sites or blogs, no one will be able to find your application outside of iTunes.  This makes marketing your application relatively difficult.  Here's the good news: the cost to build an iPhone application should come down substantially as it no longer requires a developer with an exclusive knowledge to a specific technology to build an application for iPhone.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ficodeblog.com%2F2009%2F10%2F12%2Ffloodgates-opened-for-iphone-development%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ficodeblog.com%2F2009%2F10%2F12%2Ffloodgates-opened-for-iphone-development%2F&amp;source=elctech&amp;style=normal&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p>For as active as iPhone application development community is, achieving success in iTunes has been an elusive affair for those who participate in this vertical.  The two main obstacles presented to anyone who wants to create an iPhone applications are: one, finding resources/developers with the right skill set; and two, marketing the application after the application has been submitted.  The bad news is Apple keeps iTunes a black box.  Unless your application has been reviewed or mentioned on review sites or blogs, no one will be able to find your application outside of iTunes.  This makes marketing your application relatively difficult.  Here&#8217;s the good news: the cost to build an iPhone application should come down substantially as it no longer requires a developer with an exclusive knowledge to a specific technology to build an application for iPhone.</p>
<p>When Apple first announced to openly accept applications from developers, the prerequisite for the developer is a somewhat extensive knowledge in a language called &#8220;Objective-C.&#8221;  For a short while, it would seem as though the developers who could produce Objective-C codes were superstars that also came with a superstar price tag.  Such stardom, however, did not last.  When <a href="http://phonegap.com">PhoneGap</a> was introduced as an open source development tool for iPhone via JavaScript, the web development community devoured it like salmon to a hungry bear.  Shortly after PhoneGap&#8217;s success, <a href="http://www.mono-project.com">Mono framework</a> was released in the commercial sector that provided the necessary development tools to the vast number of C# developers across multiple platforms.  And to unhinge the final bar from the floodgates, Adobe has <a href="http://www.informationweek.com/news/internet/webdev/showArticle.jhtml?articleID=220301118">just announced</a> that the next release of Flash is capable of compiling a flash project directly into native iPhone application.  Simply put, a project can go from design to finish without even being touched by a developer.</p>
<p>The implication for this phenomenon is a curious one: how will Apple respond to the rush of new applications when the floodgates are finally open?  Will Apple still be able to keep its manual review process intact?  When the market is saturated with developers and applications, will Apple be able to to maintain iTunes exclusive distribution channel and continue to motivate merchants to participate?</p>
<p>How all of this will affect Apple or iPhone developers is yet to be seen.  However, one thing that seems to be true is that when given enough demands, people will find ways to liberate a technology regardless of how businesses are structured around it. </p>
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/10/12/floodgates-opened-for-iphone-development/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Using NSXMLParser to Pull UIImages From the Web</title>
		<link>http://icodeblog.com/2009/06/19/using-nsxmlparser-to-pull-uiimages-from-the-web/</link>
		<comments>http://icodeblog.com/2009/06/19/using-nsxmlparser-to-pull-uiimages-from-the-web/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 23:35:15 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[NSXMLParser]]></category>
		<category><![CDATA[UIImage]]></category>
		<category><![CDATA[UIScrollView]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=945</guid>
		<description><![CDATA[<a href="/2009/06/19/using-nsxmlparser-to-pull-uiimages-from-the-web/"><img align="left" hspace="5" width="150" height="150" src="/wp-content/uploads/2009/06/picture-32-150x150.png" class="alignleft wp-post-image tfe" alt="picture-32" title="" /></a>Introduction Hello everyone, welcome to my third screeencast. This screencast is the result of a request made in the comments of my first post. I am going to be covering many topics in this post. But the general idea of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ficodeblog.com%2F2009%2F06%2F19%2Fusing-nsxmlparser-to-pull-uiimages-from-the-web%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ficodeblog.com%2F2009%2F06%2F19%2Fusing-nsxmlparser-to-pull-uiimages-from-the-web%2F&amp;source=elctech&amp;style=normal&amp;hashtags=NSXMLParser,UIImage,UIScrollView,XML" height="61" width="50" /><br />
			</a>
		</div>
<h1><span style="color: #ff6600;">Introduction</span></h1>
<p>Hello everyone, welcome to my third screeencast. This screencast is the result of a request made in the comments of my <a title="Creating a Custom UITableViewCell using Interface Builder" href="/2009/05/24/custom-uitableviewcell-using-interface-builder/" target="_blank">first post</a>. I am going to be covering many topics in this post. But the general idea of the app we will build is that it will use an XML file online to get the URL and title of a given picture. For each URL and Title pair a view will be created with a UIImageView showing the image and a UILabel showing the title. Each of these views will be placed in a UIScrollView to flip through, like th functinoality of the Photos app.</p>
<h2><span style="color: #000000;">Skill Level</span> <span style="color: #ff6600;">Medium</span></h2>
<p>This app is going to require a decent amount of experience with Objective C and xCode. Also some minimal understanding of XML and XML schema/structure would be valuable.</p>
<h1><span style="color: #ff6600;">Source Code<br />
</span></h1>
<h3><a title="Using NSXMLParser to Pull UIImages from the Web" href="/wp-content/uploads/2009/06/iCodeBlogXMLImage.zip"><span style="text-decoration: underline;">Available Here</span></a></h3>
<h1><span style="color: #ff6600;">Screencast</span></h1>
<p>I film myself coding out the entire sample project for each post. I personally think going through the Screencast is the best way to learn. But feel free to look through the slides and text if that suites you better.</p>
<p><object width="600" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5515556&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5515556&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="375"></embed></object>
<p><a href="http://vimeo.com/5515556">iCodeBlog: Using NSXMLParser to pull UIImages off the Web</a> from <a href="http://vimeo.com/user2008025">Collin Ruffenach</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h2><span style="color: #ff6600;">SCREENCAST ADDITION</span></h2>
<pre style="padding-left: 30px;">Adding a final line to layoutSubviews should be:</pre>
<pre style="padding-left: 30px;">     [scrollview setFrame:workingFrame];

this will stop the scroll view from bouncing up and down.</pre>
<h1><span style="color: #ff6600;">Tutorial</span></h1>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-947" src="/wp-content/uploads/2009/06/picture-32.png" alt="picture-32" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-948" src="/wp-content/uploads/2009/06/picture-41.png" alt="picture-41" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-949" src="/wp-content/uploads/2009/06/picture-5.png" alt="picture-5" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-950" src="/wp-content/uploads/2009/06/picture-61.png" alt="picture-61" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-951" src="/wp-content/uploads/2009/06/picture-71.png" alt="picture-71" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-952" src="/wp-content/uploads/2009/06/picture-81.png" alt="picture-81" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-953" src="/wp-content/uploads/2009/06/picture-91.png" alt="picture-91" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-954" src="/wp-content/uploads/2009/06/picture-101.png" alt="picture-101" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-955" src="/wp-content/uploads/2009/06/picture-111.png" alt="picture-111" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-956" src="/wp-content/uploads/2009/06/picture-121.png" alt="picture-121" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-957" src="/wp-content/uploads/2009/06/picture-131.png" alt="picture-131" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-958" src="/wp-content/uploads/2009/06/picture-141.png" alt="picture-141" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-959" src="/wp-content/uploads/2009/06/picture-151.png" alt="picture-151" width="620" height="387" /></span></p>
<h2><span style="color: #ff6600;">iCodeBlogXMLImagesViewController.h:</span></h2>
<pre style="padding-left: 60px;">@interface iCodeBlogXMLImagesViewController : UIViewController
{
	IBOutlet UIScrollView *scrollview;
}

@property (nonatomic, retain) IBOutlet UIScrollView *scrollview;</pre>
<h2><span style="color: #ff6600;">iCodeBlogXMLImagesViewController.m</span></h2>
<pre style="padding-left: 60px;">@synthesize scrollview;</pre>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-960" src="/wp-content/uploads/2009/06/picture-161.png" alt="picture-161" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-961" src="/wp-content/uploads/2009/06/picture-171.png" alt="picture-171" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-962" src="/wp-content/uploads/2009/06/picture-181.png" alt="picture-181" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-963" src="/wp-content/uploads/2009/06/picture-191.png" alt="picture-191" width="620" height="387" /></span></p>
<h2><span style="color: #ff6600;">iCodeBlogXMLView.h:</span></h2>
<pre style="padding-left: 60px;">@interface iCodeBlogXMLView : UIView
{
	IBOutlet UIImageView *imageView;
	IBOutlet UILabel *title;
}

@property (nonatomic, retain) IBOutlet UIImageView *imageView;
@property (nonatomic, retain) IBOutlet UILabel *title;

@end</pre>
<h2><span style="color: #ff6600;">iCodeBlogXMLView.m</span></h2>
<pre style="padding-left: 60px;">@synthesize imageView;
@synthesize title;</pre>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-964" src="/wp-content/uploads/2009/06/picture-201.png" alt="picture-201" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-965" src="/wp-content/uploads/2009/06/picture-211.png" alt="picture-211" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-966" src="/wp-content/uploads/2009/06/picture-221.png" alt="picture-221" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-967" src="/wp-content/uploads/2009/06/picture-23.png" alt="picture-23" width="620" height="387" /></span></p>
<h2><span style="color: #ff6600;">iCodeBlogXMLElement.h:</span></h2>
<pre style="padding-left: 60px;">@interface iCodeBlogXMLElement : NSObject
{
	UIImage *image;
	NSString *imageTitle;
}

@property (nonatomic, retain) UIImage *image;
@property (nonatomic, retain) NSString *imageTitle;

@end</pre>
<h2><span style="color: #ff6600;">iCodeBlogXMLElement.m</span></h2>
<pre style="padding-left: 60px;">@synthesize image;
@synthesize imageTitle;</pre>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-968" src="/wp-content/uploads/2009/06/picture-241.png" alt="picture-241" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-969" src="/wp-content/uploads/2009/06/picture-251.png" alt="picture-251" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-970" src="/wp-content/uploads/2009/06/picture-261.png" alt="picture-261" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-971" src="/wp-content/uploads/2009/06/picture-27.png" alt="picture-27" width="620" height="387" /></span></p>
<h2><span style="color: #ff6600;">iCodeBlogXMLImagesViewController.h:</span></h2>
<pre style="padding-left: 60px;">#import &lt;UIKit/UIKit.h&gt;
#import "iCodeBlogXMLElement.h"
#import "iCodeBlogXMLView.h"

@interface iCodeBlogXMLImagesViewController : UIViewController
{
	IBOutlet UIScrollView *scrollview;

	NSXMLParser *parser;
	NSMutableString *currentAttribute;
	NSMutableArray *xmlElementObjects;

	iCodeBlogXMLElement *tempElement;
}

@property (nonatomic, retain) IBOutlet UIScrollView *scrollview;

@property (nonatomic, retain) NSXMLParser *parser;
@property (nonatomic, retain) NSMutableString *currentAttribute;
@property (nonatomic, retain) NSMutableArray *xmlElementObjects;

@property (nonatomic, retain) iCodeBlogXMLElement *tempElement;

-(void)layoutSubview;

@end</pre>
<h2><span style="color: #ff6600;">iCodeBlogXMLImagesViewController.m</span></h2>
<pre style="padding-left: 60px;">@implementation iCodeBlogXMLImagesViewController

@synthesize scrollview;
@synthesize parser;
@synthesize currentAttribute;
@synthesize xmlElementObjects;
@synthesize tempElement;

...

- (void)viewDidLoad
{
    [super viewDidLoad];

	xmlElementObjects = [[NSMutableArray alloc] init];

	parser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://losectrl-gaincommand.com/iCodeBlogHelper/Tutorial3/iCodeBlogImageXML.xml"]];
	[parser setDelegate:self];
	[parser parse];
}

...

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{

}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{

}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{

}</pre>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-972" src="/wp-content/uploads/2009/06/picture-281.png" alt="picture-281" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-973" src="/wp-content/uploads/2009/06/picture-291.png" alt="picture-291" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-974" src="/wp-content/uploads/2009/06/picture-301.png" alt="picture-301" width="620" height="387" /></span></p>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-975" src="/wp-content/uploads/2009/06/picture-311.png" alt="picture-311" width="620" height="387" /></span></p>
<h2><span style="color: #ff6600;">iCodeBlogXMLImagesViewController.m</span></h2>
<pre style="padding-left: 60px;">- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
	if(![elementName compare:@"PictureInfo"])
	{
		tempElement = [[iCodeBlogXMLElement alloc] init];
	}

	else if(![elementName compare:@"imageURL"])
	{
		currentAttribute = [NSMutableString string];
	}

	else if(![elementName compare:@"imageTitle"])
	{
		currentAttribute = [NSMutableString string];
	}
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
	if(![elementName compare:@"PictureInfo"])
	{
		[xmlElementObjects addObject:tempElement];
	}

	else if(![elementName compare:@"imageURL"])
	{
		NSURL *imageURL = [NSURL URLWithString:currentAttribute];
		NSData *data =  [NSData dataWithContentsOfURL:imageURL];
		UIImage *image = [[UIImage alloc] initWithData:data];

		[tempElement setImage:image];
	}

	else if(![elementName compare:@"imageTitle"])
	{
		NSLog(@"The image title is %@", currentAttribute);
		[tempElement setImageTitle:currentAttribute];
	}

	else if(![elementName compare:@"Pictures"])
	{
		[self layoutSubview];
	}
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
	if(self.currentAttribute)
	{
		[self.currentAttribute appendString:string];
	}
}</pre>
<p><span style="color: #ff6600;"><img class="aligncenter size-full wp-image-976" src="/wp-content/uploads/2009/06/picture-321.png" alt="picture-321" width="622" height="388" /></span></p>
<h2><span style="color: #ff6600;">iCodeBlogXMLImagesViewController.m</span></h2>
<pre style="padding-left: 60px;"><span style="color: #ff6600;"><span style="color: #000000;">-(void)layoutSubview
{
	CGRect workingFrame;

	workingFrame.origin.x = 0;
	workingFrame.origin.y = 0;
	workingFrame.size.height = 480;
	workingFrame.size.width = 320;

	iCodeBlogXMLView *myView;

	for(iCodeBlogXMLElement *element in [self xmlElementObjects])
	{
		myView = [[iCodeBlogXMLView alloc] initWithFrame:workingFrame];

		NSLog(@"Element title is: %@", [element imageTitle]);

		NSArray *topLeveObjects = [[NSBundle mainBundle] loadNibNamed:@"iCodeBlogXMLView" owner:nil options:nil];

		for(id currentObject in topLeveObjects)
		{
			if([currentObject isKindOfClass:[iCodeBlogXMLView class]])
			{
				myView = (iCodeBlogXMLView *)currentObject;
			}
		}

		[[myView imageView] setImage:[element image]];
		[[myView title] setText:[element imageTitle]];
		[myView setFrame:workingFrame];

		[scrollview addSubview:myView];

		workingFrame.origin.x = workingFrame.origin.x + 320;
	}

	workingFrame.size.width = workingFrame.origin.x;
	[scrollview setContentSize:workingFrame.size];

	workingFrame.origin.x = 0;
	workingFrame.origin.y = 0;
	workingFrame.size.width = 320;
	workingFrame.size.height = 480;
}</span>

<img class="aligncenter size-large wp-image-996" src="/wp-content/uploads/2009/06/picture-33-1024x640.png" alt="picture-33" width="623" height="389" />
</span></pre>
<h2><span style="color: #ff6600;">iCodeBlogXMLImagesViewController.m</span></h2>
<pre>	parser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://losectrl-gaincommand.com/iCodeBlogHelper/Tutorial3/iCodeBlogImageXMLB.xml"]];</pre>
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/06/19/using-nsxmlparser-to-pull-uiimages-from-the-web/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Custom UITableViewCell Using Interface Builder</title>
		<link>http://icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/</link>
		<comments>http://icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/#comments</comments>
		<pubDate>Mon, 25 May 2009 03:27:36 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[iPhone Articles]]></category>
		<category><![CDATA[iPhone Programming Tutorials]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[uitableview]]></category>
		<category><![CDATA[UITableViewCell]]></category>

		<guid isPermaLink="false">http://icodeblog.com/?p=752</guid>
		<description><![CDATA[<a href="/2009/05/24/custom-uitableviewcell-using-interface-builder/"><img align="left" hspace="5" width="150" height="150" src="/wp-content/uploads/2009/05/picture-1-150x150.png" class="alignleft wp-post-image tfe" alt="picture-1" title="" /></a>Hey everyone, welcome to my first of many screencasts coming in the next few weeks. Today I am going to show you how to layout a UITableViewCell in Interface Builder and have a UITableView populate with those type of cells. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ficodeblog.com%2F2009%2F05%2F24%2Fcustom-uitableviewcell-using-interface-builder%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ficodeblog.com%2F2009%2F05%2F24%2Fcustom-uitableviewcell-using-interface-builder%2F&amp;source=elctech&amp;style=normal&amp;hashtags=uitableview,UITableViewCell" height="61" width="50" /><br />
			</a>
		</div>
<p>Hey everyone, welcome to my first of many screencasts coming in the next few weeks. Today I am going to show you how to layout a UITableViewCell in Interface Builder and have a UITableView populate with those type of cells. I am adopting a new structure for my screencasts which will be 5 or so mintues of keynote slides giving background info followed by 20 &#8211; 25 mintues of step by step development. The entire video will be directly below this paragraph, but scrolling down you will see a text based step by step of the whole tutorial as well. Hope you guys enjoy.</p>
<h2><span style="color: #000000;">Skill Level</span> <span style="color: #ff6600;">MEDIUM</span></h2>
<p>Here is a link to the screencast to watch. We are working on getting an embedded version in, but I figure this is basically just as functional. Have fun!</p>
<h2><a href="http://eu-video-cloud.s3.amazonaws.com/available/114103480/asset-61/encoded_hidef.mp4">Custom UITableViewCell Screencast Video</a></h2>
<h1><span style="color: #ff6600;">Source Code<br />
</span></h1>
<h3><a title="Custom UITableViewCell's Using Interface Builder" href="http://losectrl-gaincommand.com/iCodeBlogHelper/Tutorial1/CustomUITableViewCell.zip"><span style="text-decoration: underline;">Available Here</span></a></h3>
<h2><span style="color: #008080;">Background Information</span></h2>
<p><img class="aligncenter size-full wp-image-814" src="/wp-content/uploads/2009/05/picture-1.png" alt="picture-1" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-815" src="/wp-content/uploads/2009/05/picture-2.png" alt="picture-2" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-816" src="/wp-content/uploads/2009/05/picture-3.png" alt="picture-3" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-817" src="/wp-content/uploads/2009/05/picture-4.png" alt="picture-4" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-818" src="/wp-content/uploads/2009/05/picture-5.png" alt="picture-5" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-819" src="/wp-content/uploads/2009/05/picture-6.png" alt="picture-6" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-820" src="/wp-content/uploads/2009/05/picture-7.png" alt="picture-7" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-821" src="/wp-content/uploads/2009/05/picture-8.png" alt="picture-8" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-822" src="/wp-content/uploads/2009/05/picture-9.png" alt="picture-9" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-823" src="/wp-content/uploads/2009/05/picture-10.png" alt="picture-10" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-824" src="/wp-content/uploads/2009/05/picture-11.png" alt="picture-11" width="622" height="388" /></p>
<h2><span style="color: #008080;">Building The App</span></h2>
<h3><span style="color: #008080;"><span style="color: #993300;">Step 1</span></span></h3>
<p><img class="aligncenter size-full wp-image-825" src="/wp-content/uploads/2009/05/picture-12.png" alt="picture-12" width="622" height="388" /></p>
<p style="padding-left: 60px;"><span style="color: #008080;"><span style="color: #993300;"><span style="color: #000000;">This step shouldn&#8217;t require any extra information.</span></span></span></p>
<h3><span style="color: #008080;"><span style="color: #993300;">Step 2</span></span></h3>
<p><img class="aligncenter size-full wp-image-826" src="/wp-content/uploads/2009/05/picture-13.png" alt="picture-13" width="622" height="388" /></p>
<p><img class="aligncenter size-full wp-image-836" src="/wp-content/uploads/2009/05/datasourceconnection.png" alt="datasourceconnection" width="622" height="377" /></p>
<h3><span style="color: #008080;"><span style="color: #993300;">Step 3</span></span></h3>
<p><img class="aligncenter size-full wp-image-827" src="/wp-content/uploads/2009/05/picture-14.png" alt="picture-14" width="622" height="388" /></p>
<p style="padding-left: 30px;">In CustomTableCellTutorialViewController.m you must define the two required UITableViewDataSource methods. These methods will fill up the table view with data. For now we will put in dummy data just to make sure all of our connections are working.</p>
<p style="padding-left: 30px;">- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section</p>
<p style="padding-left: 30px;">{</p>
<p style="padding-left: 60px;">return 10;</p>
<p style="padding-left: 30px;">}</p>
<p style="padding-left: 30px;">- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</p>
<p style="padding-left: 30px;">{</p>
<p style="padding-left: 60px;">static NSString *CellIdentifier = @&#8221;Cell&#8221;;</p>
<p style="padding-left: 60px;">UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];</p>
<p style="padding-left: 60px;">if (cell == nil){</p>
<p style="padding-left: 90px;">cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];</p>
<p style="padding-left: 60px;">}</p>
<p style="padding-left: 60px;">[cell setText:[NSString stringWithFormat:@"I am cell %d", indexPath.row]];</p>
<p style="padding-left: 60px;">return cell;</p>
<p style="padding-left: 30px;">}</p>
<h3><span style="color: #008080;"><span style="color: #993300;">Step 4</span></span></h3>
<p><img class="aligncenter size-full wp-image-828" src="/wp-content/uploads/2009/05/picture-15.png" alt="picture-15" width="622" height="388" /></p>
<p style="padding-left: 30px;">Here you will need to be in xCode and go to File -&gt; New File&#8230;</p>
<p style="padding-left: 30px;">Select Objective C Class and make sure it is a UITableViewCell subclass, depending on your version of the SDK selecting this will differ. Look around and you will find it, call it iCodeBlogCustomCell. With this done enter these IBOutlets in the iCodeBlogCustomCell.h file enter the following IBOutlets:</p>
<p style="padding-left: 30px;">IBOutlet UILabel *articleName;<br />
IBOutlet UILabel *authorName;<br />
IBOutlet UILabel *date;</p>
<p>IBOutlet UIImageView *imageView;<br />
IBOutlet UIView *viewForBackground;</p>
<p style="padding-left: 30px;">Add the @property and synthesize them in the main.</p>
<h3><span style="color: #008080;"><span style="color: #993300;">Step 5</span></span></h3>
<p><img class="aligncenter size-full wp-image-829" src="/wp-content/uploads/2009/05/picture-16.png" alt="picture-16" width="622" height="388" /></p>
<p style="padding-left: 30px;">This step does not require and code but does require a lot of work in Interface Builder. I highly recommend you watch the screencast to see the step by step procedure here. Essentially what I do is create a new View XIB file. Opening this, I delete the standard UIView in the XIB and drag a UITableViewCell from my library into my document window. I assign the UITableViewCell to be of type iCodeBlogCustomCell. With this done layout the interface with the proper elements and hook them up by right clicking on the UITableViewCell in the document window.</p>
<h3><span style="color: #008080;"><span style="color: #993300;">Step 6<br />
</span></span></h3>
<p><img class="aligncenter size-full wp-image-830" src="/wp-content/uploads/2009/05/picture-17.png" alt="picture-17" width="622" height="388" /></p>
<p style="padding-left: 30px;">This is where the real magic is. We are going to return to CustomTableCellTutorialViewController.m and edit the UITableViewDataSource methods we implemented earlier. The code I use has me putting in 4 separate PNG files that I add to my project. You can find your own to put inside the cells. Make sure the UIImageView inside the cell is set for Aspect Fit so you don&#8217;t have to worry about resizing the images.  The functions should be changed to be:</p>
<p style="padding-left: 30px;">- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section<br />
{<br />
return 100;<br />
}</p>
<p style="padding-left: 30px;">- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath<br />
{<br />
static NSString *CellIdentifier = @&#8221;iCodeBlogCustomCell&#8221;;</p>
<p style="padding-left: 60px;">iCodeBlogCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];</p>
<p style="padding-left: 60px;">if (cell == nil){<br />
NSLog(@&#8221;New Cell Made&#8221;);</p>
<p style="padding-left: 60px;">NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@&#8221;iCodeBlogCustomCell&#8221; owner:nil options:nil];</p>
<p style="padding-left: 60px;">for(id currentObject in topLevelObjects)<br />
{<br />
if([currentObject isKindOfClass:[iCodeBlogCustomCell class]])<br />
{<br />
cell = (iCodeBlogCustomCell *)currentObject;<br />
break;<br />
}<br />
}<br />
}</p>
<p style="padding-left: 60px;">
<p style="padding-left: 60px;">if(indexPath.row % 4 == 0)<br />
{<br />
[[cell authorName] setText:@&#8221;Collin Ruffenach&#8221;];<br />
[[cell articleName] setText:@&#8221;Test Article 1&#8243;];<br />
[[cell date] setText:@&#8221;May 5th, 2009&#8243;];<br />
[[cell imageView] setImage:[UIImage imageNamed:@"1.png"]];<br />
}</p>
<p style="padding-left: 60px;">else if(indexPath.row % 4 == 1)<br />
{<br />
[[cell authorName] setText:@&#8221;Steve Jobs&#8221;];<br />
[[cell articleName] setText:@&#8221;Why iPhone will rule the world&#8221;];<br />
[[cell date] setText:@&#8221;May 5th, 2010&#8243;];<br />
[[cell imageView] setImage:[UIImage imageNamed:@"2.png"]];<br />
}</p>
<p style="padding-left: 60px;">else if(indexPath.row % 4 == 2)<br />
{<br />
[[cell authorName] setText:@&#8221;The Woz&#8221;];<br />
[[cell articleName] setText:@&#8221;Why I&#8217;m coming back to Apple&#8221;];<br />
[[cell date] setText:@&#8221;May 5th, 2012&#8243;];<br />
[[cell imageView] setImage:[UIImage imageNamed:@"3.png"]];<br />
}</p>
<p style="padding-left: 60px;">else if(indexPath.row % 4 == 3)</p>
<p style="padding-left: 60px;">{<br />
[[cell authorName] setText:@&#8221;Aaron Hillegass&#8221;];<br />
[[cell articleName] setText:@&#8221;Cocoa: A Brief Introduction&#8221;];<br />
[[cell date] setText:@&#8221;May 5th, 2004&#8243;];<br />
[[cell imageView] setImage:[UIImage imageNamed:@"4.png"]];</p>
<p style="padding-left: 60px;">}</p>
<p style="padding-left: 30px;">return cell;<br />
}</p>
<h3><span style="color: #008080;"><span style="color: #993300;">The End</span></span></h3>
<p style="padding-left: 30px;">So that is it for my first new post. I will be doing many more. Let me know your thoughts on this format in the comments. If you see anything organization wise that you think should be changed/add/removed let me know. Good Luck!</p>
<p style="padding-left: 30px;">
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2009/05/24/custom-uitableviewcell-using-interface-builder/feed/</wfw:commentRss>
		<slash:comments>79</slash:comments>
		</item>
		<item>
		<title>Finding Substrings in Objective-C</title>
		<link>http://icodeblog.com/2008/11/03/finding-substrings-in-objective-c/</link>
		<comments>http://icodeblog.com/2008/11/03/finding-substrings-in-objective-c/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 05:57:00 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://icodeblog.com/2008/11/03/finding-substrings-in-objective-c/</guid>
		<description><![CDATA[<a href="/2008/11/03/finding-substrings-in-objective-c/"><img align="left" hspace="5" width="150" height="150" src="/wp-content/plugins/thumbnail-for-excerpts/tfe_no_thumb.png" class="alignleft wp-post-image tfe" alt="" title="" /></a>It&#8217;s times like this, that I miss ruby. I&#8217;m checking a url to see if it has a substring. It would be so easy if this was ruby: absolute_url.match(/my regex/).any? In Objective C, you have to use rangeOfString which returns [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ficodeblog.com%2F2008%2F11%2F03%2Ffinding-substrings-in-objective-c%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ficodeblog.com%2F2008%2F11%2F03%2Ffinding-substrings-in-objective-c%2F&amp;source=elctech&amp;style=normal&amp;hashtags=%23iphonedev" height="61" width="50" /><br />
			</a>
		</div>
<p>It&#8217;s times like this, that I miss ruby.</p>
<p>I&#8217;m checking a url to see if it has a substring.  It would be so easy if this was ruby:
<pre>absolute_url.match(/my regex/).any?</pre>
<p>In Objective C, you have to use rangeOfString which returns a range.  If I were to run this on the string <span style="font-style: italic;">&#8220;the quick brown fox&#8221;</span> with an argument of <span style="font-style: italic;">&#8220;brown&#8221;</span> it would return <span style="font-style: italic;">{10,14}</span>.  If it&#8217;s not found, it would return <span style="font-style: italic;">{NSNotFound, 0}</span>.  Let&#8217;s use that to check to see if the range was found.  We&#8217;ll use <span style="font-style: italic;">NSMakeRange</span> to create the <span style="font-style: italic;">NSNotFound</span> range and <span style="font-style: italic;">NSEqualRanges</span> to compare them:
<pre>if(NSEqualRanges(NSMakeRange(NSNotFound, 0), [absoluteURL rangeOfString:@"my_substring"])){   NSLog(@"my_substring not found in absoluteURL %@", absoluteURL);}</pre>
]]></content:encoded>
			<wfw:commentRss>http://icodeblog.com/2008/11/03/finding-substrings-in-objective-c/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
