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
The Problem With Science Communication
On December 1st, 2022, the journal “Nature” published a cover story about a holographic wormhole. It was purportedly created inside a quantum computer to probe the intersection of quantum mechanics and gravity. The story kicked off a frenzy of tweets and …
How To Survive Quicksand | Primal Survivor
[mud squishing] [groaning] I’ve been watching out so closely for predators that I run straight into something else life threatening: quicksand. Actually, this is a little bit more serious than I thought. [sputters] What makes this dangerous is, if you can…
The Fight Against Worldwide Child Slavery & the Sex Trade | Jim Caviezel and Tim Ballard | EP 372
This is the best interview I’ve ever had in my life. I love your line of questioning and, um, getting to what is real. I hooked into Tim; he has a childlike quality to him, and I stay with that innocence and that—and don’t take that innocence’s weakness o…
A Message to Twitter CEO Parag Agrawal
Dear Mr. Agrawal, I wrote this when it was literally two in the morning during my recent visit to beautiful Samos, Greece, where I was on business attending to my efforts on the educational front. I woke up suddenly from my slumbers with you and your com…
Artificial Intelligence Should Be a Good Kick in the Groin | MIT's Michael Schrage | Big Think
I like to say that the real future of AI is not artificial intelligence but augmented introspection. All of these different theories of mind and theories of self create opportunities for redefining what we want augmented introspection to be. Look at Eric…
The Fascinating Lives of Bleeding Heart Monkeys (Part 1) | Nat Geo Live
So National Geographic asked us here tonight to tell you about a day in the life of gelada monkeys and what it’s like to live alongside them. For the past decade, the vet and I have spent years living alongside this species in a unique kind of alpine out-…