Transfer values multiple text inputs to table view, add table view items as NSManaged Objects - objective-c

I am just getting started with obj-c programming and cocoa.
Here is what I am trying to accomplish and have gotten stumped on.
I have a single table view of managed objects in Window1. I have a "Add Items" button that calls Window2 that has another blank table view (AddItemsTableView) and a series of form fields a user could fill in.
When a user fills in these fields and clicks an add button in Window2, the string values of said fields are input into AddItemsTableView to show a running list of items they are preparing to add. When the finally commit the add, I would like that running list to instantiate as NSManagedObjects
Do I need to do this as a seperate entity within coredata created just for objects to be added, then transfer the objects to the new entity upon the add action? Do I need to save them in a mutable dictionary and convert the dictionary to managed objects?
It's important that the addItemsTableView only contains data for the time period the window is open. When Add is commmited, the window closes and the table bound to the core data entity in Window1 updates with new results. If Add Items in Window 1 is pressed again, Window2 is called with an empty tableview again.
I've been searching through SO and other forums for days trying to find someone attempting to do the same thing. Can anyone point me in the right direction?
Thank you so much!

Connect your add table view to the original table view via a delegate #protocol so it can inform the other on its state and enable it to react accordingly.
Of course you use the same type of managed object throughout, no interim objects such as dictionaries. When the added data is saved, you could send the object back to the original table to be processed.
(Alternatively you can save and rely on e.g. the fetched results controller delegate - but maybe that is too advanced at this stage.)

Related

Trashed list or Custom list for trashed items

Is there a way to create a trash list?
Since I need to use soft deletes on my models I really need to create that list for the user restore tem items if he needs it.
I search in the docs but didn't found anything about it
You might try creating a View in your database that represents the soft deleted (trashed) rows. Then register a resource in your app for that view. You could actually UNION a number of tables together that had soft deleted rows in them as long as you could get some common columns from each table in your view.
After you had this view and tested it out, you could hook a to this view resource and let users view these deleted items. You could then connect an action to the List such that they could un-soft delete a given row.

Share Outlook task manager custom view with user defined columns

I have created a task manager view in Microsoft Outlook which contains user defined fields as well as other Pre-defined fields in the view. I am trying to share this task manager with the rest of my team however, I cannot get it to show all of the columns as they appear on my screen on their screens. I am able to share the task manager but many of the columns are missing. It seems to be because the custom view I created isn't being shared with the other users. On my computer, the custom view is displayed and selected above "Simple list" under the Current View menu on the left and the others do no seem to have that as an option. Does anyone know how I can share the view? The tasks are already being shared I just need the View to be shared so my team can see all the columns properly. Thanks for any input you may have to offer.
Views are defined and customized using the View object's XML property. The XML property allows you to create and set a customized XML schema that defines the various features of a view.
Use the CurrentView property of the Explorer or Folder classes to customize the View in Outlook. An XML definition of the view can be exported and transferred to another PC.
Ok essentially what I did was I went to view - current view - define views and created a new view selecting Table and This folder, visible to everyone. Then I found pre-definied columns that weren't user defined columns that allowed free text typing like subject, milage, and billing information. Once finished adding all the columns I needed I applied the view. Then I went and changed the name of the columns by right clicking each column header in the task manager and selecting format column. there you chan change the label name to whatever you want the column to be titled. This way you did not have to worry with using user defined columns that can be tricky to share. After that I went back to view - current view - define views, and made a copy of the view I created selecting this folder, visible to everyone. Then you will want to right on the tasks manager name you created under the My Tasks list and select properties. Make sure to give everyone your sharing it with full permissions as owners so that they can all edit the task manager as they finish each task. Then I shared this task manager by right clicking on the name of my newly created tasks manager (listed under the My Tasks menu) and selecting "share". I checked the box in the email stating recipient can add, edit, and delete items in this tasks folder. Now everyone can see all information displayed in each column and edit it as well hope this helps.

Cocoa Bindings with NSComboBox

I have Cocoa Bindings working with a NSComboBox that shows and autocompletes values based on a Managed Object Context. My issue is trying to get the current selection after the user either selects from the dropdown or the autocomplete text is used. I know that the Array Controller class has a selected objects property, but when I try to use it to pull out the selected object I get nothing. With a NSComboBox do I have to set the selection once the text/selection of the combo box occurs or is there something I'm missing setting up the Array Controller.
Thanks
A combo box allows any arbitrary string to be entered, right? (You're not limited to the items you can autocomplete, unlike a popup menu.) So it doesn't have a concept of selected item, since the text in it might not correspond to any item in your database.
This question seems to address a similar issue, declaring it to be unsolvable using only bindings, and links to a blog post that has some hints on what code needs to be added. The gist of it is that, when the user finishes editing the combo box, you create your own fetch request in code and use the response from that to link up the model.

Adding an object to a binded NSTableView - Core Data application

I have an app that uses core data. The model of which has 3 Entities, all connected by 1-many relationships as so:
|E1|<-->>|E2|<-->>|E3|
My UI is essentially a 3-way vertical split pane, each with a tableview in. The way it works is that I have each window incrementally 1 layer down, essentially allowing the user to 'drill' down from E1 objects to E3 objects, all linked by relationships, similar to the option in OSX finder.
Each table is populated by an NSArrayController, getting it's data from the relevant Entity, and also on what is selected in the previous 'drill-down' window. This all works fine if I simply hook up a button to the addObject method of the array controller, however the new object it makes is a blank row, one that I have to fill in manually.
I have hooked up the add button to open an 'Open Dialogue', which allows the user to select files. I then iterate through the array of NSURL's returned, and add the file information to the E3 entity of the core data model. I call save, but nothing appears in the UI. I'm guessing that this is something to with the fact that the object i'm adding has no way of knowing which E2 it belongs to, and therefore isn't showing.
Is there a way to add an object to the core data model with relationships? For example, I could see what object was selected in E2, and then add the object with a relationship to this. I hope I've made this clear enough. Any ideas or suggestions are more then welcome!
I sorted this by creating an object, setting it's properties, then calling addObject:id on the array controller.
Hope this helps someone.

Insert/Remove item in listbox bound to database

I want to be able to reorder my listbox which is bound to my sql ce database by clicking up and down arrow buttons. Since my listbox is populated directly from my database using the entity framework, I think I have to delete the object (from the listbox) and reinsert it (in the row above) if I want to move the item up the list.
I have no view model, my listbox is populated directly from my database in my code like this:
listBoxProperties.ItemsSource = entities.Properties.ToList();
Does my question make sense?
Cheers
ormally you would handle the moving of your list item in your view model which would hold the ObservableCollection the control was bound to - and then that would be reflected in your control via the binding.
It is going to get messy trying to accomplish this dirrectly on the control - which is your only way since your binding to a throwaway copy of the EF properties list.
As your UI dev goes on you are only going to run into more issues like this. I strongly recommend getting a view model in place sooner rather that later.