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

Mac Programing Lesson 1 Part 2


2m read
·Nov 3, 2024

Thank you for continuing to watch this video. If you have not seen part one of this video, it would be smart to watch that first because otherwise this part won't make any sense. Thank you, enjoy the video.

So I'm going to declare an NS string, and I'll put star here, and I'll call it, um, time string, and I'll say it equals a new string. Now, in Java, you would do new string. In Objective C, you have to allocate it and initialize it, so you do left parentheses or left bracket NS string alloc right bracket, put that in brackets, and then outside of those brackets call a nit with format.

And then here's where we put the format. So I'm just going to do percent D, and as the next parameter to a nit with format, I'm going to set it to be time, time left parentheses null. So time is an old C function, and you just pass it something that doesn't matter, so I'll just pass it null.

So now we're going to have an NS string that is not only allocated, but it has the time in it. And just for fun, I'm just going to say t equals, or no, I'll just do T colon space, and then percent D to show you that it is in fact a format.

So if you remember from C, you do percent D, and that means in the next parameter, you're going to have to pass it an integer. So time is a C function that returns an integer, so now we're going to have a string called time string that's an integer.

So now, if we set the string value to time string, it'll say T and then, you know, the time. So this is easy. We're going to also call this when it loads.

So when every application loads, um, what happens is the program looks at every single one of the objects here and looks for a method on them called awake from nib, and it calls awake from nib on them. Awake from nib is just something that gets called when everything is loaded.

So if I implement awake from nib, I don't have to add it to myh because it's built into every class. Um, so if I add it here, this code will run when the application starts up, so I'll just paste the exact same thing there.

So now, if you watch, it says T and then the Epoch time, time since 1970. If I click it again, it'll keep on changing. Now the label's not quite wide enough to display the whole Epoch time, so I'll make this window a little wider.

So it is changing there, so this is how to make our application. I was rushing through this because I wanted to be very, um, very fast, maybe make it just a two-parter, not a three-parter.

And I'm sure you'll all have very many questions for me, and I'm fine with that, so please ask away. Anyway, thanks for watching. My kids in the one, look forward to Objective C lesson two for the Mac with Coco. Um, anyway, subscribe and goodbye.

More Articles

View All
Can Stem Cells Reverse Aging? With Dr. David Agus | Big Think
I want to tell you one story. And the story came from the early 1950s. A woman named Wanda Ruth Lunsford, she was a scientist in New York City and she published one paper, which turned out to be her only paper in science and she was actually pushed out of…
How to sell private jets to billionaires!
My name is Steve Varsano, and I have a company called The Jet Business. We’re involved with the buying and selling of corporate jets. I live in the UK; I work in the UK. I set up my business in the UK, but my business is global. The final purchase price …
How Comic Books Can Make Kids (and Adults) Smarter | Gene Luen Yang | Big Think
Out of all of the visual storytelling media that are out there – film, animation, television – comics is really the only one that is not time-bound. That’s what I call permanent. Which means, you know, when you’re watching a movie or when you’re watching…
The Struggle of Faith | Biblical Series: Exodus
Here they are. They just saw the most incredible miracle of all: He transcended even the ten plagues, the crushing of Pharaoh’s army. They are walking through a sea that allows them dry land. Now they fear God and believe in God, and believe in Moses. The…
When Life Hurts, Care Less About It | The Philosophy of Marcus Aurelius
Once the most powerful man in the known world, Marcus Aurelius attempted to live virtuously, following Stoic principles. Unlike many Roman Emperors, he did not indulge in the many pleasures he had access to, like getting drunk on wine and watching sadisti…
How Damaging is Radiation?
What is radiation? Isn’t a bad type of poisoning. It’s just like a dirty word to me. It’s just something which is not good, not good for me, being a human being exposed to great amounts of it—waves of bad stuff. Yeah, I mean, it’s dangerous. We all know …