green_knight: (Archer)
[personal profile] green_knight
This is a very basic thing, but at least under Tiger (10.4) there are different ways of doing it. Even if you have a newer version of IB, many tutorials date back a considerable time, and they're still perfectly good tutorials, and the difference isn't always obvious when you just read them, so this remains relevant.

When you create a project, you will create an application controller (a subclass of NSObject). At least, you will do so if you're a good citizen sticking to the MVC model.
In the Classes tab, select your App Controller, and add actions and outlines using either the items in the Classes menu, or the attributes in the Inspector palette.
When you create the files for your application controller, these outlets and actions will be automatically added to your .h and .m files.

So far, so good, and this is what most tutorials will tell you.

When you want to add further outlets and actions, you _can_ do the same. This will lead to IB creating new files, which you will then need to merge, because all the code you've written is in the old, about-to-be-overwritten file. That's a lot of effort (and a lot of potential to go wrong) so my advice would be not to do it.

The other way is to add outlets and actions to the files manually, select your class in the classes tab and use the 'read AppController.h' item in the Classes menu. Your actions and outlets will appear in the attributes list, and you can connect them as usual. (That is, as long as you remember to implement them in AppController.m)

(This post was sparked by a fifteen minute odyssey following the line 'we add an outlet' without saying how to actually do it. Once you've done it x many times, it will be second nature. Until then, it's not the most intuitive thing ever.)
green_knight: (Bravo)
[personal profile] green_knight
I'm currently reading this book, and it lives up to my expectations of an O'Reilly title - it's concise, contains a lot of information, and explains things very well.

So well, in fact, that when faced with a particular listing, I googled (as I am lazy) for a webpage that would give me all that information in one place, so I didn't have to copy it.

At which point I found

http://commons.oreilly.com/wiki/index.php/Learning_Cocoa_with_Objective-C/Preface

which is the starting point to the abovementioned book with all examples etc, online, and free. Yes, it *is* slightly dated, but the principles haven't changed, and it contains a boatload of references and explanations that will come in useful.

Thought I'd share the love.
green_knight: (Dragonfly)
[personal profile] green_knight
http://cocoasamurai.blogspot.com/2006/09/tip-pragma-mark-organizing-your-source.html explains it better than I can, but this is one of the little things that I've stumbled across in sample code.

Basically, by using

#pragma mark -
(which will give you a blank line)
and

#pragma mark whatever

it means that your editor will contain a list under @ implementation MyClass listing all your methods. It's a way to organise code and make it easier to jump to methods. I can see a strong case for getting into the habit straight from the start.
green_knight: (Never Enough)
[personal profile] green_knight
You probably don't learn how to program from a book, but it can help. Below is a list of Cocoa books that I have found in my local library.

Snip seven books )

I will review the others if and when I get to them.

Over to you: anything I've missed? Any experiences? The most frustrating part for me about learning to use Cocoa is that there seem to be plenty of tutorials that let you ride the waves of 'see how many cool things you can do with a few lines of code' which really is a very cool thing indeed, but I find that most of the time I don't seem to _understand_ the basics: when do you create a new class? Which one of the three or four methods to achieve X is the one you should choose? How does one _design_ an application when all you have is an idea? How do you know which classes, functions, and interface element will best achieve your goals?

I have the advantage of having developed applications (of sorts) for many years - not programmed from scratch, but I've done, in order, Hypercard, Filemaker, Multimedia, and web applications (including PHP), with probably one or two missing; and I've actually _read_ Apple's Interface Design Guidelines, so I have a handle on many of these questions - but I don't see books or articles addressing them.

Objective C tutorials, on the other hand, exist in large numbers. and while they're a good thing, I find them often contradictory, but that's a subject for another post.
green_knight: (Bruja Informatica)
[personal profile] green_knight
In the comments to an earlier entry to [community profile] three_weeks_for_dw it turned out that there wasn't yet a community for people who use Apple's Cocoa in programming.

So I created one.

I would like this to be a place where Cocoa users can share tips and tricks, tutorials and articles, problems they encounter, brainstorm, discuss development for iPhone and iPad, and, and, and.

(Personally, I use Objective C, and there seems to be no community for that, either, so I'd love to meet other Objective C programmers).

So come in, throw the manuals off the chair, and have a cup of cocoa.

Profile

Cup Of Cocoa - OS X/iPhone/iPad Programming

June 2010

S M T W T F S
  1 2345
6789101112
13141516171819
20 212223242526
27282930   

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 15th, 2025 06:58 pm
Powered by Dreamwidth Studios