yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

iPhone SDK Programing


5m read
·Nov 3, 2024

Hey guys, this is Mids on1. Today I'm going to be teaching you how to use the SDK for the iPhone. SDK does stand for Software Development Kit, and Apple has provided everyone with this Software Development Kit, whether you paid them or not. Unfortunately, you can't get some of the full features of this without paying to become a developer, but you can currently download the iPhone SDK 2.2.1 for the latest currently available iPhone OS. There is the 3.0 SDKs, but it's only for developers. I happen to have it, but it's only for developers.

Okay, so the first thing you want to do is open up your Xcode. Xcode will be installed on your computer, so you can just go to Macintosh HD, Developer, Applications, and Xcode will be there, or you can search it. Search Xcode. Okay, but anyway, Xcode comes with the iPhone SDK. So now that you've installed it, you just go up to File, New Project. Then under iPhone OS, you select Application, Window-based Application. Then you click Choose.

Now it's going to ask us what to call it. I'm going to call it "I Copy iPhone." Okay, so now it looks like the normal Xcode layout. You can still customize your toolbar, do a search, all this stuff. If you click on the main project, you can select MainMenu.xib, so I selected that.

Here's Interface Builder, and the iPhone SDK provides us a whole new set of tools that the Mac SDK didn't. The Mac SDK uses a framework called Cocoa to provide you with the great GUI tools such as text fields, buttons, etc. Now they're NSTextFields. NS stands for Next Step, but on the iPhone, they're called UI. So, UI TextField, UI Button, because it's not Next Step anymore.

We're outside of that range, and they didn't want to copy the names to disorient people, so we're not in Cocoa anymore; we are in Cocoa Touch. Right here, if you take a look, you can just go up to Tools, Library, and Tools, Inspector to get the Attributes Inspector and Library window.

So if you go under Library, Cocoa Touch plugin, you can see there are a bunch of controls. So I'm going to get right started and drag in controls. First of all, I'll drag in a label, make it the whole width of the screen, and I'll center the text, make it say "I Copy." Next, I'll drag in a text field and make it a good width, drag in a button, copy, and I'll drag in another text field.

This text field will be what's copying to. "I Copy" is an application I also demonstrated in the Mac programming that allowed you to type something in one text field, click copy, and it would appear in the other text field. It would work in the same way backwards.

Okay, so this application, all it's going to do is you're going to type in here, click copy, and it'll be in here. You won't be able to do it the other way because that's kind of pointless at this point. So, you will notice if you go up to File, Save, and then quit Interface Builder, then if you build and go in Xcode, the iPhone simulator will appear with your application running in it. You can type something in here, but nothing works when you click copy. Wouldn't you like it if it worked?

So we're not going to open Interface Builder up right yet. We're going to click on the Classes folder on the side, go up to Action, Add New File. We're going to make it an NSObject subclass under Cocoa Touch Classes, select Next, and call it "AppController."

Okay, so now in AppController.h, inside the @interface AppController NSObject, right before the closing curly brace—and I'll just zoom in there—you're going to type IBOutlet space UI TextField space *textField1 semicolon. Now, on the next line, we're going to type another IBOutlet UI TextField *textField2 semicolon. Now, outside the curly brace, right before the @end, we're going to type Dash space left bracket, or left parentheses, IBAction close parentheses copyStrings colon open parentheses ID close parentheses sender semicolon.

So now we're going to copy this last line that says IBAction and paste it into AppController.m, between the @implementation and the @end. We're going to get rid of the semicolon and change it with an open curly brace. You can get that by pressing, holding Shift, and then pressing the left bracket, and hitting Enter, holding Shift and pressing the right bracket to get a closing curly brace.

So now here's our code in AppController.m. Here's our code in AppController. So I'll just go up to File and Save. Okay, so now I'll click back on the main application and find your .xib and double click that.

So now we have our document window. The way you can get to that is in Interface Builder, going up to the Window menu and clicking Document, and this window will appear. So in the Library, you want to find NSObject. It looks like this and drag it in there. Then under the Information tab under Attributes, you want to set the class to be "AppController." Hit Enter.

So now it's a zController right there. So now I'll go up to Save. So now we have our main window. What we're going to do first of all, we're going to click on the copy button and hold down our mouse, hold down Control and the mouse.

Now you should be holding down Control and the mouse and drag it to AppController, and we're going to click "Copy Strings." Then we'll do the same, except first we click on AppController, hold Control, and drag it over to the first text field. We're going to call it "textField1." Do the same to the second text field and follow textField2.

So now we're done here; we can save and quit. So now if we go to AppController.m, back under Classes, between the open curly brace and the closed curly brace, we're going to type left bracket textField1 space setText colon left bracket again textField2 space text close bracket another close bracket semicolon. Sorry, where it says textField1 here, change that to textField2 and change this to textField1.

Okay, now we'll click Build; we'll click Go. So now I type in here "Alex," I click copy, it appears here. I type "Alex 1," click copy, it appears there. Type "Alex." If I type, "This is a cool string on 3.0," okay, you click copy. Yeah, and when you click on this one, it'll clear. When you click on this one, it clears because Interface Builder does that automatically.

So you can mess around with the iPhone SDK a little more, but this is just how to simply tie up your code. So that's all I want to show you. That is the iPhone SDK for complete beginners. If it doesn't look exactly like this, just download the latest SDK, and if it still doesn't look exactly like this, you may have to customize your toolbar, or this may be a very old video, so check the date on the video.

So thanks for watching, M kids, and unsubscribe and goodbye.

More Articles

View All
5 Secrets You Shouldn't Share with Others | STOICISM INSIGHTS #stoicism
Welcome back to Stoicism Insights, your guide to unlocking the timeless wisdom of Stoic philosophy for a more fulfilling life. In this video, I’ll be addressing certain personal matters and situations that are best kept private, things that don’t serve an…
Start Your Affordable Watch Collection Here
[Applause] [Music] In the last year, a lot of people have been writing me saying, “Okay Kevin, this is just absolutely great! Every time you’re talking about a watch, it’s a one-of-a-kind that no one else can get, and you’re such a rich person talking ab…
DONALD TRUMP'S FULL SPEECH | Trump claims victory, addresses supporters in Florida
Thank you very much. Wow! Well, I want to thank you all very much. This is great. These are our friends. We have thousands of friends on this incredible movement. This was a movement like nobody’s ever seen before, and frankly, this was, I believe, the gr…
Credentials don’t matter
Smart people, capable people, don’t let themselves be pigeonholed into one definition. That is a disease of credentialism. Because we created this university, now you’ve got to go to university, and you’ve got to get a degree in something. Then people say…
Local and global scope | Intro to CS - Python | Khan Academy
What do you think happens when I run this program? Does it print zero, four, or raise some kind of error? To find out, let’s explore variable scope. The scope of a variable describes the region of the program where we can access it. When we run this prog…
Course Mastery Sal (intro only)
Hi teachers, this is Sal Khan here from Khan Academy, and welcome to Course Mastery. So, back in 1984, famous education researcher Benjamin Bloom published the famous Two Sigma study, where he showed that a student who works in a mastery learning framewo…