Records in NSMutableArray not sorted - cocoa

I am using a NSArrayController to display the records in a NSTableView. I am reading back a selected record using [recordArray objectAtIndex:[tableView selectedRow]]. This is working fine when I don't click any of the headers in the table to sort the data. When I click a header to sort the data, the data is sorted on the screen but not in my recordArray and the order of my recordArray does not match the order of the data in the table view anymore.
My recordArray is of type NSMutableArray and contains records of type BrowserRecord. BrowserRecord contains the fields name and type (both NSString and readwrite).
I've followed all the guidelines and examples found in books and on the internet and I find it very confusing that it doesn't work for me (my previous version of the code without core-data was working fine). I must be doing something very strange. Hope that someone can point me out into the right direction.

Your array controller is managing the sorted contents. Ask it for its -arrangedObjects.

Related

Uipath - How to extract A table from a pdf

Hi i have found some video and text on how to do this but they dont help with this task.
I know how to get one values but not extract a table.
I want this to get exported into a database if possible or a Excel. But i cant figure it out.
I have even tryed change the "Change reading opption"
I tryed to "data scraping" but the program just say
"This controler does not support data extraction"
And it can't be more of a table then this.
I have heard that it cant be because the structure of the PDF is bad.
Still isn't there more ways of doing this.
Unfortunately, there is no activity in UiPath to read tables directly from PDFs. (As of today.) That was the bad news. The good news is that you can get to the contents of the PDF. Either you get the data (as flat text) directly with UiPath.PDF.Activities.ReadPDFText or you have to use OCR.
#kwoxer provided a wonderful link for explanations on this topic.
I have already been able to extract data from tables contained in a PDF document. At that time, I was lucky: ReadPDFText extracted everything. The table elements were separated by tabs ("\t"). And the table header contained a word that did not appear elsewhere in the document.
Just as an idea, I proceeded like this:
Extract text from the PDF document with UiPath.PDF.Activities.ReadPDFText.
Create an array, where the elements are the lines in the document. (Split using Environment.NewLine and option StringSplitOptions.RemoveEmptyEntries)
Go through lines in a loop (ForEach) until the table header is found. (StartsWith or Contains etc.)
The next row belongs to the table as long as it contains a tab. (Otherwise the table is over.)
Split current row by tab and store it in an array: The elements of the array are the individual cells of the row.
I hope, this idea help.

Retrieve filtered data from ALV

Is there an easy way of retrieving the ALV data that is displayed when there are also filters used on that ALV?
The ALV used is an object of CL_GUI_ALV_GRID. When showing it to the user, there is a filter placed on it by default. The user also has a button that processes the data in the ALV. How can I make sure the process only works with the data that is displayed, even if the user places his own filters on the ALV?
e.g: An ALV gets created from an itab that has 10 rows, but because there is also a filter passed on the ALV, only 8 rows are showing. When pressing a button, I only want to work with the 8 rows currently showing to the user.
I have tried finding a function module for this purpose but I can only find a FM which works with the selected rows in an ALV.
EDIT: Further, there is a method called get_filtered_entries, but it only retrieves those entries that are NOT displayed. Using this will be quite time-consuming to make the translation to displayed entries. get_filtered_entries
Thanks in advance.
GET_FILTERED_ENTRIES returns a table of excluded row indices. You just have to skip those in your processing.
" Copy original table
DATA(lit_buffer) = it_out[].
" Get excluded rows
o_grid->get_filtered_entries(
IMPORTING
et_filtered_entries = DATA(lit_index)
).
" Reverse order to keep correct indizes; thnx futu
SORT lit_index DESCENDING.
" Remove excluded rows from buffer
LOOP AT lit_index ASSIGNING FIELD-SYMBOL(<index>).
DELETE lit_buffer INDEX <index>.
ENDLOOP.
EDIT: I debugged cl_gui_alv_grid a little and it doesn't seems like that a filtered version of the original table exists at all. The lines get filtered, sorted, grouped and immediately transferred into a table of cells. Looks like it is nearly impossible to get the displayed rows without a performance drawback.

Count how many times one post has been read

Is it possible to show how many times one post has been read? In WordPress there is a plug-in,https://wordpress.org/plugins/wp-postviews/
I don't know whether there is such a plug-in in Anypic of Parse to count the times?
Of course it will be nice if it can display who has read a post as well.
Thanks
I'm not sure which language you working on.
But anyway you need to create:
Array column in Parse.com
And then just make query to add his name when viewWillAppear
Now you can count the array to get integer number for views and you can display their names from the array.
Two options are;
Add a viewcount column and increment it whenever needed.
Add an actions table which consist all actions within your webpage or app. This way you can store more data(custom analytics) in it like button pressing etc.. When you want to check the viewcount you can just count objects with specific type. For iOS SDK countObjectsInBackgroundWithBlock does this job.

Delete column in nstableview that has content

I have a tableview with one textboxcolumn and 7 checkbox columns.
This table will eventually be filled with data, and at some later point i have to remove one of the columns somewhere in the middle. What happens with the array associated with the table? How should i proprtly handle this? How would you do it? Please be clear in your answer since i am a beginner!
Have you learned how to provide data to the table view? I suggest getting that working before you try to solve this problem.
There are two ways to get data to the table view: a table view data source and Cocoa Bindings.
If you use a data source, you'll need to write -tableView:objectValueForTableColumn:row: so that it works correctly before or after the column is removed. One way to do this is to base that code on the column's identifier instead of its index. The identifier is a value you set on the column in your nib (look for Identifier). This is the same technique you can use to provide the correct data to reordered columns.
NSString *identifier = [column identifier];
if ([identifier isEqualToString:#"firstField"]) {
return ...
} else if ([identifier isEqualToString:#"secondField"]) {
return ...
}
If you use Cocoa Bindings, you can just remove a column and the other columns will keep working.
If you're using an array or an array controller, in neither case will anything automatically happen to the array when you remove a column.

Core Data, NSTableView and getting Selected Row Value

I'm pretty new to Core Data and managed to get the NSTableView to show my Core Data values. The entity that the table uses is Emotes that have the two properties, Emote (string) and Usage (integer 16)
When a user selects a item, it will allow a person to copy that emote to clipboard. In order to do that, I need to get the ManagedObject of the selected row and send the Emote value in the object to the clipboard. I got the clipboard part, but stuck on the part in retrieving the data of the selected row from the data source.
What is the easiest way in getting the value of the selected row?
What is the easiest way in getting the value of the selected row?
The easiest way is to query the NSArrayController for
- (NSArray *)selectedObjects
You don't have to worry about what rows are selected; the table view will tell you what rows to copy by sending you (the data source) a tableView:writeRowsWithIndexes:toPasteboard: message.
Whatever you do in your implementation of tableView:objectValueForTableColumn:row:, you'll implement that method pretty much the same way, except that instead of retrieving and returning a single column value, you'll write (or at least promise) all of them at once, in whatever formats make sense, to the pasteboard.

Resources