<?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>iDevKit &#187; Xcode</title>
	<atom:link href="http://idevkit.com/iphonedev/tag/xcode/feed/" rel="self" type="application/rss+xml" />
	<link>http://idevkit.com/iphonedev</link>
	<description>An iPhone Developer&#039;s Blog</description>
	<lastBuildDate>Sat, 24 Apr 2010 17:47:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Xcode and the iPhone SDK</title>
		<link>http://idevkit.com/iphonedev/2009/09/xcode-and-the-iphone-sdk/</link>
		<comments>http://idevkit.com/iphonedev/2009/09/xcode-and-the-iphone-sdk/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 02:55:58 +0000</pubDate>
		<dc:creator>sj</dc:creator>
				<category><![CDATA[Xcode]]></category>
		<category><![CDATA[iPhone SDK (Official Dev)]]></category>
		<category><![CDATA[intro]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://idevkit.com/iphonedev/?p=8</guid>
		<description><![CDATA[Alright everyone, for the first tutorial on iDevKit, I though we should start somewhere relatively basic, and seeing as how this blog is going to be covering everything from Archiving to OpenGL, Quartz to GameKit, and CoreLocation to Cocoa Touch, I thought it would be best to start somewhere simple.  That is why this post [...]]]></description>
			<content:encoded><![CDATA[<p>Alright everyone, for the first tutorial on iDevKit, I though we should start somewhere relatively basic, and seeing as how this blog is going to be covering everything from Archiving to OpenGL, Quartz to GameKit, and CoreLocation to Cocoa Touch, I thought it would be best to start somewhere simple.  That is why this post will cover the hows and whys of Xcode, the IDE for the iPhone and Mac OS X, and make your very own &#8220;Hello World&#8221; using Objective-C.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-60" title="Xcode Logo" src="http://idevkit.com/iphonedev/wp-content/uploads/2009/09/xcode-logo.png" alt="Xcode Logo" width="125" height="125" /></p>
<p>To start with, you will need the iPhone SDK (Xcode), available <a title="Apple Developer Connection" href="http://developer.apple.com/iphone/index.action" target="_blank">here</a>. Download the latest version, which is currently 3.0 for unregistered users, and 3.1 beta3 for certified developers (To become a certified developer, you have to <a title="iPhone Developer Enrollment" href="http://developer.apple.com/iphone/program/start/register/" target="_blank">enroll</a> with the Apple Developer Connection&#8217;s iPhone program. I will cover some hurdles related to this in a later post).  After you have downloaded the SDK, mount the dmg file and install. (This part is fairly straight forward)</p>
<p>After you have installed the iPhone SDK, open Xcode and select <strong>File -&gt; New Project</strong>.</p>
<div id="attachment_24" class="wp-caption alignnone" style="width: 310px"><img class="size-medium wp-image-24" title="Xcode Intro-1.1" src="http://idevkit.com/iphonedev/wp-content/uploads/2009/09/Xcode-Intro-1.1-300x247.png" alt="Project Types" width="300" height="247" /><p class="wp-caption-text">Project Types</p></div>
<div id="attachment_25" class="wp-caption alignnone" style="width: 310px"><img class="size-medium wp-image-25" title="Xcode Intro-1.2" src="http://idevkit.com/iphonedev/wp-content/uploads/2009/09/Xcode-Intro-1.2-300x99.png" alt="File Name" width="300" height="99" /><p class="wp-caption-text">File Name</p></div>
<p>When you&#8217;re there, you will be prompted with an array of options and templates to choose from for both Mac OS X and iPhone OS.  You will see six different options, but for this particular example, we will only concern ourselves with &#8220;View-Based Application&#8221;.  Select <strong>View-based Application</strong> and click <strong>Choose. . .</strong>, name your project &#8220;Hello World&#8221;, and a new window will then open, containing your application template.</p>
<div id="attachment_23" class="wp-caption alignnone" style="width: 310px"><img class="size-medium wp-image-23" title="Xcode Intro-1.3" src="http://idevkit.com/iphonedev/wp-content/uploads/2009/09/Xcode-Intro-1.3-300x207.png" alt="New Project in Xcode" width="300" height="207" /><p class="wp-caption-text">New Project in Xcode</p></div>
<p>Here, you&#8217;re going to see many different file references and directories.  I&#8217;ll quickly go over what&#8217;s important:</p>
<p><strong>Classes</strong> &#8211; In here you will find your application delegate and root view controller, with appropriate headers.</p>
<p><strong>Other Sources</strong> &#8211; This contains the .pch (project header) that imports UIKit and Foundation Frameworks, along with the main.m file.</p>
<p><strong>Resources</strong> &#8211; As of now, this contains the XIB files (for Interface Builder), and the HelloWorld-Info.plist. XIBs are static files used to create UIViewControllers. The Info plist contains the core settings of your application like icon location, opening orientation, Bundle Names, Identifiers, etc. Much of this is used by Apple when releasing your application on App Store via iTunesConnect (much on this &#8220;fun&#8221; process later)</p>
<p><strong>Frameworks</strong> &#8211; This contains references to dynamic frameworks, including UIKit, Foundation, and CoreGraphics, with many more available on your system from the SDK.  This is also where static frameworks are stored, these frameworks are compiled into your application vs being linked to a dynamic framework present on the device.</p>
<p><strong>Products</strong> &#8211; This contains the executable .app that you get after compilation.</p>
<p>Everything else listed here is either organization, compiling information, or other components that we will worry about in the future.</p>
<p>For now, we are going to concern ourselves with the <strong>Classes</strong> section only.  We will be using an NSString to store text, a UILabel to display the string of text, and colored background.  So let us begin by editing the HelloWorldAppDelegate.m, insert the following line of code at the start of the applicationDidFinishLaunching: method:</p>
<p><code>[window setBackgroundColor:[UIColor blueColor]];</code></p>
<p>This will make the background of your application blue as opposed to the boring default white.  There is a host of preset colors in the UIColor API, along with methods that let you create your own by setting the RGB properties.</p>
<p>Now go to your HelloWorldViewController.m file and navigate to the loadView method and uncomment it.  This method will contain the code that loads your UILabel, NSString, and UIView.  Insert the following:</p>
<p><code>CGRect appFrame = [UIScreen mainScreen].applicationFrame;<br />
UIView *view = [[UIView alloc] initWithFrame:appFrame];<br />
self.view = view;</code></p>
<p>Okay, let me explain: <code>appframe</code> is essentially just a rectangle the size of your device screen (320px by 480px), which is used by <code>view</code> to set the frame it is built around.  <code>view</code> then becomes the layer that the rest of the ViewController uses to display other &#8220;subviews&#8221; (like UIImageView, UILabel, UIButton etc).  Now we are going to add our NSString (the object that will contain our text for the UILabel).  Below what we just added, type the following:</p>
<p><code>NSString *hello_text = [NSString stringWithFormat:@"Hello, World!"];</code></p>
<p>This line creates and initializes the object <code>hello_text</code> with the text that we will be using next.  Now type below this:</p>
<p><code>UILabel *hello_label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,200,30)];<br />
[hello_label setFont:[UIFont fontWithName:@"Arial" size:30]];<br />
[hello_label setCenter:CGPointMake(160,100)];<br />
[hello_label setText:hello_text];<br />
[hello_label setTextColor:[UIColor redColor]];<br />
[hello_label setBackgroundColor:[UIColor clearColor]];</code></p>
<p>Alright, there&#8217;s a lot here so lets break it down, starting with the first line.  This line basically allocates memory for <code>hello_label</code> and creates a CGRect for whatever we place inside of it.  Next, we set the UIFont properties for the label (for a list of available fonts, look at the end of the post) including the font itself (Arial) and the size (in px) of it (30).  After that, we position hello_label&#8217;s center point so that it won&#8217;t appear at the default (0,0), but instead at our own custom position (160,100) (this is 160 px from the left, and 100 px from the top; think cartesian plain, quadrant IV).  We then set the string that we want to display, in this case we are using the contents of <code>hello_text</code>, this is done by just using the <code>setText:</code> property.  After that, all we are doing is setting the color of the text and the background of the frame using UIColor again.  Notice something weird about the background color?  Instead of setting a visible color, we use a <code>clearColor</code>, which is essentially just transparency.  All that is left to do now is add the UILabel to our view and we can call it a day.</p>
<p><code>[self.view addSubview:hello_label];</code></p>
<p>This takes the object that we defined, and adds it to the superview.  Build &amp; Go.</p>
<div id="attachment_21" class="wp-caption alignnone" style="width: 169px"><img class="size-medium wp-image-21" title="Xcode Intro-1.4" src="http://idevkit.com/iphonedev/wp-content/uploads/2009/09/Xcode-Intro-1.4-159x300.png" alt="Output" width="159" height="300" /><p class="wp-caption-text">Output</p></div>
<p>That is about it for now, Download the Hello World application used in this tutorial here: <a href="http://idevkit.com/iphonedev/wp-content/uploads/2009/09/iDK-HelloWorld.zip">HelloWorld</a></p>
<p>Regards,<br />
sj</p>
<p>Below is a console log of all the fonts and font families from <a title="Dave Mitchell's Blog" href="http://blog.lightvoid.net/2008/11/02/iphone-uifont-list/" target="_blank">Dave Mitchell</a></p>
<blockquote><p>Font Family: American Typewriter<br />
Font: AmericanTypewriter<br />
Font: AmericanTypewriter-Bold</p>
<p>Font Family: AppleGothic<br />
Font: AppleGothic</p>
<p>Font Family: Arial<br />
Font: ArialMT<br />
Font: Arial-BoldMT<br />
Font: Arial-BoldItalicMT<br />
Font: Arial-ItalicMT</p>
<p>Font Family: Arial Rounded MT Bold<br />
Font: ArialRoundedMTBold</p>
<p>Font Family: Arial Unicode MS<br />
Font: ArialUnicodeMS</p>
<p>Font Family: Courier<br />
Font: Courier<br />
Font: Courier-BoldOblique<br />
Font: Courier-Oblique<br />
Font: Courier-Bold</p>
<p>Font Family: Courier New<br />
Font: CourierNewPS-BoldMT<br />
Font: CourierNewPS-ItalicMT<br />
Font: CourierNewPS-BoldItalicMT<br />
Font: CourierNewPSMT</p>
<p>Font Family: DB LCD Temp<br />
Font: DBLCDTempBlack</p>
<p>Font Family: Georgia<br />
Font: Georgia-Bold<br />
Font: Georgia<br />
Font: Georgia-BoldItalic<br />
Font: Georgia-Italic</p>
<p>Font Family: Helvetica<br />
Font: Helvetica-Oblique<br />
Font: Helvetica-BoldOblique<br />
Font: Helvetica<br />
Font: Helvetica-Bold</p>
<p>Font Family: Helvetica Neue<br />
Font: HelveticaNeue<br />
Font: HelveticaNeue-Bold</p>
<p>Font Family: Hiragino Kaku Gothic **** W3<br />
Font: HiraKakuProN-W3</p>
<p>Font Family: Hiragino Kaku Gothic **** W6<br />
Font: HiraKakuProN-W6</p>
<p>Font Family: Marker Felt<br />
Font: MarkerFelt-Thin</p>
<p>Font Family: STHeiti J<br />
Font: STHeitiJ-Medium<br />
Font: STHeitiJ-Light</p>
<p>Font Family: STHeiti K<br />
Font: STHeitiK-Medium<br />
Font: STHeitiK-Light</p>
<p>Font Family: STHeiti SC<br />
Font: STHeitiSC-Medium<br />
Font: STHeitiSC-Light</p>
<p>Font Family: STHeiti TC<br />
Font: STHeitiTC-Light<br />
Font: STHeitiTC-Medium</p>
<p>Font Family: Times New Roman<br />
Font: TimesNewRomanPSMT<br />
Font: TimesNewRomanPS-BoldMT<br />
Font: TimesNewRomanPS-BoldItalicMT<br />
Font: TimesNewRomanPS-ItalicMT</p>
<p>Font Family: Trebuchet MS<br />
Font: TrebuchetMS-Italic<br />
Font: TrebuchetMS<br />
Font: Trebuchet-BoldItalic<br />
Font: TrebuchetMS-Bold</p>
<p>Font Family: Verdana<br />
Font: Verdana-Bold<br />
Font: Verdana-BoldItalic<br />
Font: Verdana<br />
Font: Verdana-Italic</p>
<p>Font Family: Zapfino<br />
Font: Zapfino</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://idevkit.com/iphonedev/2009/09/xcode-and-the-iphone-sdk/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
