Load only first 10 posts, then load more - parse.com - swift

I'm having a post-feed where I load my posts from a parse database. All posts are saved and loaded from one class.
Now, when the app launches and the user opened the post-feed, I want to load only the first 10 posts (sorted by date).
After that, when I'm at the bottom table cell, I want to load the next 10 posts. Can be done by pressing a "Load More" button or by scrolling at the bottom and it automatically loads more.
I use swift in xCode.
Can anyone help me with that?

PFQuery has a limit property and a skip property.
These are listed in the docs under "Paginating Results".
For the first ten you set skip to 0 and limit to 10.
For the next ten you set skip to 10 and limit to 10.
And so on...
You can read more detail by looking at the documentation for PFQuery.
To add your results to the existing results.
First have an array to store the results.
var results = [MyObject]()
Then when the results come back from parse currently you will be doing something like this...
results = theArrayReturnedFromParse
This will set the array to be only the ten from parse. You need to do this...
results += theArrayReturnedFromParse
This will add the new results to the array and keep the old ones.

Related

MS Access: Make Form show only records from last 48HS

I am using MS Access and I have a table called tblLogs, it contains all the logs and a field called logDate. I have created a form in which I need to show the data from tblLogs, but only the records from the last two days. My question is: what are my options?
I've been doing some research and tried making a query which retrieves the data I need from last 2 days, but after doing it I realized there wasn't an easy way to bind query content to a Control (a text box in this case). Another option that came to mind was somehow setting an automatic filter that is triggered when you open the form (don't know how to do it yet), but I don't know if that would be convenient.
So, I'm all ears guys
In the form properties set Filter On Load to Yes and Filter to
logDate >= DateAdd('h', -48, Now())

Iterating all rows and changing a specific value ends up in a disappearing table

I have following problem: I have a small application running where i have implementes a language switching function. Therefore i need to change the datetime columns in footable for the right date format.
My idea was to iterate through all rows, get the date value, recalculate it in the right format and write it back to the table. But This approach is not working properly, when i try it, you can see the very first row changing, and then the whole table disappears. I have attached some screen shots and the relevant code to explain the problem...
My Code (for iterating the rows and changing the value):
var ft = FooTable.get("#spiele_data");
$.each(ft.rows.all, function(i, row){
v=row.val();
var m = moment(v.sp_timestamp, 'L LT');
v.sp_timestamp=m.format('L LT');
row.val(v);
});
This is what happens:
Table is loaded and displayes properly
After changing the language => see the first line
Immediatley after that the table is gone
What am i doing wrong or is there a better possibility to change specific columns in all rows?
Best regards
Christian
+EDIT: One more thing: the $.each-loop is iterated completely. I've tested that by writing the index to the console.
$('table').trigger('footable_redraw');
You need to call redraw to see footable again

How to filter data based on a time parameter in Access?

I have a query from another thread which goes through a list of different events and pulls out the most recent event and puts it into a list. The code I'm using is:
SELECT Cleaning1, Max(Date1) AS most_recent
FROM CleaningLog
GROUP BY Cleaning1;
Cleaning1 is the column that has the different cleanings, and Date1 is the column that has the date the cleaning occurred, and CleaningLog is the name of the table. I currently have a macro in Access which is an OpenQuery, query. I am having it open the above query, and then having it view as a data sheet and it's in edit mode.
What I am stuck on, is getting a subsequent macro/query/vba code to take the datasheet the query produces and going through each item and determining if they're over due to be cleaned. I tried having a Make Table query, but the problem is, there is no user friendly way to refresh that table without having to delete it (I am having unskilled workers use this Access sheet).
I am wondering if there's a way to look at the most recent cleaning's date, what the query produces, and filter the dates out that are over due for a cleaning, specified by a parameter. I have been looking at this webpage to start playing with the notation, but I haven't been able to come up with much that is useful.
https://support.office.com/en-us/article/Examples-of-query-criteria-3197228C-8684-4552-AC03-ABA746FB29D8
Another problem that I am encountering is that each cleaning doesn't have the same time frame in which is needs to be cleaned.
Thank you in advance for any help!!
You should just be able to modify the query above to show entries with a max date lower than they should be. Below shows entries that haven't been cleaned in 30 days, for instance.
SELECT Cleaning1, Max(Date1) AS most_recent
FROM CleaningLog
GROUP BY Cleaning1
HAVING Max(Date1) < Now() - 30;

ListView: instantly updating and time comparision

I have to work on an application in which we are getting list of orders(with all details and display_time) and we have to show them in list view, but the condition is we have to show particular order on their exact display_time.
For example below are some orders with display time:
order_id: 101 |
display_time (hh:mm:ss): 09:10:00
order_id: 102 |
display_time (hh:mm:ss): 09:30:00
Then the requirement is:
We have to show the orders on list on exact their display time.
All order should come instantly as they entered in database.
Edit
The first thing that I need is:
To get the order from database (SQL Server) instantly without hitting
any API. Like push notification.
Then the second need is:
To compare the device's time and order's display_time and if its matched then make visible the order in ListView. I have to do this for each order i think.
I don't know how can I do this.
So please suggest how can we do the above task.
I hope I understand correctly. Mainly you want the list of items to be in the order of time from earliest to latest.
Here is one algorithm and it could be enhanced.
Allocate 100 (arbitrary) items/rows in the Listview.
If you only have 2 items or orders initially, make the other 98 rows not visible (state).
If a new order is entered, add the new order into one of the non-visible rows. And make it visible of course.
The issue in this case, you may have to reorder the items above the new order. However this is only a manipulation of text in your rows. A data structure is necessary to support this.
I claim this algorithm is fast. I think this is a good start.

iTextSharp - finding end of page

Is there any way to find the current page is going to end in iTextSharp. For example,
say there are some 10 records which needs two pages to be written down at the end of the first page i wish to add '(contd on nex page'). IS there a way to do this. Will finding the end of page be an answer for this or is there a way to find the line number on which writing is done, so that i can make a calculation to decide whether to add a message of my choice and proceed to the next page.
any advise is much appreciated :)
Thanks a zillion
Usually, this is done by defining a footer for the table. When the table breaks automatically, iText will show that footer. Of course: you don't want this footer to show up on the last page (after the final row of the table). That's why there's also a method to skip the last row.
This example shows you how to create a table with headers and footers. This is the link to SkipLastFooter.
Note that saying that "finding the line number" would solve your problem is wrong for two reasons:
There is no such thing as a line number in a PDF file. You have a MediaBox and you draw content on the canvas defined by the MediaBox using coordinates.
There's a way to get the current Y-position on a page after adding an object to a document. You can get the Y-position before adding a table and after adding a table, but not while you're still creating the table.
An alternative solution to the one I suggested above, woult be to use table events.
If you really need to find the end of the page, and are not using a table with a footer row that will be printed at the end of each page, you can use the PdfWriter object as follows:
var remainingPageSpace = pdfWriter.GetVerticalPosition(false) - pdfDocument.BottomMargin;
This will give you the remaining space on the page, from which you can determine what you want to do next.
If you are using tabular data however, it is much preferred to use a PdfPTable and take advantage of the footer row feature.