Programming with xCode is not as difficult



If I had a dollar for every person that tried to learn Objective-C and gave up, I would be a millionaire. Right? I have heard practically every second developer say that and they have looked for alternatives, some finding their niche and some having to be ruled by Objective-C.

Now, Objective-C is not such a scary thing and in 2009 I was in the same boat as most of you. I was an enterprise developer of spaghetti code for a very long time and worked on Microsoft technologies and *gasp* VB, hated Java with a passion and did not feel that C could help in quick development cycles and C++ was an overkill. The best part about VB was custom controls, either 3rd Party or the ones that I could create by *subclassing* (not a good word in VB) a graphic element and being responsible for it's drawing. Coding for me was like a summertime affair, it was on and off, the last time I actually was a hardcore developer was in 1999 after which I was more into other supervisory and management tasks till 2006 when I was into hardcore development for about 1-2 years for a client and then off again. So, Objective-C was *not* exactly fun times. I could make no head or tail of the square brackets, the - and the + signs in declarations, the : every now and then, it was just a bit funny.

In 2009, I attended a workshop on iPhone development, the sole aim of that workshop for me was to actually use Objective-C which I had never used and kind of shy'ed away from. I got an idea of what Objective-C was and tried my hand at creating some apps for the iPhone. Oh Boy! What an ambitious idea, I could not get the code working right for several reasons, logically, what I wanted to do was perfectly fine but it was the new environment and the way the Apple system workflow worked which made me cranky. However, having said that I did get a game out of the door and onto iTunes Store.

I had several starting issues and I ended up with creating a central heartbeat system that would then show/perform according to the appMode which changed at each stage as haltMode, gameMode and pauseMode, touches were handled based on the modes to know what was being pressed. Using the CGRectContainsPoint. Routines were called using their textName via performSelectors. Perhaps, not the best way to do things, but that was what i could do at that time to get it working.

I made a few more apps in Objective-C and the confidence level increased, but I always dreaded the Mac OSX app, it was not the same and it was more complicated with so many controls to choose from.

I just released my first Mac OS X App to the general public, it can be downloaded from http://www.oz-apps.com/files/CoronaCodeGenerator.dmg Work on this was started this morning and it was done by lunch time. It was all mickey mouse code just the way it used to be in VB. Yes, it might not be portable as Delphi code could be or RealBasic code is, but for anyone that has done VB coding before, majority of the work is done in Interface Builder and that is the most daunting part that scares developers away, or if you do what I do, not use the Interface Builder and write the controls myself in code (bad idea) then it seems more like C++ than VB.

For this app, I did not have to write much code, and I get a lot of things for FREE, like I can highlight text in the generated code and have the system speak it to me, I can perform transforms. It is all about the controls offered by Mac OS X and how you use them. I learned that there is no such thing as a Label on Mac OS X, they are all TextBoxes but with the selectable and editable set to false and without a border. The major uphill battle with xCode is knowing the controls and using them.

Those that have used VB will instantly recognize this code
selectedText = cboType.Text
now on the Mac OS X ComboBox, there is no text method ( [cboType text] ), so for a very long time I could not get the text value, I found the indexOfSelectedItem and I could determine from that what the item was. Till I found [cboType stringValue] DUH!! and for the TextBox which is called a TextField on Mac OS X,
myText = txtAge.Text
would be written as
NSString *myText = [txtAge stringValue];

and it gets even better under Mac OS X, you can also get
int myAge = [[txtAge stringValue] intValue];

which would have been
myAge = val(txtAge.text) in VB

The development platform under Mac OS X is powerful and quite handy if you can get your head around it to get it to do what you want. Get cracking at it, it is an iceberg there is more underneath than meets the eye. To add to that you also get the Apple UI and HIG for Free that make the app look prettier.

Comments

  1. Everything in this article is true. I've been a hack (hobbyist) programmer since I first sat in front of a computer way back in the late 70s. I can write many languages on many platforms and there's never been an IDE, platform or compiler that I couldn't master (even Java! ick!) I am now on about my 5th book in an attempt to learn XCode, objective C, etc.
    Every time I think I've learned something, I try to apply it in a way that makes sense. I try and try and try and try and nothing ever works. Eventually I will get online or ask someone or something and the answer is always the same.
    "Oh, you have to stand on your head and paint a red dot on your chin and chant 'blah blah blah' 30 times and it will work. I know, it's not in the documentation, but you should 'just know.'"

    ReplyDelete

Post a Comment

Popular Posts