NSCollectionView was introduced in OS X 10.5, and is not yet implemented in Cocotron.
I am trying to implement a small app that will allow creating properly packaged data files for an online service, which will then be uploaded by an administrator. More specifically, the user will create a collection of input and output data pairs, by dragging input and output files onto the window.
Currently the idea is that user drags a file, from the filename it's detected if it's the input or output filename (by default, input), and a view with icon and filename for input and output is added to collection view. Then, the second file is dropped on the "other" icon.
However, NSCollectionView does not appear in pre-10.5, and most of my users don't have Macs so I'll have to provide a Cocotron-built application. Not only that; I still don't fully understand KVC/KVO, and I really should understand everything that my code does. Hence, I need an alternative to NSCollectionView.
What alternative do I have to using NSCollectionView? (Any intuitive solution is appreciated, don't feel limited by the above description of my idea.)
To work with NSCollectionView, you need to not only understand KVC and KVO, but also Bindings.
There's code for an NSCollectionView clone that works on Tiger here.
I still don't fully understand KVC/KVO…
That's what the docs are for:
Key-Value Coding Programming Guide
Key-Value Observing Programming Guide
What alternative do I have to using NSCollectionView?
Make your own.
Related
As a OS X user, you must be quite familiar with the "New Documents" window when you start some Apple's apps, like Pages.
This window is so common, that I thought it must be some system-provided window, am I right?
I tried to mimic the window, and it turns out to be quite tedious. As a developer, I have to first create a finder-like browser view with list-style selection support. Also, iCloud integration is quite difficult not to mention search support.
So, my question is how can I implement this window, is there any documentation writing about this window? Big thanks!
Look at NSDocument. That is Apple's suggested way of creating document-based apps. You create a subclass of NSDocument to handle tasks specific to your data format, and the superclass handles all the heavy lifting, including iCloud support. I haven't used it myself, but I know that it handles open and save chores, so that's probably where the panel is coming from.
As it turns out, to get this window, all I need to do is to enable iCloud support in Capabilities tab of project properties page.
A little heads up: doesn't work for Swift in Xcode6 Beta. I don't know why to be frankly. And it took me a day to searching around...
So I am making an xcode application for OS X, and so far things have gone well. However, right now I am at a roadblock. My app is mostly one window, and I need that window to be created multiple times, in the way that apps like Safari, TextEdit, and all those ones have the File>New function. I am new at Xcode, and I was wondering if there was an easy way (hopefully 3-4 lines of code) to do this. If someone could explain that to me that would be great.
Thanks!
Start a new OS X project and choose "Create Document Based Application" . This will create a NSDocument subclass.
If you want to use Core Data , choose that also. This will create a NSPersistentDocument subclass.
This will give you the basis of your application with all the functionality you ask for.
Have a look at Document Based App Programming guide and NSPersistentDocument Class Reference
Whatever you do, dont try to bake your own. There lies madness.
The project template sets up the info.plist correctly to make this work.
Whatever I tell you, it won't involve only "3-4 lines of code," unfortunately.
If you're working from a non-document-based application, you'll want to factor out the code that creates your one window. If you're not using a window controller in concert with your window, you should implement one. Then you can implement an action that will create a new instance of your window controller, and so a new window. Of course, you'll need to add more infrastructure if you're interested in saving information associated with a window to a file.
Which leads me to your other option, which is to create a document-based application. The big advantage here is that, if you're interested in saving the window contents to a file, the infrastructure for doing so is provided. This involves starting over to some extent, but since you've already got the guts of your application working, you'd simply transfer those guts to the document subclass that is provided for you. You'd also need to provide to your project meta information describing the kind of document it is, including the file extension describing it.
Best wishes to you in your endeavors.
I am creating an application for Mac using Xcode 4.2, and I wanted to create a page on startup somewhat like the ones in GarageBand and Microsoft Office. The user would be able to select an option (template) and then press 'Choose' to start working with that template. The following images depict the startup (option) screens of GarageBand and MSOffice:
Please note that both of these have an interesting way of selecting an option (template) to begin.
I would like to know what kind of UI Element or special class is being used for this. I do realize that a lot of custom artwork would go into this. Please also explain how these items are used like a radio button, not a normal button.
Those are almost certainly done with an NSCollectionView. NSCollectionView can be a little difficult to work with (in my limited experience) so I would start by looking at the docs:
Quick Start for Collection Views
NSCollectionView Class Reference
And then at some tutorials:
NSCollectionView Tutorial for Dummies (Xcode 3.1.3) (A little out of date but still helpful)
Adventures with NSCollectionView
I notice that Mail.app, iTunes and even Finder have a similar template, with a various columns, but often, a left Column with "folders" and "files". Is this a sort of standard template, that I can use so as to not reinvent the wheel?
Thanks!!
No, Apple does not provide a control that acts like a finder window, etc., although it is a common request and you might want to file a bug report at http://bugreport.apple.com making this request...it would help push them along to provide such a standard control.
However, there are several controls that implement various aspects that you may want to take a look at like NSTableView, NSOutlineView, NSCollectionView & IKImageBrowser.
Although, to get everything you want, you may have to reinvent the wheel. I have generally found these control hard to customize if they do not provide everything you need out-of-the-box...but they do provide a lot out-of-the-box.
Nopes, but you can create your own templates so you only have to reinvent the wheel once.
By the way, you can decompile nibs from some applications by copying two files from an empty nib into them.
By the way, if you decompile Finder's nibs, you see that they are very messy and the sidebar is in a separate nib. I guess they are combined programmatically.
By the way, iTunes uses Carbon nibs while Finder and Mail use Cocoa nibs.
By the way, Mail is soon to be replaced with a new version that has a totally different lay-out.
I am a newbie in Mac application development. I want to write a GUI application in Cocoa using Interface Builder. I want multiple screens i.e. when one button on a screen is clicked, another screen should be displayed. How can I activate a new screen at button click event?
I would heartily recommend Aaron Hilegass's book Cocoa Programming for Mac OS X. It took me from feeling like everything was impossible to being relatively competent in the space of a few short weeks. I was very impressed with it.
Apple's documentation is amazingly good, but it takes a while to get used to the style, and you will need to know which objects actually exist before you can look up how to use them, which is where Aaron's book comes in.
Your library may have a copy of it, or be able to order one for you if they don't.
I think you mean windows, not screens. Screens are the displays (monitors) on which all the user's windows from all the user's applications appear.
And I second Jonathan's recommendation of the Hillegass book.
The button has a target. That should link to the new window. As its action you can tell the window to show itself.
Take a look at:
http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/WinPanel/WinPanel.html
I think what you want is the type of interface like that seen in Coda, or System Preferences where there is a toolbar on the top of the screen that can be used to select between the content of the window.
The simplest method I have found is to use BWToolkit.
Another method is to use a series of views, and switch between them when the toolbar is clicked. I've found one description here, but that's not the one I used first (which may have been originally in Ruby Cocoa, IIRC).
NSTabView.