Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 24, 2012, 03:10 PM   #1
vokov
macrumors newbie
 
Join Date: Oct 2012
using MVC in app with tree, table, and graphics widgets

Hey everyone! I am trying to decide whether I should use C++/Qt or Objective-C/Cocoa for my
next project. I am familiar with C++ and Qt, but know nothing about Objective-C/Cocoa (but
definitely don't mind learning since mac is becoming my primary target platform).

Qt has a pretty good support for model/view architecture, but using it for apps with tree,
table, graphics widgets that pull data from the same model seems pretty challenging.

So, I am wondering how one would go about organizing such an app with Objective-C/Cocoa.

Basically, I want to store train schedules (involving ~20,000 trains) in a model so that
(1) The tree widget would display departure cities at the top level, arrival cities on
the next level, and finally the corresponding trains.

Like this:
  • Paris
    • Athens
      • train A
      • train B
      • train C
(2) The table widget would display arrival/departure times and other data for the selected
trains. Train selection can be facilitated by adding check boxes to the above tree widget.

(3) Graphics widget would visualize the route of the selected trains on a map.

I would really appreciate any suggestions! Thank you!
vokov is offline   0 Reply With Quote
Old Oct 24, 2012, 03:37 PM   #2
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
Quote:
Originally Posted by vokov View Post
Hey everyone! I am trying to decide whether I should use C++/Qt or Objective-C/Cocoa for my
next project. I am familiar with C++ and Qt, but know nothing about Objective-C/Cocoa (but
definitely don't mind learning since mac is becoming my primary target platform).

Qt has a pretty good support for model/view architecture, but using it for apps with tree,
table, graphics widgets that pull data from the same model seems pretty challenging.

So, I am wondering how one would go about organizing such an app with Objective-C/Cocoa.

Basically, I want to store train schedules (involving ~20,000 trains) in a model so that
(1) The tree widget would display departure cities at the top level, arrival cities on
the next level, and finally the corresponding trains.

Like this:
  • Paris
    • Athens
      • train A
      • train B
      • train C
(2) The table widget would display arrival/departure times and other data for the selected
trains. Train selection can be facilitated by adding check boxes to the above tree widget.

(3) Graphics widget would visualize the route of the selected trains on a map.

I would really appreciate any suggestions! Thank you!
Seems like you would have an NSOutlineView, an NSTableView, and a custom map view. Then a controller object for each of those that presents your model data to the view in the form that it expects. Your model would be something vaguely database-like where the controllers could query it in a structured way about route information.

Really, this app sounds like a textbook example of a good place to use MVC.

You might need two layers of controllers so that there's place for the cross-view logic like selection to live. Haven't thought that part all the way through.
Catfish_Man is offline   0 Reply With Quote
Old Oct 24, 2012, 04:04 PM   #3
vokov
Thread Starter
macrumors newbie
 
Join Date: Oct 2012
Quote:
Originally Posted by Catfish_Man View Post
Seems like you would have an NSOutlineView, an NSTableView, and a custom map view. Then a controller object for each of those that presents your model data to the view in the form that it expects. Your model would be something vaguely database-like where the controllers could query it in a structured way about route information.

Really, this app sounds like a textbook example of a good place to use MVC.

You might need two layers of controllers so that there's place for the cross-view logic like selection to live. Haven't thought that part all the way through.
Sounds great! Thanks for the quick reply!

I am assuming the database-like model your are talking would allow each widget to update itself (the model) and, once updated, would dynamically update all the other widgets that pull the data from this model. Right? Sorry, I really have no clue how MVC works in Cocoa!
vokov is offline   0 Reply With Quote
Old Oct 24, 2012, 04:37 PM   #4
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by vokov View Post
... Sorry, I really have no clue how MVC works in Cocoa!
Cocoa Core Competencies

For details, use link at end of article.

I advise reading all the articles in Cocoa Core Competencies, along with each of the reference guides linked to.


There's also Cocoa Fundamentals Guide which has a bunch of important fundamentals in it.
chown33 is offline   0 Reply With Quote
Old Oct 24, 2012, 05:01 PM   #5
vokov
Thread Starter
macrumors newbie
 
Join Date: Oct 2012
Quote:
Originally Posted by chown33 View Post
Cocoa Core Competencies

For details, use link at end of article.

I advise reading all the articles in Cocoa Core Competencies, along with each of the reference guides linked to.


There's also Cocoa Fundamentals Guide which has a bunch of important fundamentals in it.
Will do; thanks! I am also considering Cocoa Design Patterns (http://www.amazon.com/Cocoa-Design-P...dp/0321535022/) as its first chapter is about MVC. Unless someone can suggest a better book...
vokov is offline   0 Reply With Quote
Old Oct 25, 2012, 07:01 PM   #6
mkmDesign
macrumors newbie
 
Join Date: Feb 2010
Location: Scotland
The Cocoa Fundamentals Guide that chown33 mentioned is full of great information that you will find useful.

If you're new to Cocoa and Objective-C then I highly recommend Cocoa Programming for Mac OS X
mkmDesign is offline   0 Reply With Quote
Old Oct 25, 2012, 08:36 PM   #7
mfram
macrumors 6502a
 
Join Date: Jan 2010
Location: San Diego, CA USA
Cocoa Design Patterns is really more of an "advanced" book. It assumes you are already familiar with Cocoa and Objective-C. I think it's a great book, but it doesn't teach the fundamentals.

You can certainly get it to browse through to see "what's out there" for Cocoa. But recognize you will need other books.
mfram is offline   0 Reply With Quote
Old Oct 26, 2012, 01:47 AM   #8
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
Quote:
Originally Posted by vokov View Post
Sounds great! Thanks for the quick reply!

I am assuming the database-like model your are talking would allow each widget to update itself (the model) and, once updated, would dynamically update all the other widgets that pull the data from this model. Right? Sorry, I really have no clue how MVC works in Cocoa!
Changes to the model should be done by the controller layer, which can then also call -setNeedsDisplay: or similar on views.
Catfish_Man is offline   0 Reply With Quote
Old Oct 26, 2012, 02:06 AM   #9
vokov
Thread Starter
macrumors newbie
 
Join Date: Oct 2012
Quote:
Originally Posted by mkmDesign View Post
The Cocoa Fundamentals Guide that chown33 mentioned is full of great information that you will find useful.

If you're new to Cocoa and Objective-C then I highly recommend Cocoa Programming for Mac OS X
Quote:
Originally Posted by mfram View Post
Cocoa Design Patterns is really more of an "advanced" book. It assumes you are already familiar with Cocoa and Objective-C. I think it's a great book, but it doesn't teach the fundamentals.

You can certainly get it to browse through to see "what's out there" for Cocoa. But recognize you will need other books.
Thanks to both of you. I'll start with "Cocoa Programming for Mac OS X" (luckily available in my university's library) and "The Cocoa Fundamentals Guide." I just want to first be completely confident that Cocoa's MVC is suitable for my project. This is why I am also ordering the design patterns book.
vokov is offline   0 Reply With Quote
Old Oct 26, 2012, 02:37 AM   #10
vokov
Thread Starter
macrumors newbie
 
Join Date: Oct 2012
Quote:
Originally Posted by Catfish_Man View Post
Changes to the model should be done by the controller layer, which can then also call -setNeedsDisplay: or similar on views.
Makes sense. I am definitely going to try using Cocoa on this project. I am very curious whether I can get a cleaner implementation compared to what's possible in Qt. Thanks for getting me started!
vokov is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Table of Contents-Numbers App-Generated automatically maeveen Mac Applications and Mac App Store 0 Apr 14, 2014 12:05 PM
How do I tell my app to display the next few table view cells? moonman239 iPhone/iPad Programming 4 Mar 15, 2014 09:16 PM
Help! Any App to repair partition table? Crisis OS X 10.8 Mountain Lion 0 Oct 26, 2012 12:57 PM
InfoCenter: a multiple widgets desktop app for your iphone r2build iPhone and iPod touch Apps 1 Sep 27, 2012 10:41 PM

Forum Jump

All times are GMT -5. The time now is 01:23 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC