Step 6: Have some fun by adding things programmatically

To make it a little more advanced, we are going to add everything programmatically.

1. Delete the label we added to the UI as well as all the code we wrote up to this point.

2. Open ViewController.h and add the Following code between the @interface ViewController: UIViewController and @end:
@property (strong, nonatomic)UILabel *label;
Notice how a circle did not appear this time? That's an indication that you did it correctly

3. In ViewController.m add @synthesize label; right beneath @implementation ViewController and add [self setLabel:nil]; in the viewDidUnload function.

4. In the viewDidLoad function add the following lines of code:
//Define where the label will be displayed
self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
//Define the text to be displayed
self.label.text = @"Hello World";
//Center the Text
self.label.textAlignment = UITextAlignmentCenter;
//Programmatically add the label to the view
[self.view addSubview:self.label];

5. Hit run and admire your handiwork, you've completed your first iOS application
<p>Good for new developers but It is very easy to develop iOS apps by using new language by Apple called &quot;Swift&quot;. It have many builtin features that you can use in your application.</p><br>Domain Age Checker
<p>I am a beginner in iOS app development.This article is very helpful to me.Thanks for sharing this.</p><p>http://www.atees.in/</p>
<p>So you cant get the program on anything but a mac... u cant even get it on a ipad...etc</p>
<p>This was the best step by step tutorial for learning of how to start building iOS apps. I hope it makes more easy for developing first iOS app.</p><p>http://www.mobilepundits.com/</p>
<p>Wow this is amazing tutorial for learners like me. I also found another website to create your own app. They have different options to create your own app. Click <a href="http://ow.ly/V0FKY" rel="nofollow">here</a> to see in action.</p>
<p>This is Very Good Tutorial for iOS <a href="http://www.prateektechnosoft.com/Web-Application-Development-Services.php" rel="nofollow" title="Mobile Application Development">Mobile Application Development</a> Ideas.. Useful for Me Thanks..</p>
Would be great if you could include how to get the app onto your device. Thanks for the instructable.
<p>guys, the reason they don't allow you to put apps on your phone is because, then you could put them on any iPhone. this would circumvent the app store. the whole point of the app store is that the only way to get an app on an iPhone is after it has been tested by apple to make sure it works and does what it says it will. it's quality control. ultimately, it's about making sure everything on an iOS device &quot;just works&quot;. i for one fully support a business model that allows them to make money while ensuring a quality product. it's the one thing that sets apple products apart. it makes them more expensive, yes, but it's worth it to many people.</p>
Unfortunately (and I learned this the hard way), you need to be a part of the paid developer program (US $100/year) in order to put the app on your device.
For your own device, connected with your iTunes, you don't need to be in the developer program - just connect the device for sync. <br>But if you want your app in the AppStore, you need to be in the program. <br>best regards <br>Martin
Is it jailbroken?
I had to join the program to put it on my device, but if you'd post an 'ible on how to do that, I'd love to be proven wrong.
<p>Today its simple to create an <a href="http://www.technoduce.com/iphone-application-development" rel="nofollow">iphone application development</a>, download and install X code. Also install a good text editor. Along with it install a vector graphics program. You have be familier with objective C. Create a development account and download some test apps. </p>
<p>As an iOS app developer, I suggest you to develop apps with mobile app development platforms. It will save your lots of time as well as you will get plenty of handy features.</p><p>I generally use Configure.IT because it provides good features compared to other platforms such as automatic coding, App preview facility, .PSD file export for UI design and many more. You can view the detailed list here:</p><p><a href="http://www.configure.it/features/mobile-app-configuration/" rel="nofollow">http://www.configure.it/features/mobile-app-configuration/</a></p>
<p>This is Very Helpful Information.. I am very Happy to read this post.. I want to join Iphone Developer. This is very Helpful for me. Thanks</p><p><a href="http://www.hospity.com" rel="nofollow" title="Hospital Management System">Hospital Management System</a> , <a href="http://www.invity.com" rel="nofollow" title="Wedding Websites">Wedding Websites</a></p>
<p>Does this mean I can build my own App for my iPhone? How wonderful!</p>
<p>Nice!!! It really helps me..I really admire your post.. Checking the worth of the website.. <a href="http://www.appschopper.com/iphone-apps-development.shtml" rel="nofollow">http://www.appschopper.com/iphone-apps-development.shtml</a></p>
<p>we are ready to help to create your first iOS app. if you need any help, please visit www.taoteapps.com &amp; learn more.</p>
Hi,<br> <br> <br> Thanks for sharing this <a href="http://www.quadrupleindia.com/mobile-application-development.php" rel="nofollow">app for iphone development</a>, Iam going to try build a new app.<br> <br> <br> Thanks,<br> Andrew
Hi, <br> <br> I am a <a href="http://www.evincetech.com/" rel="nofollow" title="iphone Developer">iphone Developer</a>,with 1month exp, this Tutorial is very helpful for me,thanks for sharing this
It's a really nice post, the way you tell how to create first iOS app is just amazing. Thanks for sharing. Checking the worth of the website: <a href="http://www.emailchopper.com" rel="nofollow">http://www.emailchopper.com</a>
I am an iPhone developer and according to me It's a really nice post..It will definitely helps all the iPhone developers. Checking the worth of the website: <a href="http://www.appschopper.com" rel="nofollow">http://www.appschopper.com</a>
@A-Nony-Mus Many thanks to you....I started to create my app using the steps provided by you here, it worked out well and I am happy coding my iPhone app using XCode <a href="http://www.contus.com/iphone-application-development.php" rel="nofollow">iPhone apps development</a> tool, Sweb also helped me a lot.&nbsp; Would like to know how to test once I wind up my app? Please help me out!&nbsp; few apps.<br> <br> Recently did research on <a href="http://www.techbuzzonline.com/create-simple-iphone-web-app/" rel="nofollow">how to make iPhone apps </a>and posted! Please find the below link<br> <br> <br>
I hate apples power-based monopoly. You shouldn't have to use a Mac just to legally use their dev software
Thanks for the simple introduction to iOS app development.<br> <br> FWIW, an alternate approach to the proposed substitution above would be to add another label.<br> <br> Since I'm using iOS 6, UITextAlignmentCenter is deprecated; a post on StackOverflow (<a href="http://stackoverflow.com/questions/12792999/what-are-good-alternatives-to-uitextalignmentcenter-in-ios-6" rel="nofollow">http://stackoverflow.com/questions/12792999/what-are-good-alternatives-to-uitextalignmentcenter-in-ios-6</a>) suggested using NSTextAlignmentCenter instead ... and for backward compatibility, to use the following:<br> <br> #ifdef __IPHONE_6_0<br> # define ALIGN_CENTER NSTextAlignmentCenter<br> #else<br> # define ALIGN_CENTER UITextAlignmentCenter<br> #endif<br> <br> I added the following line to ViewController.h (below the @property declaration for label):<br> <br> @property (strong, nonatomic)UILabel *label2;<br> <br> and added the following line in ViewController.m (below the @synthesize label; line):<br> <br> @synthesize label2;<br> <br> After adding the preprocessor macro proposed in the StackOverflow, and using the code provided above (substituting &quot;label2&quot; for &quot;label&quot; in the added statements), my viewDidLoad method appears as follows:<br> <br> <br> - (void)viewDidLoad<br> {<br> &nbsp;&nbsp;&nbsp; [super viewDidLoad];<br> <br> &nbsp;&nbsp;&nbsp; // from before:<br> &nbsp;&nbsp;&nbsp; self.label.text = @&quot;Hello World!&quot;;<br> <br> &nbsp;&nbsp;&nbsp; // using a Y coordinate of 200 instead of 0 for label2<br> &nbsp;&nbsp;&nbsp; self.label2 = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, 320, 100)];<br> &nbsp;&nbsp;&nbsp; self.label2.text = @&quot;Goodbye&quot;;<br> &nbsp;&nbsp;&nbsp; self.label2.textAlignment = ALIGN_CENTER;<br> &nbsp;&nbsp;&nbsp; [self.view addSubview:self.label2];<br> }
Note that the second part of Step 4 is no longer necessary (or supported). <br> <br>viewDidUnload <br>Called when the controller&rsquo;s view is released from memory. (Deprecated in iOS 6.0. Views are no longer purged under low-memory conditions and so this method is never called.)
Great tutorial. But, when I click run, the iOS Simulator screen comes up with a white screen, no label. I've followed your directions except for not using the viewDidUnload function, as it's deprecated in iOS 6.1. Any ideas? Thanks!
I work on a MBP, so I only have 15 inches of screen size. Ever since apple announced the new iPhone screen size, I have to scroll up and down, like I would with a page, if I want to see the entire app.
Um just wondering but what programming language did you use in this tutorial? Thanks
It was written in objective-c, an object oriented version of c.
Thanks for pointing this out! I know that I am interested in <a href="http://www.intuitivepear.com/mobile-application-development" rel="nofollow">mobile app development</a>, and am always looking to read and learn more about it.
I did the&nbsp; <strong>Hello World !&nbsp; </strong><br> Now, can I mess with the RF output to unlock my car, Only My Car.<br> I don't want to sell or provide the Xcode to anyone.<br> Is this possible ??<br> <br> A
Why anyone in the 21st century would use something proprietary is beyond me especially intelligent people that have the power to change the world. In any event I doubt many Linux users have an iphone but Antirez Blog has opensource for it http://antirez.com/page/iphone-gcc-guide.html <br> <br>Or you could use Eclipse which is also open source and rated higher than Mac and Microsoft software you have to buy http://alternativeto.net/software/eclipse/
I am a Linux user and an android user and an Iphone user. They are for different things. I'm a fiddler so Linux and android are great but my wife wants things that work first time and that&acirc;€™s where apple comes in. Like so many things Apples strengths are its weakness. I'm forever downloading apps on the android market that freeze or simply just don't work as there's very little control but I haven't seen an Apple app (no doubt they exist) that didn't do what it said straight out of the tin with no messing. So like I said apple no good for me as I don't mind fiddling and actually like it but perfect for the wife. Would anyone learning how to write Hello world for the first time really fork out $100 just to test if it works? If you&acirc;€™re not going to put your new app on a device then I&acirc;€™m not really sure what the point is. I think if Apple just allowed you to put it on your own device but couldn&acirc;€™t go any further then this may encourage folk like me that have been programming for years and wouldn&acirc;€™t mind a crack at the IOS stuff but I aint gonna pay $100 for the privilege.
If you have a jailbroken ipod you can put it onto your own device easily. Or you should develop your apps on android instead, that way you can have it on your own device for free, and if/when it works you could pay the $25 to put it on the market.
Maybe because they: <br>1) want something that works. <br>2) want something that wasn't blatantly stolen because of misplaced trust <br>3) want something that enough people actually use that they can make a living <br>4) want something that doesn't require multiple versions and rewrites to support all possible devices in a fragmented ecosystem <br>5) realize that there is a significant amount of proprietary code running on Android as well. <br> <br>And BTW, the fact that you have to root just about all Android devices to update to the current OS, and even then stand a good chance of bricking your device unless you know exactly what you are doing, and/or have specially written tools, puts the lie to your implied claims of &quot;proprietary-free&quot;
Huh? <br><br>Statistically speaking everything works better than Apple products and if nothing else it is repairable not disposable as with mac. <br><br>PC and Tablet are hardware not a brand as there are many manufactures and many OS for them, not just one flavor like Mac. <br><br>Americans screaming about Communism, Fascism, crimes against humanity, sweat shops, global warming, jobs going overseas .... have a look at Apple!<br><br>Nothing has been stolen from anyone, Apple is the one doing the stealing which is about to back fire in Asia, not to mention the name iphone and ipad are also stolen however they did pay off the Chinese for &quot;ipad&quot;. The USA is the biggest market for apple and compared to the rest of the world that is about 5%. <br><br>I'm a Linux user so.... I know the Mach Kernel was taken from a failed Linux project that was scrapped and used to build Mac OS X so your fanboy stuff won't wok with me nor does it annoy me because I know the truth.<br><br>&quot;We have always been shameless about stealing great ideas&quot; &mdash; Steve Jobs<br><br>Yep, and you did a lot of stealing and now it is going to catch up with you and the iphone 5 will be trashed because the courts will not allow it to go on the market because of the stolen G4 tech from Samsung who you had the nerve to go after for something you actually stole from Mitsubishi.<br><br><br>Anyway the facts are plain to see I don't need to have this debate because it is like teaching science to a creationist. <br><br>You totally missed my point anyway.
Wow. Talk abut misinformed. Let's make a list, shall we, of all the factually inaccurate, or unsupportable statements in your post: <br>1) &quot;Statistically speaking everything works better than Apple products and if nothing else it is repairable not disposable as with mac. &quot; <br>What statistic would that be? Certainly not customer satisfaction, where Apple scores higher than ANY other company (including every company, not just computer companies) looked at. <br> <br>2) How on earth are you claiming Apple products are not repairable? Perhaps you are arguing based on what you misread online? Maybe the internet meme you are regurgitating that started with iFixit.com's review of the new Retina Display MacBook Pro? Funny, since the entire iFix it site started as a Mac repair guide site. As for actual facts, I repair Macs, hardware and software, on a regular basis. Claiming they are not repairable just means you don't know what you are talking about. <br> <br>*&quot;PC and Tablet are hardware not a brand as there are many manufactures and many OS for them, not just one flavor like Mac.&quot; <br> <br>That isn't even a decipherable English sentence, so I can't have a response. <br> <br>3) &quot;Americans screaming about Communism, Fascism, crimes against humanity, sweat shops, global warming, jobs going overseas .... have a look at Apple!&quot; <br>First, Communism and Fascism are two opposite things, so Apple could not b both. Per se. Period. <br>If you are trying to make a comment about FoxConn, then make it. My guess is you are misinformed there, as well. First, the stories that started that whole business, told by Mike Daisey, were shown to be fabrications and outright lies. Second, Apple is the only major manufacturer that uses FoxConn that demands minimal pay and living standards for the employees working on their lines. Thus, workers that assemble Apple gear are more highly paid, and have better treatment than others at the same plant, that assemble units for Dell, HP, and others. <br> <br>4) Quite a lot was stolen, including trade dress, which is why the courts just fined Samsung 1 BILLION dollars. You may disagree with the verdict, but the court is a higher authority than you. <br> <br>5) Apple did NOT steal the name iPad, it was licensed legally from Proview, who was paid a substantial amount of money for the rights, and now are trying to renege on their deal. Try getting the facts before you post, it'll help you no to look so foolish in retrospect. <br> <br>As to your 5% number you are mixing your facts. Apple's position globally is NOT 5%. That number is the % of sales of Samsung devices in the US that are effected by a possible ban , resulting from the recent court loss. Get your facts straight. <br>Case in point: <br> <br>6) &quot;I'm a Linux user so.... I know the Mach Kernel was taken from a failed Linux project that was scrapped and used to build Mac OS X&quot; <br> <br>You have GOT to be joking!!! If you had bothered to do even 30 seconds of research before you posted that nonsense, you might have saved yourself from looking the fool. <br>Here is some info for you. <br>Mach was developed down the street from me at CMU starting in 1985. It was the basis for NeXTSTEP, which was first shown in 1988. <br>Linus Torvalds did not even start work on Linux until 1991. a full six years LATER. <br>More importantly, Linux is based on a flavour of Unix from Bell Labs known as Sys V Unix. Mach was intended as a kernel replacement for a version of Unix developed ad Berkeley called BSD. These flavours of Unix are TOTALLY different, have different design philosophies, and operate completely differently. As such, there is NO WAY one either could have stemmed from the other. Doing so would have essentially required a complete rewrite, from the ground up. <br>And you speak of truth. <br> <br>7) &quot;the iphone 5 will be trashed because the courts will not allow it to go on the market because of the stolen G4 tech from Samsung who you had the nerve to go after for something you actually stole from Mitsubishi.&quot; <br> <br>Um, what? Where to begin? <br>First, every major analyst is predicting that the iPhone 5 will be huge, some even predicting that it will be the single largest consumer product launch in human history. I suspect they have a bit more information and intelligence that you. <br>Second, the tech in question is 4G related, and I will be willing to bet you that EVERY one of Samsung's patents will be declared FRAND. You do know what that means, right? <br>Third, where on earth are you getting Mitsubishi from? Mitsubishi has nothing to do with any of this. Oh, you mean the stunt Samsung tried to pull bringing up the Diamond Touch and bringing in Adam Bogue ? First, clearly the judge and jury in the case did not see it the same way as you. More importantly, the Mitsubishi Diamond Touch was developed in 2003, and was never even a real product. Pinch to Zoom was developed by the engineers at Apple who previously worked at FingerWorks, who developed the technology in 1998. <br> <br>Prior art what? <br> <br>As for your O.P., I addressed it head on in my original reply. <br> <br>And here are some cites: <br> <br>http://en.wikipedia.org/wiki/Linux <br>http://en.wikipedia.org/wiki/Mach_(kernel) <br>http://en.wikipedia.org/wiki/NeXTSTEP <br>http://www.google.com/url?sa=t&amp;rct=j&amp;q=apple%20customer%20satisfaction&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CCIQFjAA&amp;url=http%3A%2F%2Fnews.cnet.com%2F8301-13579_3-57430768-37%2Fapple-scores-big-bump-in-customer-satisfaction%2F&amp;ei=BuBPUOKJCYe68ATIs4CYCA&amp;usg=AFQjCNHiHgLUyJOn4f8q3Q_eh4HkkgJAZw <br>http://www.google.com/url?sa=t&amp;rct=j&amp;q=apple%20customer%20satisfaction&amp;source=web&amp;cd=2&amp;cad=rja&amp;ved=0CC8QFjAB&amp;url=http%3A%2F%2Fnews.cnet.com%2F8301-13506_3-20108336-17%2Fapple-tops-in-customer-satisfaction-for-8th-year%2F&amp;ei=I-BPUNSDPI609gSNwIC4BA&amp;usg=AFQjCNF4lXjI5r4NLa4FXZeIyLUikXkdWQ <br>http://www.google.com/url?sa=t&amp;rct=j&amp;q=apple%20customer%20satisfaction&amp;source=web&amp;cd=5&amp;cad=rja&amp;ved=0CEkQFjAE&amp;url=http%3A%2F%2Fwww.slashgear.com%2Fapple-grabs-top-spot-in-us-customer-satisfaction-rankings-15228389%2F&amp;ei=I-BPUNSDPI609gSNwIC4BA&amp;usg=AFQjCNF1aokOzNbqcflSZT6TvDxG5kwE <br>http://en.wikipedia.org/wiki/FingerWorks <br>http://www.ifixit.com/ <br>http://www.google.com/url?sa=t&amp;rct=j&amp;q=ipad%20proview%20license&amp;source=web&amp;cd=3&amp;cad=rja&amp;ved=0CDMQFjAC&amp;url=http%3A%2F%2Fwww.bgr.com%2F2012%2F05%2F10%2Fapple-ipad-proview-lawsuit%2F&amp;ei=puBPUN-LDZLM9gTRuoCgBA&amp;usg=AFQjCNHrGKYX0RtUA3RWwZPXPGOuOgibEAhttp://www.google.com/url?sa=t&amp;rct=j&amp;q=iphone%20largest%20launch%20history&amp;source=web&amp;cd=5&amp;cad=rja&amp;ved=0CD4QFjAE&amp;url=http%3A%2F%2Fnews.yahoo.com%2Fnext-iphone-biggest-product-launch-consumer-electronics-history-014541012.html&amp;ei=6uBPUNC5KZK09gSj5oC4DA&amp;usg=AFQjCNGe3CcPvjLIhe1r9sb4scqzYJRGdw
Its probably because most people today, no matter how much they say they want to help the world, will help themselves first... its all about the $$$ and the Ego. Sad really, this world could be so much cooler... Imagine if there was no BS out there? everyone got along, no one being snarky or cocky, you could actually have a good day, every day...lol
Just remember, in this economy, in order to help others, you have to have $$$ first.
Quick question, I'm currently making my own RPG with RPG Maker VX Ace and i'd like to know if there was anyway i could make it into an app?
A-nony-mus <br>Nice Iabble for an app introduction mon <br> <br>Championx5 <br>In your case I recommend Construct 2 http://www.scirra.com/construct2 <br>its originally free and when your &quot;app&quot; is ready then you may decide to use either of the licenses they offer. In my case I just upload the finish product as a web app to my server for testing up til i'm happy with it. <br> <br>Cheers and happy hunting/programming/iabbling or whatever...-ing :)
Don't know, never heard of that software before now. I know that unity has a way of making iOS apps, so it wouldn't surprise me if this did.
very nice thank you bro!
all that just to say Hello World? whats it take to make an actual app like these photo editing apps and such?
Apple has tons of sample code if you want to take a look at that and get the idea of the size of an average program.
That is not all that much work - really. With much power comes much responsibility, meaning that there are many small things required just to get up and running, but once you are, running that is, the next steps are not that much more complex
...like baby steps.. lol Thanks!
Very nice introduction to writing an app! This could be the road to riches for someone with a good idea an a willingness to learn. <br> <br>Thank you!!

About This Instructable


578 favorites


Bio: I am an Apple Developer in College ultimately pursuing a masters in robotics. If you would like to take a look at my apps, all ... More »
More by A-Nony-Mus: How to use the camera in your iOS program Creating your first iOS app Rat-trap powered vehicle
Add instructable to: