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
How To Improve Your Charisma
Do you ever wonder how some people seem to fit in everywhere and get along with literally everyone? Everybody wants to enjoy their company, talk to them, and wherever they go, there’s no such thing as a closed door or somebody standing in their way. Are t…
Dostoevsky - Walk Your Own Path, Face Your Errors
In Crime and Punishment, Fyodor Dostoevsky wrote, “That’s man’s one privilege over all creation. Through error you come to the truth! I am a man because I err! You never reach any truth without making fourteen mistakes and very likely a hundred and fourte…
Why you're unmotivated and how to get motivated?📚🧑🏻‍💻
Do you sometimes be like, “Oh man, I don’t have any motivation. I really need to motivate myself to do blah blah task?” I used to think I needed motivation to do something as well, but I was wrong. Motivation is overhyped, and I’m going to explain you why…
Kapil Gupta: Conquering the Mind
What’s interesting about talking to you couple is that you’re not for everybody. In fact, it’s quite the opposite. The things you think about and the way you speak really only applies to a very small set of people. This discussion is going to be unique in…
Foraging in the Rainforest | Restaurants at the End of the World | National Geographic
So I’m curious to see what unique ingredients Giorgi will be able to bring to the table, literally. Ow. [Speaking Portuguese] One of the most special species in the rainforest. The name is capicoba. That’s pretty, huh? For you—that looks like that looks v…
Solving two-step word problems with decimals (adding and subtracting) | Khan Academy
We are told that Lynn has saved $80. He spent $175.00 on a gift for his brother and $229.50 on a gift for his mom. How much money does he have left after buying the gifts? Pause this video and work through this on your own before we do this together. All…