How do I use two NStableviews on the same interface? - objective-c

I am re-phrasing an earlier question and re-posting. I made the original question too complicated; I understand how the set up a TableView and get files to drop into it. What I don't understand is; How do I get two NSTableViews on one interface and get the contents to display in what ever table I choose? For eample, I want to drag files/folders into the first TableView, and when I double click on one, I want the contents of the file/folder to display in the second table.
Thanks

Provide the two table views with two different dataSource delegates, or, in the single dataSource object observe the UITableView address that's passed on every call.

Related

Who calls commitEditingStyle:forRowAtIndexPath?

I've got a custom UITableViewCell that allows a user to input text when in edit mode. I've noticed that on stock UITableViewCells, when I swipe left, then hit the Delete button, it's table view receives the commitEditingStyle:forRowAtIndexPath message. I'm curious where this message is coming from. As far as I can tell, individual cells don't have a reference to the table view they belong to. If I want my custom cell to send this message, how would I go about doing that? I've thought about using the superview of the cell, but it seems like there's got to be an easier way.
This method gets called automatically (if you implement the data source protocol) before adding any row or column.
If you want to know to which table view a cell is belonging, use the superview method.

Static Grouped UITableView without storyboard

I've been searching and can't find an answer anywhere. I want to a create a really simple grouped table view for "settings" of my app. User taps a button and I want to load a UITableView that has 3 or 4 cells in categories. Is there a way to just set one up in IB without the dynamic code building (ie. cellForRowAtIndexPath).
Note: Most answers I have found pertain to storyboard, which I am not using.
No, you can't. tableView:cellForRowAtIndexPath: is the way a table gets its data -- there's no way to populate a table without that in iOS (in OSX you can use bindings, but they're not available in iOS).
If you only need a few cells, are you sure you need to use a table?

Apply dequeueReusableCellWithIdentifier to a bunch of UIImageViews not TableviewCell

Im not sure if this is possible but I was just hoping to have a question answered about dequeueReusableCellWithIdentifier and if it could be applied to something other than a UITableViewCell. Maybe not dequeueReusableCellWithIdentifier exactly, but maybe something along the same idea.
I have a bunch of UIImageViews, that appear in a grid, they all have the same image, and the user can remove and add more to the grid so it is quite dynamic. But I was hoping that maybe there would be a way to reuse some of the images that the user has removed, because I'm seeing some pretty large performance issues after the user interacts with them for a little while.
Can anyone give me a little advice how I might do this?
There's no built-in mechanism, but it's not hard to create one.
Just add an NSMutableArray to your view controller. Every time you remove a view from the grid because it's moved off screen add it to the array. Every time you need to add a new view to the grid, check the array and see if there are any views in it. If there are, remove one from the array and add it to the screen. If there aren't, create alloc a new view.
That's really all there is to view dequeing and re-use.
You don't need to replicate the reuseIdentifier stuff because (I'm guessing) all the views in your grid will be the same class.
If you do need to have multiple different views, just have multiple queue arrays and use different arrays for different view types.
Why dont you create one UITableViewCell & add 2 ImageViews on them. Dont forget to add a unique cell identifier to them o that dequeueReusableCellWithIdentifier works as usual.
Something like this -

UITableViewController Dynamic Drill-Downs

In a table-view that contains say 10 cells, is it the case that we need to create 10 separate UITableViewControllers to handle the different views loaded by clicking on each of those 10 cells?
That doesn't seem very efficient - especially in situations where large amounts of data (and thus tables/menu) need to be displayed.
How can you write a dynamic UITableViewController, that can accept any data-set (like an Array) on the fly and display its contents - and do it in a recyclable manner, so that it can be recreated again and again for each cell that is clicked?
I have it mostly working in an app I'm building - the only thing I don't fully understand about the method is how the incrementing of the "CurrentLevel" works since it seems like the variable would just keep getting reset since the controller calls itself.
Anyhow, the concept is that every time someone clicks a cell, a new instance of the UITableView controller is called and a new level is generated and added to "the stack", and a navigation controller is able to track what is in the stack and allow you to browse back to the previously loaded views.

Using Custom Cell for Mac Application

Does anyone have any info on this? I'm new to cocoa, all tutorials seem to be for iPhone which uses a different view controller. Anyone willing to provide a step by step for adding labels to a custom cell? (I'm pulling from Core Data)
EDIT: It's important to note I'm using Core Data here. Many tutorials use arrays.. I don't understand why you would use that??
I'll award an answer quickly!
Zach
I'm not sure if this is going to help you, but your problem seems unrelated to your use of CoreData.
If I've understood your problem correctly, here are some steps:
Populate your NSTableView
Using CoreData, what you can do is put an NSArrayController object in your XIB document, set its mode to Entity and choose the Entity you want to display in your TableView (all of this from the first tab of the inspector on your array controller object).
Then, bind your NSTableView Content to the arrangedObjects of the array controller. You might also bind the selectionIndexes and use some sort descriptors on the array controller to order your data, as CoreData will give you a set rather than an array.
Click on your table view as many times as necessary as to select the table column in which you want your custom cell to appear, and set its Value binding to arrangedObjects too.
Set your custom cell
Finally, click on the cell of this table column and in the "Identity" of the inspector, change the class name of the cell to the class name of your custom cell.
I'll let you read the appropriate documentation to implement your custom cell according to what you want to achieve.
With the different bindings I've described, the objectValue of your cell should be the object from your array controller at the same index of the row your cell will appear on.
Please note that I've not tested again all of these steps but answered from memory... there might be details I've missed but you should have the main steps here.