 |
 |
Where to start? - Cocoa and specifics
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jul 2004
Status:
Offline
|
|
Hello,
First the long-winded introduction:
I am new to Macs and so therefore also new to programming for them. I have dabbled with Windows programming using C and the Windows API over the past few years, learning through a mixture of tutorials, skimmed and part-read books, and trying things for myself (a complete hack, in other words). I got a bit lost when trying to learn C++ and MFC, though, mainly because I'm just a hobbyist and will never be making any money out of it, so didn't want to sign away my precious evenings traipsing though 1,000-page manuals. But then I just bought an iBook, tried installing XCode, found a tutorial for a putting together a basic wordprocessor, and couldn't believe how much was possible with so little code - so I am thinking of trying to put together the app I've always thought about using Cocoa. I have printed out Apple's 150-page Objective-C manual, which I'm plowing through, and various other tutorials. So now I would like to ask some questions of more experienced developers, to gauge whether I can realistically achieve what I would like to do...
First, I wondered if anybody out there could point me in the direction of any tutorials, samples, or API functions that might help me with these objectives:
I would like to create an app, the main window of which would have two elements: a browser on the left, and a text view on the right.
- The browser would show all .RTF files in a particular directory on the disk.
- Double-clicking on any file in the browser would open it in the text view.
- I would like to implement the option to show the text view in full screen.
I've found a full screen tutorial on cocoadevcentral.com and know there is a supposed to be a SimpleBrowser sample in the AppKit examples, but I would be grateful for any other links or general advice about what I need to think about.
Also, if anybody could recommend the best Cocoa development forums, I would be grateful. I always used CodeProject and CodeGuru when "programming" (I use the word in the loosest sense) for Windows, but they aren't much help for Objective-C and Cocoa...
Like I say, I'm a beginner in Objective-C and Cocoa, so if you think I'm being overambitious to start like this, please say so, it will save me wasting a lot of time. And if what you say goes over my head, then at least I will have some idea of how much I have to learn.
Many thanks for any help or advice,
KB
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Sep 2000
Location: Texas
Status:
Offline
|
|
Here are 2 sites that are great:
http://cocoa.mamasam.com - Excellent archives to search through.
http://www.idevgames.com - Excellent forums with very knowledgeable individuals.
Take a look at those along with the tons of code/tutorials that are out there.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status:
Offline
|
|
That sounds like a very reasonable first project. Basically, you've got an NSTableView on the left side of the window and an NSTextView on the right. You'll probably want to embed them both in an NSSplitView.
You'll want to use an application delegate to handle opening the directory. When the directory is opened (using NSOpenPanel, probably), you'll create an instance of your window controller (a subclass of NSWindowController). This will control your window and will be the main workhorse of your app. The window controller will have an Interface Builder nib associated with it (via -initWithWindowNibName  . This will provide the relationship between your NSWindowController subclass (which will be the "owner" in your nib) and the graphical views.
Your subclass will implement the required NSTableView datasource methods. You'll use NSFileManager to get an enumerator of the contents of your directory, and the datasource methods will provide this info to your NSTableView. When the selection changes, you'll use the methods in NSText and NSTextView to set the contents of your text view.
There are other ways of doing this, of course, but since you're a n00b, I thought you might appreciate a roadmap.
You're probably looking at under a hundred lines of code total.
Oh, and I second the vote for the mamasam website. It's a great place to search to find out how to do some particular task.
|
Geekspiff - generating spiffdiddlee software since before you began paying attention.
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2002
Status:
Offline
|
|
Since your new to OS X programming, and hopefully are using 10.3, you should look into using bindings for your NSTableView and various other parts. It allows you to perform many actions without all the code. A tutorial for bindings is available at http://cocoadevcentral.com, but it seems to be down.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Jul 2004
Status:
Offline
|
|
Many thanks for taking the time to read my post and for responding - and for the great advice.
djohnson - thanks for the links, I have just been searching through mamasam, and it seems like it's massive. I'll check out the other one later.
Smeger - wow, thanks for the overview of how I should go about putting it together, much appreciated. Under 100 lines of code? Incredible. Some of what you have said is a little over my head, as I still have to get to grips with OOP and Objective-C, but hopefully it will make more sense to me once I've got through the Objective-C book and gone through more of the basic tutorials. So I'm copying it all down and coming back to it when I'm a bit more comfortable with the terminology and way of doing things - I am certainly very grateful for the roadmap.
EDIT: I forgot to ask: Would a table view be better for this purpose than a browser view or an outline view, then? Thanks!
IOliverC - thanks, CocoaDevCentral seems to be back up again, so I am going to look up bindings.
Many thanks again for the replies (and of course, anything else that anyone thinks might be useful always appreciated),
KB
(Last edited by Ambit; Jul 2, 2004 at 04:22 AM.
)
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|