Re: Program Structure
Re: Program Structure
- Subject: Re: Program Structure
- From: Joanna Carter <email@hidden>
- Date: Wed, 29 Jun 2011 18:29:46 +0100
Le 29 juin 2011 à 14:07, Jeff Gaines a écrit :
> I am new to OS X, having purchased this Mac Mini 2 weeks ago, and new to Objective C/Xcode 4 although I have been writing programs since the days of the Vic 20, most recently in C# using Visual Studio.
>
> I have set out to write an address book as my first program as it means displaying data, reading it from Text Boxes and reading/writing a SQLite database. I also need to pick up button press events, fill an NSTableView and respond to click events from the table.
>
> It works, it was difficult and I've nearly worn Google out but I'm there. What I would like advice on is the overall structure of this project as I will use it as a model for the future.
>
> What I have is:
>
> MainMenu.xib - what I would have called a Windows Form in VS.
> JMainView - I have set this up to be the "code behind" MainMenu, it reads/writes data in the Text Boxes and handles button clicks and the selection of a record in the NSTableView, then calls functions in the other classes.
> JAddressData - this is the address data class.
> JAddressUpdater - reads/writes records from/to the SQLite database (it has static functions)
> JDataTableSource - the data source for the NSTableView, it originally picked up the click event from the table but now just deals with the data for the table.
>
> Is that a reasonable structure to use? If there is a web page with recommendations I am happy to look at it.
>
> During the process I had another class called JRecordManager which I have removed from the project but the output window refers to it as an unknown class. I have cleaned the project but this warning is still there. Is there something else I need to do to remove all traces of it? It isn't referred to in any of the code files now.
You are trying too hard to make Cocoa work like .NET; you really need to get to know the MVC design pattern and how Cocoa apps are put together :-)
Could I suggest you get "Cocoa Recipes for Mac OS X (2nd ed.)" by Bill Cheeseman. I just got it and am working through the sample application.
It really is worth every penny (being in the UK, I don't use cents :-)).
If you are wanting to save data to SQLite, then you really need to read up on Core Data; you can also hook up edits directly to properties of classes, using Cocoa Bindings, similar to how you would bind edits to properties in C#.
I also have a, deliberately simple, tutorial that I wrote, that demonstrates the essentials of Core Data and bindings, etc; let me know if it would be of any help.
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden