NSSortDescriptor/NSPredicate to organize my tableView - iphone

i have a table view. In the table view, there is a custom UILabel, And each label with have a letter. "A, B, C, D" etc.. You can hit a plus button on the nav bar and it bring you to another view controller to enter info, and you hit save, and it adds the row onto the table view. Is there a way to utilize NSSortDescriptor/NSPredicate to make all the "A"'s together (together meaning i want all the cells with a to be with each other, but i still want them in the same section. ) if that makes sense! Is there a way to do this? Im using Core Data to save all my information. Any help is appreciated. Thanks in advance

I assume you are using NSFetchedResultsController. If not, please refactor and do.
The section grouping is anyway taken care of by the key path during the initialization of the fetched results controller with the argument sectionKeyPath.
As the sorting does not change, simply add a sort descriptor to the fetch request before initializing the fetched results controller:
fetchRequest.sortDescriptors = #[[NSSortDescriptor
sortDescriptorWithKey:#"textAttributeName" ascending:YES]];
where textAttributeName is the whatever you called your A B C label attribute in your entity.

Related

Adding a full width row to a CollectionView two-column structure

I created such a structure with CollectionView, there are two items in one line. The whole structure should go on like this, everything is fine until here, but I must add (only 1) slide at the top. So I want to place one more full width image in 1 line. What path should I follow?
An image of my app
If the full-width image that you need to display is just a first item of the data set you're displaying, make the collection view return a custom size for it based on its index path. In order to do it, assign a delegate to your collection view and implement the UICollectionViewDelegateFlowLayout protocol, specifically the collectionView(_:layout:sizeForItemAt:) method. Alternatively, if you're targeting iOS 13+, you can do the same with the UICollectionViewCompositionalLayout, but the implementation will be different, in that case I encourage you to read its documentation.
If the item doesn't really belong to the data set, better create a section header with just that item inside.

How to count element of one controller into another

i've a question to ask for my mvc project...
i have two controllers: Giurisprudenza e GiurisprudenzaNode, these controllers implement an index with the list of elements and a crud system to add/edit/remove elements. In the Girusiprudenza view page every element has a button that return you into the relative GiurisprudenzaNode page, with the list of elements contained into the primary element.
I would like to insert a label next to every element of the list in Giurisprudenza that say how many elements there are into that single primary element, but i don't know how to do that count... Anybody can help me?
for this you dont need two controllers or two different view .
For this you need to follow below steps.
Create a viewModel (Customize mix of both models)
add custom property in you this viewmodel for counts
create new view for this ViewModel class .
Let me know if you need code snippet for this.
View Model from MSDN

is it possible save data from different view controller and show it at same tableviewcell?

my project have A table view controller & B view controller.
A have name, company & phone number need fill in.
B just have job number need fill in.
I expect when I finished A then click next button then go to B page.
and B page had save button, it can save A & B user info (core data)
I expected "777777"(Job number) will show it at same table view cell
enter image description here
Thanks all!
What you should do:
Save info like name, etc on ViewController A in a dictionary.
Pass it to viewController B while pushing it over stack.
In B ViewController modify existing dictionary that you passed from A VC and append new key - job number in it.
Then simply save it using core data.
Check it out for core data.

NSTableView with custom cell view and NSArrayController bindings drawing a blank string

It took me forever to figure out how to set up editing on a custom cell view for an NSTableView. Thanks to StackOverflow I figured that much out. P.S. I was doing all of this in Interface Builder.
I have a single column table in which the cell is a custom multi-control NSTableCellView, with:
name (in bold)
description
detail
It's all text. Set up editability on the name only. The table is sorted by the name.
When I edit the name, it has the effect on the bound model that I expect. The table even re-sorts correctly. However, it's displaying incorrectly. The description and detail (not editable) still show up correctly, but the name (which was edited) is a blank. When I inspect the model, it has the correct updated value. But the cell view itself is incorrect.
This doesn't happen all the time--it typically happens if the cell is re-sorted to the top or bottom of the table, but that may be a red herring and may instead have to do with NSTableView cell caching or something.
I hacked up a workaround in which I assign a delegate to the NSTextField (automatically generated for the NSTableCellView) and intercept the textShouldEndEditing event. For some reason this event is getting triggered twice for a given edit (after I press "enter" in the text field)--once for the actual edit where fieldEditor.string is different from the model name, followed by another event where fieldEditor.string is the same as the model name. If I return false for my textShouldEndEditing handler in the latter case, then the cell contents end up being drawn correctly. That's the hack.
I feel like I'm doing something wrong here though, and that shouldn't be necessary.
Is the textShouldEndEditing event supposed to be fired twice?

Hoe put searchbar in each component of UIPickerview? and how perform searching in each related SearchBar?

Actually i used the pickerView for display My database value containing Name, SSN, Research Area etc. Now I need to search in each component of pickerview, like Name,SSN using SearchBar is it Possible?
If I understand you right, you want to filter the rows of the components when the searchtext changed.
You can have a NSArray for each component to populate it with: In – searchBar:textDidChange: you can check which entries in your arrays fit to the search text and add it to a array, that you will use to fill the picker. Don't forget to either call [aPickerView reloadAllComponents] or [aPickerView reloadComponent:i], this will tell the picker to draw itself again.