34 thoughts on “Cocoa Programming L20 – NSTableView Bindings”

  1. @ichrisgodwin In this tutorial it will delete the row selected. You must have done something incorrectly if doesn't delete the row you have selected.

  2. @AppleProgramming I don't doubt that … i got the data core example to work correctly. i will go back and double check my work. Thanks for you work. these tutorials are awesome!

  3. We really rarely use NSMutableString. What we prefer to do is just create a new NSString object and then set that as the new one it's more efficient than having the mutable subclass.

  4. Is it possible to link add and remove assignments actions to a custom menu item in MainManu,xib without loosing functionality of remaining menu items, i.e. about, file open, etc? Thanks

  5. As long as you leave the current items in the menu bar, you can add whatever items you want and link them up.

  6. The trouble is I can't link it. Let's say I have new menu called Assignments and 2 submenus – add and remove. Add and remove actions are in array controller as it is shown in your video. The menu items are in MainMenu, which is separate nib file. I can change File's owner on Document.xib and cant figure out how to link them.

  7. Right, never thought about the fact that these are documents. I'd have too look into this. I know there are validation methods for items in the menu bar (User Interface Validation Apple Doc). However, I'm not sure if you could add targets and actions with this. I'll have to get back to you on this one.

  8. I'm almost positive this would have to be a Responder Chain type of problem (although enabling/disabling menu items would be different). By sending things down the responder chain, you could tell the document to perform some action which in turn could tell the array controller to add a new object. I haven't covered working with the responder chain however so it may be a little confusing. There are lots of articles on it though if you try googling it.

  9. I've searched a lot, read apple documentation, reviewed various examples on stackoverflow, etc … but my knowledge of objC (well actually any programing language) is very limited as I am trying to learn it by myself from scratch, reading books, watching tutorials, etc … and looks like I missing basic understanding of file's owner and responder chain concept … anyway, thanks a lot, your tutorials are the best available on youtube and internet in general.

  10. I might very well explain the responder chain after I get my NSCollectionView video out (aiming for this weekend). You'll learn it one way or the other 😉

  11. Hi Lucas, how can we control table views headers colors and fonts and heights.
    Also how can we undergo rows conditional formatting, for example is it possible to have the row background changing based on user input data so if a cell value in the row is 0 the row color (or cell color) become red for example, and if 50 it becomes blue and so on.

  12. If you look up the NSTableView class reference you can see what is available to change directly. You can directly change row colors and heights, not sure about the headers though, you may have to create a custom object for that.

  13. Lucas, question please, I tried to filter the assignments mutablearray by
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name == 'Student1'"];
    [assignments filterUsingPredicate:predicate];

    Could you please clarify what's going wrong? I have put this code with it's IBAction in the document class, is this the cause of the problem ? shouldn't the arraycontroller feels there is a subset of data and inform the tableview to reload without my intervention ?

  14. Great to hear I'm helping someone out :). I'm not sure exactly what you're trying to accomplish, but just so you know, NSTextField sends it's action to whatever target you have for it when you hit return. So if this helps you at all then try that out.

  15. I got the program to work following your tutorial, however one thing bothers me. In your video when you ran it at the end your document window appeared automatically. For me I had to go to the menu and select 'new' for it to bring the window up. How did you make it show the window automatically?

  16. This means that your function or method that you are implementing is supposed to return something but you aren't returning anything. As the error suggests, you reach the end of a non-void function (a function that returns something), but don't return. For this tutorial, you probably just missed a return statement somewhere.

  17. hi, i want to know how to reload the table? i call the method reloadData , but the table no reload! thx for you video.. i like it…

  18. Um, it should assuming everything is setup correctly. When using bindings you won't really need to reload the data manually since it's handled by the NSArrayController.

  19. Hello,
    is there someone who can help me with Chapter L20 ? When I run it under Xcode 4.6 I get a crash which this stack trace:

    2013-03-13 18:21:35.034 L20[10538:303] An uncaught exception was raised
    2013-03-13 18:21:35.035 L20[10538:303] [NSApplication 0x1001210f0 valueForUndefinedKey:]: this class is not key value coding-compliant for the key assignments.
    2013-03-13 18:21:35.040 L20[10538:303] (
    0 CoreFoundation 0x00007fff978f70a6 __exceptionPreprocess + 198

  20. Hi,thanks for your tutorials.. but how can i really save the data?? because i open the app and add grades close it and it doesn't save anything, im trying to make a database of clients for my invoices proyect. thanks for your answer

  21. …or your close bracket on your init if statement is after the return instead of before it. I do that all the time.

  22. Hi Lucas… Many thanks for your vids. I followed your tutorial for the NSTableView which doesn't follow the bindings, and I created a table that has a column that calculates a salary after a raise. What I did there is that for this column I made an exception for identifier so that if the identifier is "raisedSalary", the Value is calculated from an equation like:
    raisedSalary = initialSalary*(1+raise).
    With the bindings, I can't figure out how to replicate this… Any Help? Thanks

  23. To put my last question differently: What is the way to have dependent variables (or attributes when one uses Core Data) and have them in NSTableView. In the table you want one column (attribute) to be calculated automatically. How can one do this?
    Many thanks indeed.

  24. NSArrayController is really nice and powerful. I have documents where each row is an object with a few properties, which I show in an NSViews-based table with custom graphical sub-views that act as controls. Binding these is tricky. I'm guessing KVO is applied on the visible rows automagically, so my views will just get signals to draw as properties change. But I need some extra glue to signal changing values via clicks in these custom views, by making them into custom controls I suppose!

  25. Check out the topic of getters and setters. Bindings use getters to get and compare values, and you can implement a getter as a custom method. Stackoverflow question number 6327448 addresses this topic pretty well also.

  26. I have a simple doubt, I have a pre-populated array and how does this entire thing works in that case? I have tried adding objects to the array, but it crashes. Then I looked around and found that it is not KVC compliant. I would appreciate if anyone can help me in this scenario.

  27. Hello, I enjoy your videos pretty much and have learned a lot from them. Thanks for all the support you bring us. I'd like to ask you a simple question, can I bind a CheckBoxCell (inside a table view) to the tableviews selection indexes? I'm making a core data app, and otherwise I have to create an attribute called selection in the entity to select it. Thanks

  28. Hey, this is AMAZINGLY GOOD CONTENT, just a quick question, when i set a a table column to NSPopUpButtonCell, i get errors that are confusing, i have been trying to figure out the cause and have found lots of various reasons, but ultimately i think i am just binding everything to the wrong places, i have a 2nd table (people) with name+age and then in the first table i use person+car, i want to select the person from the people table via a popup, it is all pretty simple but i am obviously missing something fundamental here, i presume i don't want to change the person item to an nsobject as i want the nsstring of the name or maybe i want a reference to the item so that if it changes in the 2nd table it is represented correctly in the first table… not really sure, would love to hear what is the right way to do all this. thanks muchly

Leave a Reply