Equivalent of .Net Data Repeater in Cocoa - cocoa

I'm a total noob to Xcode and Interface builder. I'm on version 3.2.3 and OSX 10.6.4.
What I'd like to know, and haven't been able to find out, is how to display a list of n items. Using .Net, I'd probably use a Data Repeater control and then use that to repeatedly populate the controls I'd like to display.
Is there an equivalent or am I going about things in the wrong way? I don't see anything in the IB controls library that is quite what I'm looking for.
Any help is much appreciated, even a direction to a relevant tutorial or something.
Regards,
Iain

I guess you are looking for NSTableView with it's DataSource (ArrayController or equivalent) and it's delegate (for defining N items)?

The most common view for displaying lists is NSTableView. There are many, many tutorials on the web... Just google 'nstableview tutorial' and take your pick. :-)

Related

Looking for a spreadsheet-like control for Cocoa

I'm looking for a grid view / table view / spreadsheet-type control for Cocoa and can't seem to find anything that's in any reasonable state.
I've tried using NSTableView but it's not really meant to be a single cell control.
NSCollectionView doesn't seem to be right either.
Any ideas?
While Matt Ball's spreadsheet view (https://github.com/mattball/mbtablegrid/, mentioned above) is several years old, it does still compile on El Capitan. It must be easier as a starting point than working from scratch. There are several forks of the repository, most notable this one that does seem to be actively developed:
https://github.com/pixelspark/mbtablegrid
It seems like it would be better for those interested to pool contributions than create something new!
We now have NSGridView, which is most likely what any future person reading this will want to use.

Custom NSDatePicker graphical calender-like pickers

For example, I wanted to have a popover or something that would let me choose from a table (say, like the periodic table, IPA chart, etc.…) in a similar style as a graphical NSDatePicker. In addition, how could I make it select multiple cells at once?
Is there already a default Cocoa way to do so? If not, from what class could such a thing be done and maybe some pointers on from where to proceed?
(I apologize if this is another common question, but I couldn't find it on my own.)
It is very surprising, but on a lot of points, I think that OSX's GUI is very limited unlike iOS.
So, I'm afraid that you have to create your own component from scratch.
Or you can have a look at these open-source controls written for OSX :
For choosing a date : You can use MLCalendarView (Calendar-OSX) available on Github.
For displaying a TableView, with multiple selections (very similar to UITableView) : you can use this great open-source component : PXListView available on Github.

JAWS, Accessibility and VB6

I am just beginning to learn about accessbility specifically in relation to JAWS - so newbie alert!
I am looking to modify an old vb6 app which has a form with a 3 column flexgrid. There is a custom edit box which is overlaid on the form for editing in the right most column. On row change, ideally JAWS needs to read the contents of the 2 leftmost columns on that row.
I am wondering how best to implement this?
I have seen possible solutions of loading into a text file and shelling out to JAWS on a row-change type event. This seems a bit heavy but maybe it is a good solution.
I have also read about the IAccessible interface. This sounds like a good solution to me, but I don't know if it'd give me what I was after ie whether JAWS uses this interface to get its info.
I would be grateful if someone could advise me/steer me in the 'right' direction about the way I should be thinking about this.
Visual Basic 6 is unsupported by Microsoft many (12+) years ago. It doesn't have any easy way to incorporate MS Active Accessibility (MSAA), the previous versions were missing support in many of the default graphic widgets, and many controls did and do not have keyboard access.
Don't use it is the best answer, but not to your question. If you must continue, you'll have to look at the MSAA route (you are headed in the right direction with IAccessible interface)

What is the benefit of Xcode's seemingly over-complicated control/outlet workflow?

I'm new to Objective-C, Cocoa, Xcode and Interface Builder. I've got some C background in the past, as well as a fair amount of RealBASIC experience.
I'm working through Mark and LaMarche's iPhone 3 Dev book and I'm really just sort of stunned about how tedious some things are. Maybe someone can shed some light on this for me. My question really is, why does the process for seemingly simple actions involve such a complicated number of steps? Is there a benefit to the complexity which I'll come to love later? Or is it just a brute fact that is unavoidable?
For example, in RealBASIC, if I want a slider's value displayed in a text box, I simply add:
myTextBox.text = mySlider.value
to the slider's Changed event. I can program this in well under 1 minute.
In Xcode/Interface Builder, I have to physically type a declaration for both the text box and the slider, then type a property/outlet declaration for each as well, then create a method declaration and implementation for the ValueChanged even, then set up a (relatively) complicated typecast of the slider's integer value into an NSString using initWithFormat. I then have to return to Interface Builder to link up the controls with the control and method outlets I typed in. I don't see how this can be done in much less than 10 minutes. Maybe 5.
So, what's the benefit of this? Why doesn't Interface Builder automatically create, or at least suggest, control declarations and #property statements, as well as method declarations and implementations? Why can't double-clicking a slider in IB offer you a list of events and offer to automatically insert a skeleton method into your .h and .m file? And why does IB even have to be a separate application?
I'm willing to accept that some of this is my unfamiliarity with all things Xcode, but is this really as efficient as the development environment can be?
My apologies if this is a dead-horse, flame-bait topic with opposing sides on full aggro. If so, please just say "yes, that it is" and move on.
Thanks,
-Rob
A lot of the reasons behind the way IB works will become more clear as you get used to the MVC paradigm.
Once you start using Cocoa Bindings, which update your model when the UI changes and vice versa, you should see an enormous productivity improvement.
I too used to think that Xcode and Interface Builder were unnecessarily complicated, until I worked through a book on both (specifically, Beginning iPhone Development: Exploring the iPhone SDK).
If you're serious about working with Xcode and Interface Builder and are as confused as I was when I started, I highly recommend picking up a book like the one I used. Granted, that was for iPhone development, but I think there is another book by the same publisher (or author) that is straight Mac programming.
Once you work through it and understand what is going on behind the scenes it starts to make a lot more sense. In some ways I prefer IB to things like Expression Blend or XAML for WPF programming in .NET.
Give a book a try and see if it helps :-)
Good luck!

Is there a simple way to combine a text and icon in an NSCell in Cocoa?

I'm trying to create a very simple selection list widget based on NSOutlineView. However, I'm having a hard time figuring out how to display an icon and a label right next to it, which is really the expected behavior in all the mainstream implementations of that kind of widget out there (iTunes, mail, Finder,...).
So far I am just binding two separate cells, but then when I'm expanding the tree, the icon cell grows larger and a gap appears between the icon and its accompanying label. I know I can probably overcome this problem by extending NSCell and provide a custom class, but as what I'm trying to achieve is really the standard thing, I can't be resigned to accept that there isn't a simpler solution.
Candide
Sadly, there isn't a 'text and icon' cell that you can just use, fresh out of the box as you would like. However, when I was working on a project, I found that Apple released some sample code that implements this, since it is such a common idiom.
This can be found here, specifically ImageAndTextCell.h/m
It can help teach you about UI customization by reading through this example, but scratching that, just dropping the ImageAndTextCell straight into your project should do just fine.
You need to create ImageAndTextcell to combine text and icon..
you can create ImageAndTextcell like this Sample Project

Resources