I am working to a window with multiples NSTableView (in my case 8) and I am not sure if it's correct what I do.
My screen look like printscreen : custom window
In principle my window it's a Master - Detail Interface a selection of table from the left must populate the right table.
Until now I succeded to populate all the tables from the left with help of cocoa binding - NSArrayController which contain custom objects but further I don't know how continue, obvious in my mind it's to implement delegate method for NSTableView: tableViewSelectionDidChange:notification but this require more glue code.
My question if it's possible to populate the right table with help of cocoa binding without glue code. I read documention and I tried with selection proprety of NSArrayController but all my attempts failed. Any suggestion?
Related
I am a new learner, I am doing an assignment, stuck on this point. My target is when user click on a cell inside collection view, I have to go on table view and pass data to it (Which means that table view will have only one cell with data for selected collection view item).
I know I will go to table view programatically not possible through storyboard(If possible let me know) by using delegate method didSelectItemAtIndexPath
Can you explain the way to open table view from collection view cell click and how I will wrap data to pass to other controller (I think Segue? But how if we cannot use storyBoard). I am not getting clear there is no much help on internet in objective c? If you provide some pathway it will be good and if you explain it would be excellent??? Any helping material will be a plus
I am using XCode11 with objective c and not using XIB files Just working by storyboards
I also think segues is the way to solve your problem.
Set up the segue in storyboard and then inside the didSelectItemAtIndexPath set some variable with the data you want to pass and use performSegueWithIdentifier:sender to kick off the segue. Then override prepareForSegue:sender to transfer this data to the destinationViewController. You could use the sender to transfer the data from perform... to prepare... as well but I suggest for now just use some instance variable.
still learning iOS development, want to create something like mention friend likes in Facebook / Instagram.
Mention People UI in Instagram
Is it using new TableViewController and add subview to the same View Controller? (in this case, CommentViewController) , but, when i already have UITAbleViewController in my CommentViewController, how can i handle the second tableviewcontroller?
Looking at the image you provided it looks as though the best way to implement this would be a UIViewController that has a UITableView added to it. Each tableview that is created can have a delegate and datasource set for it. When the textview detects that a mention is being entered (more about detecting this later) you would trigger a second tableview to appear as an additional view (subview) that overlays your current tableview (or as the accessory view of the keyboard, the way apple and others present a textview over the keyboard for text entry ex: messages app).
In order to manage the two tableviews my suggestion would be to create two additional classes each of which conform to the UITableViewDelegate and UITableViewData source. The first one would be the CommentsTableViewManager and the second would be the MentionsTableViewManager. The first tableview would set the CommentsTableViewManager as its delegate and datasource while the second would use the MentionsTableViewManager.
The other problem you may run into later on is determining how to properly detect mentions being typed into the textview. I've actually created an open source library that will help you with this problem. It's located here: https://github.com/szweier/SZMentionsSwift the README should provide enough information for you to get started if you choose to use it.
I hope the information about helps get you started with your app.
From architecture prospective it's way better to have a single table view with altered data source container, depending on current mode.
Speaking an instagram way - either you're showing comments, or, if # symbol was detected, displaying a list of users. So almost all your UITableView's delegate and data source methods will start with something like if (isMentionMode) and you'll choose specific cell class/cell's height/amount of rows per section/etc depends on isMentionMode state.
Im new to IOS developing and i would like, as one of my start projects to learn more about table views. I would like to fill a table view up and then be able to handle clicks on them, to open a webpage etc. Does someone know a good tutorial or code for this?
Thanks!
What you want is the UITableViewDelegate documentation.
Specifically, tableView:didSelectRowAtIndexPath:. You can then lookup the cell at the given indexPath and handle it accordingly. More info on delegation can be found in the docs if you need it, but you'll want to implement methods like that in the object referenced as the delegate of your tableView
I just started playing with the UISplitViewController - I've cobbled together some code from various tutorials, but I'm having trouble seeing how to send data from the Master to the Detail. I'm creating an RSS reader just to illustrate to myself how it should work. I've parsed an RSS feed and populated the MasterViewController with a UITableView, but I'm stuck figuring out how to take a row click and load the corresponding article in a UIWebView in the detailViewController. Any tips are appreciated.
A good approach is to use delegates. That allows one view to call a callback provide by the other. In this case the detail view relies on the master existing so having it callback is fine. I would avoid letting them have direct references to each other and reading each others data directly.
What exactly does delegate do in xcode ios project?
Here's a tutorial with UISplitViewController that does just that (delegate between master/detail):
http://www.raywenderlich.com/1040/ipad-for-iphone-developers-101-uisplitview-tutorial
Specifically this section:
Hooking Up The Left With the Right
Time to play matchmaker and hook
these two sides together.
There are many different strategies for how
to best accomplish this. In the Split View Application template they
give the left view controller a pointer to the right view controller,
and the left view controller sets a property on the right view
controller when a row gets selected. The right view controller
overrides the property to update the view when the property is
updated. That works fine, but we’re going to follow the approach
suggested in the UISplitViewController class reference here – use
delegates. The basic idea is we’re going to define a protocol with a
single method – “selectedBotChanged.” Our right hand side will
implement this method, and our left hand side will accept a delegate
of somebody who wants to know about this.
Another approach would be to have a shared model - sort of like a singleton with notifications to trigger different views to update themselves based on either the data from the notification or querying the model in reaction to a model changes. This is sometimes better in an app with many views that don't rely on each other and just bubble up data in various ways (which is not the case here - the detail view relies on the master existing so a delegate is fine).
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.