Create iTunes-like grid view connected to Core Data on OSX - cocoa

I am an experienced iOS developer interested in creating a Mac application. I want to create a grid view of data connected to my Core Data store via bindings, which, like iTunes, should by default only display a subset of the total data columns, but allow the user to choose to add more columns from the database to be displayed, move them around, etc. OSX has a number of grid-like GUI elements, e.g. NSTableView, NSOutlineView, NSCollectionView, etc. Which of these is the best to create such a view?

The NSCollectionView item cannot handle large amount of data, since it does load all the views even though they're not visible at the moment. If you use for more than 500 elements (or a few more), you will get an unusable view and a lot of errors in the Console.
You should always prefer the IKImageBrowserView for displaying large amounts of data, that is included in the Quartz framework. I think that iTunes uses this.

I don't know about the NSCollectionView, it is pretty new, I am sure you can make exactly what you want with an NSTableView. It really has more to do with the cells that you implement and keeping track of your control Cells. Check out the core data application demo, if that isn't what you want you can follow #sudo rm -rf to:
the NSCollectionView programing guide

Related

UITableView like NSTableView

Ive developed for iOS in the past and recently moved over to mac development. I began a project to "get the feel" of things, and ran into an issue. Im trying to create a NSTableView to display multiple items, including a label, a 2 UIImageViews, and a UIButton. NSTableViews are way different than tables on iOS, and I cant simply create a custom TableViewCell (I think). A great example of how I would like it to look is AlienBlue for Mac: (The middle table with post information)
Can anyone shed some light on how to create this?
You have the power of being able to return whole views instead of cells in NSTableViews.
Here's Apple's documentation on View-based tables and how to populate those views in your table.
The delegate method I use most in my own view-based tables is "tableView:viewForTableColumn:row:"
Hopefully this points you in the right direction!
Please use NSCollectionView instead (set NSCollectionView.maxNumberOfColumns = 1). It's a more modern, extensible view api, that is analogous to UICollectionView.
In contrast, NSTableView was originally meant for displaying a spreadsheet table (with add-on support for custom view cells), and is less consistent with UITableView.

Is there a concept of viewcontroller containment in NSViewController

In iOS, you have a concept of View Containment, is there such things in OSX?
Basically I want to create multiple nsviewcontroller each managing a specific view. I'd have a MasterViewController with a menu on the left (like ITunes), each time the user click on an item on the left, it would load the correct nsviewcontroller to display it's view.
Any tips to achieve what I need is appreciated
Thanks,
As of OSX 10.10 there is, watch Storyboards and Controllers on OS X.
Comment.
NSViewController did basically nothing (other that load NIBs) for years, I'm glad to see that it finally got from attention. Certain people in the Cocoa crowd here have a snotty attitude about the view controller programming style; I've asked questions like this before and had the "are you a iOS newbie coming to Cocoa" response. That's something that I never understood, it's a great model for containment, and reuse.
The main difference between OS X and iOS is that on an iOS device you have only one "window". On OS X there are desktops that can contain many windows that you can view and interact with at the same time.
In general, it sounds like you are trying to create an NSWindow that contains a single-column NSTableView for your list of choices on the left, and some other view that will display the detail of the selection on the right. It's common to place these within a vertical NSSplitView so the user can adjust their relative widths, but they could also stand on their own, as two separate subviews within the window's main view.
You typically use an NSArrayController to manage the list contents and track which particular item is selected. For your detail view on the right, you would use a single NSView with NSControl subviews that display values bound to the array controller's selected object.
If the data structure varies among your objects, swap in or show/hide various subviews as needed for the different types of data the particular selected object represents. You can use the "Conditionally Sets Hidden" binding option to automatically hide controls for which there is no applicable keyed value.
Alternatively, if there's a fixed number of objects in your list and their structures are all quite different from one another, then you may wish to use a tabless NSTabView that has a separate tab with its own custom view for each of your objects. Observe when the selection changes in your list, and select the appropriate tab accordingly.

XCode iPad split view controller with detail views containing several form controls

Fairly new to Mac and XCode 3.2.6 and iPad. I have a fairly simple business data model to implement on the iPad, but can't seem to find the combination of views and controllers to use.
It's a simple data collection program, but there are too many data fields to fit on a single screen so I've resorted to the Split View approach.
I've got eight rows of table data on the left; RootViewController is the default UITableViewController. I'm trying to write the program such that when any of those table rows are selected, the view on the right (Detail View) gets redrawn and populated with a bunch of different controls (labels, buttons, text fields, etc.) that correspond to the selection on the left. Currently all the Details views are plain UIViewControllers.
For instance, the first "tab" might be titled "Personal", and I need to display fields to collect info such as Name, DOB, Height, Weight, etc. The next one might be "Address" where I need to collect Street, City, ZIP Code, etc. The next one might be "Employer", where I'd like to collect the employer's name, address, phone number, etc. These are mostly static and unchanging, but there are enough fields for about 8 screens worth.
I've got all this laid out in Interface Builder, but when I run it on the iPad simulator and click the very first button on the very first view, the connected delegate isn't called. I've put a breakpoint there and it's not being hit.
Is there some special magic to using simple UIViewControllers on the right side of a UISplitViewController, as far as letting them contain other simple Label, TextBox, and Button controls?
Also is there any special magic in that the framework built the original start-up code with a RootViewController.h/.m and DetailViewController.h/.m pair? Am I correct in thinking that a single detail view represents the entire iPad screen to the right of the Table View, and that to add more "pages" we need to write more files and .XIBs like DetailViewController?
Final question is how to implement the data model for this app. I noticed when the project was first auto-created, there weren't any source files for the model. (Maybe most of the predefined app types don't auto-generate anything for the model, but I understand that's a big part of model-view-controller paradigm.) Anyway these data fields on all the various views will eventually be part of a SQLite record that I'd like to save and load from storage. Where would I begin to wire all that stuff in to all the auto-generated "view centric" code?
If anyone has seen a "how to write real business apps for the iPad" website along the lines of anything like this, please post the link. I'm not trying to display jpegs of various fruits in a single (reused) view on the right side; I'm trying to display several real controls for real-world data collection for a real business app.
Thanks!
Basic things if you haven't already done them:
Have you connected the interface object the user is pressing from it's INSIDE TOUCH UP event to an IBOUTLET that then refreshes the right side?
If you have, and you've mucked about a bit (ie renaming and moving stuff around), try deleting it from the right-click event panel and then reconnecting it to the same IBOUTLET again (you don't have to delete any code).
Also, if you are counting on some event to fire that isn't firing, you should search on that (ie VIEWDIDLOAD NOT FIRING) because that can both occasionally be "broken" (ie no connection to the Files Owner) but more often one might misunderstand when that actually gets fired (ie VIEWDIDLOAD vs VIEWDIDAPPEAR vs VIEWWILLAPPEAR etc.)
For your data model, CoreData is your friend. It provides a modell-oriented approach and easily allows to persist data.
For your navigation needs, I think a tabBarController better suits your needs.
Changing the detail view from the master view can be troublesome, especially when using a NavigationController as detail view. The best way I've found is using the NSNotificationCenter.
When using UISplitview I strongly recommend to support the iPad only when it's a business requirement - there are some changes in iOs 8 that make easier to use.

Cocoa: Creating a Window with a Variable Number of Interface Elements

I've a window that will have an unknown amount of text fields, determined by the content of a remote server.
In high level terms, how should I go about this? Create a custom view or create an empty window with a backing NSWindowController and then add stuff to it when the window is opened?
I've seen the examples on the O'Reilly Cocoa book and those effectively create a custom NSView. Is this the right way to do it, 8 year later?
You probably want an NSMatrix. A NSMatrix allows you to create an arbitrarily large grid of cells.
Tables, outlines, browser etc are also options depending on your specific needs.

How do you create a Keynote-like interface in Cocoa and IB?

the app I want to create will have an interface very like Keynote, with a list of pages on the left and one page in full on the right. These kinds of interfaces are very common yet I don't know how to do them in Interface Builder.
Are there any ready-made components? Apple doesn't offer any, afaik. Or does every developer recreate this from scratch?
I only need a general idea or tutorial, no finished code.
Thanks in advance!!
If you're referring to a scrollable list of same-size thumbnails, use NSCollectionView / NSCollectionViewItem. Should be very easy: the item would just display a thumbnail image based on your document editor view's current state. In 10.6, it got some drag and drop support, if I remember correctly from WWDC '09, so you can drag-reorder your pages this way, too.
For the editor side, the collection view would only work if all your pages are the same size, as it doesn't allow for variable-sized items. If all your "pages" are the same size, though, the collection view should actually work for this too.

Resources