views:

302

answers:

2

I'm new to Objective-C, Cocoa, Xcode and Interface Builder. I've got some C background in the past, as well as a fair amount of RealBASIC experience.

I'm working through Mark and LaMarche's iPhone 3 Dev book and I'm really just sort of stunned about how tedious some things are. Maybe someone can shed some light on this for me. My question really is, why does the process for seemingly simple actions involve such a complicated number of steps? Is there a benefit to the complexity which I'll come to love later? Or is it just a brute fact that is unavoidable?

For example, in RealBASIC, if I want a slider's value displayed in a text box, I simply add:

myTextBox.text = mySlider.value

to the slider's Changed event. I can program this in well under 1 minute.

In Xcode/Interface Builder, I have to physically type a declaration for both the text box and the slider, then type a property/outlet declaration for each as well, then create a method declaration and implementation for the ValueChanged even, then set up a (relatively) complicated typecast of the slider's integer value into an NSString using initWithFormat. I then have to return to Interface Builder to link up the controls with the control and method outlets I typed in. I don't see how this can be done in much less than 10 minutes. Maybe 5.

So, what's the benefit of this? Why doesn't Interface Builder automatically create, or at least suggest, control declarations and @property statements, as well as method declarations and implementations? Why can't double-clicking a slider in IB offer you a list of events and offer to automatically insert a skeleton method into your .h and .m file? And why does IB even have to be a separate application?

I'm willing to accept that some of this is my unfamiliarity with all things Xcode, but is this really as efficient as the development environment can be?

My apologies if this is a dead-horse, flame-bait topic with opposing sides on full aggro. If so, please just say "yes, that it is" and move on.

Thanks, -Rob

+1  A: 

I too used to think that Xcode and Interface Builder were unnecessarily complicated, until I worked through a book on both (specifically, Beginning iPhone Development: Exploring the iPhone SDK).

If you're serious about working with Xcode and Interface Builder and are as confused as I was when I started, I highly recommend picking up a book like the one I used. Granted, that was for iPhone development, but I think there is another book by the same publisher (or author) that is straight Mac programming.

Once you work through it and understand what is going on behind the scenes it starts to make a lot more sense. In some ways I prefer IB to things like Expression Blend or XAML for WPF programming in .NET.

Give a book a try and see if it helps :-) Good luck!

unforgiven3
Thanks for your response!That's the book I'm working through (only mine's the new one for iPhone OS 3.0). I'm not having huge difficulty seeing how Interface Builder and Xcode's .h and .m files link up, I'm just surprised (shocked) at how something that takes less than a minute in the IDE I'm used to takes 5-10 times longer here. It makes the idea of experimenting with different UI ideas seem sort of daunting. If every new control (or control removal), involves several minutes of typing code or tracking down code to delete, that just strikes me as--well--tedious.
Rob
Yeah, I see what your saying. Tedious is the perfect word for it :-) It would be nice if it were a bit more seemless/automated.
unforgiven3
+3  A: 

A lot of the reasons behind the way IB works will become more clear as you get used to the MVC paradigm.

Once you start using Cocoa Bindings, which update your model when the UI changes and vice versa, you should see an enormous productivity improvement.

Rob Keniger
+1. +2, if I could. With bindings, it's very easy to display the value of a slider in a text box and simultaneously make the slider responsive to editing the number in text box.
outis
Thanks to everyone for the comments about bindings. I'm sure that'll be one of the first things I go searching for once I'm out of the newbie/tutorials phase. I sure felt like I was typing plenty of code, but wasn't doing much **programming**. I couldn't imagine professionals preferring that.
Rob