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
LONELY.
Hey, Vsauce Michael here, and I am back in New York City. And today, we’re going to talk about loneliness. But first, I just learned this yesterday. Bear Grylls, the host of Man vs. Wild, has three sons, and I’m not kidding, their names are Jesse, Huckle…
See Antarctica Like Never Before | National Geographic
[Music] I think there’s no place on earth like Antarctica. You can spend days and days and days here without seeing any other human being. It’s just as close as there is to being alone on this planet. It’s just so beautiful, so majestic, so overwhelming. …
Collecting Animal Bones in Alaska | Best Job Ever
[Music] So here we are on the Arctic National Wildlife Refuge. We’re here looking for Caribou antlers and [Music] bones. We are pretty much finding bones wherever we go. What we have here is a shed bull Caribou antler, so a male, large male. This is where…
Bad Investing Mistakes That Make Me Cringe...
Hey guys, welcome back to the channel! In this video, we’re going to be talking about three specific investing mistakes that, in all honesty, these ones like really make me cringe. Like, not gonna lie! And in all honesty, I see people make these mistakes …
Reimagining Dinosaurs with Women of Impact | National Geographic
Okay, hi! I think we’re good to go. Welcome everybody! Um, today’s Women of Impact panel on reimagining dinosaurs, and we’ve got three incredible women paleontologists around the world, with London and the United States represented today in this panel. Um…
The Challenges a Repeat Founder Faces - Tikhon Bernstam
Hey guys, today we have Tea Con Burn, a multi-time YC founder. So could you just start by explaining how you first found YC? Yeah, I actually found YC because I was on Reddit. I was in graduate school, which meant I had a lot of free time. And so I was, …