Cocoa, Core Data, and me (V)

Let’s take a closer look at the radiobuttons and how they relate to core data. Remember how the countries drawer pane looks in Interface Builder:

Detail view in IB

I want the four radiobuttons to correspond to the four possible “VAT regions” in the data model:

Data model

Maybe I need to explain what I mean by “VAT regions”, as most non-europeans will find the concept literally foreign.

Continue reading “Cocoa, Core Data, and me (V)”

Cocoa, Core Data, and me (IV)

I’m back after finally getting the tax forms mailed in. What a waste of time that is. A civilized society shouldn’t be doing these things to their citizens.

Now the time has arrived to construct the CountriesController class. This class controls the model and view for the countries data element. It is instantiated by the AppController and in turn loads and shows the Countries.nib. There’s only one single instance of the CountriesController class, so it’s a singleton.

Continue reading “Cocoa, Core Data, and me (IV)”

Cocoa, Core Data, and me (III)

I realize I skipped a step right in the beginning. I’m sure I skipped more steps, but at least I noticed this one. The step I missed is:

How does one create a new window and its associated objects and have it created when a menu option is clicked or another part of the application needs it? We don’t want everything crowded into the MainMenu.nib, so we need to modularize it somehow.

Continue reading “Cocoa, Core Data, and me (III)”

Being Joppy

So, I ventured out in the World of Warcraft after quite a bit of pressure from a friend. Downloaded the 10-day trial and fired it up. Works just fine.

I created my first character to look a bit like me. Too much like me, really. Me, first incarnation. Short legs, gray, rotund and highly ineffectual with a weapon. Damn, did I get whipped. Spent most of my time running out of graveyards looking for my dead body, which was always inconveniently far away. I did get a lot of excercise that way, but it seemed to have no influence on my rotundness, either in the game or IRL. The rest of the time I spent being confused. No weapons seemed to fit this character and even the really cool twirling gesture I had in the beginning somehow went limp and dead after a while, and I could never figure out why I didn’t have that thing anymore. Or why I had it before. So, not only was I a loser, I was a bewildered loser. A couple of times I mistakenly agreed to duels with other characters, which never took more than a few milliseconds, leaving me running from that old graveyard again. I half expected the angel to smack her forehead and exlaim “No, not you again… but she never did.

I soon learned to always decline all kinds of invitations and not to speak to strangers. Somehow, during all this suffering, I did manage to get to level 10, even though it didn’t seem to do me much good. I still got clobbered by anything larger than a rabbit. I could still whack chickens, but that’s only briefly satisfying for us non-psychopaths.

So, I left this ridiculous little doppelgänger out somewhere in the woods and created a new character, about four times as tall, looking not a bit like me, but with a little more style and character. Ran around a church or abbey for a while, murdering woodland critters to my heart’s content and actually collecting some imaginary money along the way. This guy had a lot more success than the first character, which only goes to show that if you’re a man, you should be tall and have a flat belly. Everything goes better for you.

This time, I didn’t accept any duel invitations. Actually, I only got one, which I promptly declined. I guess my more imposing persona seemed less of an easy target, even though the game engine really doesn’t care how you look, you’re dead just as quickly, anyway. It’s not like it’s a presidential election or anything. I also got only two invitations to join groups. I guess you have to select a female character to get a lot of those. Not that I want to be in groups, I’m not a team player. Interestingly, I fought along other guys a couple of times, without any kind of conversation. That’s the style I like. No talk, just action. Then just go away.

My second persona. Tall, handsome, not me.With this character, everything went better. Enemies actually died after a while. I got a handle on the spells, the firethrowing, the freezing of enemies. I could even turn them into sheep just by waving my virtual hands around.

I spent a weekend running errands for people (quests, they call them), sneaking up on unsuspecting troll-jawed minicles and young winter igloo beers, or whatever. I’m sure I’m getting the names wrong. I’ve been stealing bandannas, copper coins, emptying other people’s magic chests, but most of all I’ve been, you guessed it, running from graveyards looking for myself. The difference being that this guy has longer legs, and I’ve chosen to die closer to the nearest graveyard most of the times. If real life was that simple.

But mostly, I’ve been skinning corpses left by others, and beating the crap out of cows, deer, and the occasional boar. That’s me. Go for the small stuff, but it does add up when you sell the skins. I got to level 10 with this one as well. And I’m a pretty good skinner by now.

So?

Will I buy this game? No. And there are several reasons.

I would buy it if they sold it to me online. Actually, I can’t understand why they don’t. I already have the game, since I downloaded the 3 Gb trial file, which is almost a DVD. I’m sure the shelf unit contains the same thing. But Blizzard won’t sell me a license online, they expect me to drive into town to find a store that has it in stock. Or find a seller on the net and have it shipped. Why? I’m perfectly ok with paying the full price over the net and getting just a license code.

I would just maybe get a subscription if it cost the same over here as in the USA. Paying 50% more just because we’re in Europe is a slap in the face. I don’t mind the price itself, I mind the price difference.

Finally, the subscription is on a monthly basis. I’d love to play this game every now and then, but a monthly fee stresses me into playing too much. I’d really like a model similar to Skype’s outdial service, where you pay for use in advance. If Blizzard would let me buy 50 hours online gameplay for $25, for instance, and they’d let me use it over six months, I’d do it.

I’ll wait until Blizzard changes their terms, or until the next competitor comes along with something that suits me better.

Correction: a friend showed me that you can, in fact, buy WoW online. It’s hidden, like most treasures in WoW. Go to “manage your account” and in there somewhere, you can buy a key online for 19.95 euros.

Cocoa, Core Data, and me (II)

I promised to describe how to implement validation to ensure uniqueness in the database. Here goes.

First, you need to open the datamodel in XCode. With the datamodel on screen, select File… New… and you’ll see “Managed Object Class” under the section “Design”. Note that this choice simply isn’t there unless you first opened the data model.

Continue reading “Cocoa, Core Data, and me (II)”

Cocoa, Core Data, and me (I)

My travails as I implement my first project in Cocoa, part I.

This is, or may become, a series of blog entries about Cocoa development, as written by a complete n00b. I’m not saying it’s correct, I’m not saying I will even go on with the entries; I may stop at any time or lose interest or something. Or die, or end up in jail. Or lose my memory, or lose my website and backups. But if I don’t do any of those things, I intend to chronicle my advances into the world of OSX development. Thanks. You’re welcome. BTW, if I discover that I said something unusually stupid, I may change the text afterwards and pretend nothing happened. So if you want to prove me an idiot, you’d better take a screenshot of it before I remove the evidence. Another way of saying the same thing is: I will update the text as mistakes are discovered. Or not.

I’ll put my entries about this project into its own blog category: OSX Dev, so if you want to follow just this story, select the category in the sidepanel.

I’ve done Windows development for 20+ years and I’m sick and tired of it. I’ve been PDG (Pretty Damn Good) in a couple of languages, like compiled Basic for CP/M, Clarion for DOS, C++, and Delphi. I’ve been decently good in C#, and I’ve done my share of hating Centura. I’ve tried Java, and it left me cold.

Some languages inspire, like Clarion for DOS and to some degree Delphi. Some languages are too tedious and complex to inspire and only turn into a dreary day job, like Clarion for Windows and C#. Some languages inspire revulsion, like Centura. But that’s just me, YMMV.

Some languages are highly productive, and again, I drag up Clarion for DOS. I really love C++, but I can’t call it productive. It’s like going to the pub. You can delve into irrelevancies forever, to get everything just right, but you’re not advancing very much. There’s nothing like a perfectly tuned template to turn me on, but what’s the point? Yes, I know, there is a point, but it’s a bit too small to get actual real live and breathing software delivered.

I have a feeling that Objective-C and Cocoa may be an inspiring combination, so I started a project just to learn about it. The project is an accounting program, so it’s a database app. I’m not aiming for multiuser or anything fancy, I just want an accounting app I can change myself when I need something. I’ve done accounting apps before, so I know how they work.

Continue reading “Cocoa, Core Data, and me (I)”

The ICU Team From Hell

I just read a newspaper article about how an elderly woman died on a British Airway flight and was moved to a free seat in first class. Even though the body had a seat belt on, she kept sliding out of the seat on to the floor which upset other passengers in first class. I don’t know what upset them most: that she was dead, or lay on the floor, or got a free upgrade, but upset they were. British Airways duly apologized, maybe for all these things.

I guess the crew on this flight was of the same variety as one particular team on the ICU where I did my residency enough number of years ago to make any crime they committed fall under the statute of limitations. Some of these nurses also worked in the ER on the night shift, and this is where the following story plays out.

Ambulance

On a dark and rainy night… a car crash trauma victim is admitted in pretty bad shape. Major blunt trauma to the chest, miscellaneous fractures and stuff, maybe neurological problems (I don’t remember), unconcious. Naturally, everyone just start doing their stuff, taking blood pressure, vital signs, arterial blood gases, putting in central IV lines, etc. We didn’t have oxymeters back then, but he definitely looked hypoxic.

After a couple of minutes, I get the blood gas results, and they confirm what I thought, namely crush lung. Low on oxygen, low on carbon dioxide. I was standing about 3 meters away from the patient explaining the blood gases to an intern while the nurses were working on the patient. I was talking in a normal to low voice, explaining how the blood gases showed bad oxygenation and hyperventilation at the same time, which indicates functional shunting, in other words almost certainly a crush lung, so we’d need a chest xray and almost certainly PEEP (ventilation with over pressure). We kept discussing different aspects of this for a while, maybe a minute or so.

Then I turned around and noticed the nurses had put a mask and balloon over the face of the patient, but hadn’t connected any oxygen line to it. They didn’t pump the balloon either. So I said, quite loudly, “hey, you forgot the oxygen line!”, whereupon the lead genius answers “You shouldn’t connect oxygen in these situations!”. So I said, “Of course you should!”. He says “No!”.

So I walk over there and ask them “What in the world are you guys doing? Suffocating the patient?”

Answer from the lead male ICU nurse: “You said he is hyperventilating, and when a patient hyperventilates you make them re-breathe in a bag. Everyone knows that!”.

So here they were, effectively suffocating a patient that came in to the ER already very short on oxygenation, because they overheard a discussion I had with an intern that they didn’t understand and acted on anyway. They had an unerring talent for doing the wrong thing for the wrong reasons, with a scary consistency.

When these guys worked nights, believe me, you didn’t have the luxury of sleeping while on call. Death by stupidity walked the corridors like a ghost.

Anyway, the patient made it. But certainly not thanks to that team.

Back to the regular programming now.

My ongoing fight with XP

I’ve been using Windows since the ’80s. Programming for it, too. That’s been my main “thing” in IT all these years and still is, to some degree. But then, almost two years ago, I got myself a Mac, an iBook, and it’s been downhill ever since. Everything about Windows XP irritates me now. Let’s go through my current frustrations.

Continue reading “My ongoing fight with XP”