I am sure this is not duplicate question, please read completely and share your ideas.
I am getting data from server,on calling API(example API1) first time , I am getting 20 records , based on “events” count.
In Jan 5 events, in Feb 6 events, March 5 events ,Apr 8 events
But API not returning all the events of April in first call as I have to retrieve only 20 records at a time.
I second time calling API, I am getting remaining records of April month(example API2).
I have to add remaining three records to previous array to show all the April months events under same section.
I am creating a view based on the event’s array and sub viewing to the cell content, I didn't take any custom cell because of critical UI design as shown below.
In the above image, Dec 2016 created twice, as first few records comes in first call of API and next few records comes in second API call.
How do I achieve this..?
You store an array somewhere with the meaning "this is the data that I currently know about". Your tableview uses this array as its source for all its operation.
When more data arrives, you do the following on the main thread: Modify the array so that it contains the new data, then call reloadData for the view that is modified.
Now if you get data for the month april twice, then the "modify the array" is slightly more complicated: For every month arriving, you check if that month is already there; that month would have an array of data associated with it, so you add the new data to that array. If the month isn't there already, you add a new month.
Related
I have a master data sheet which is updated been updated daily bases. from the master data sheet, cases will be assigned to my staff. I am doing this using Query function with condition as staff name. from there data will be pulled to individual staff sheet where they will update about the complete status of the case in new columns. Here I am facing some issues
If cases like 1 to 10 cases are initiated. If only 2, 6, 8 are initiated to staff A for certain reasons then later if Staff A is assigned with 3,4. Then rows are aligning like 2,3,6,8 instead of 2,6,8,3,4 periodically. Can I get new data row in last row.
If staff A is assigned with case 3 but later we thought of assigning it to staff B then data is been reshuffled in updating sheet. Can we over come these situations.
I'm currently using the Microsoft Graph API to sync calendar events to my local application. On my end, I don't care to save each individual occurrence in a series, but prefer instead to just save the series master and then extrapolate out the instances of the series myself. For this reason, I am using the /me/events call rather than the /me/calendarView call.
My problem is when editing a single occurrence in a series. After editing the single occurrence, I make the /me/events call and I can see the newly added "Exception" type -- which is great. However, I don't see how to relate that new event back to which occurrence was changed to cause the exception.
For example, if I have a weekly meeting on Monday at noon, and I change today's meeting from noon to 2:00, it's pretty easy to tell that today's meeting is the one that changed. But if I change today's meeting to Friday, how can I tell that it was today's meeting that changed and not next week's? Keep in mind that I am only storing the master, and not every single calendarView occurrence.
Another example is if I delete an occurrence. In this case, the /me/calendarView call will simply not return that occurrence anymore. No exception type is generated. And the series master returned from the /me/events call doesn't change at all to indicate that a date is missing.
The format that I'm used to is something like the iCal/vCal format, where there is a start date, end date, and then a list of exception dates. Using that format, I can easily tell from the series master which dates to skip, without needing to "render" the entire occurrence and skip the exceptions. And if an occurrence is deleted, it is added to the EXDATE list and then it is never considered on rendering. Does the Microsoft Graph API not have an easy way to see these changed/deleted occurrences?
I was having a similar issue, but I think I've now realized that Microsoft does not allow recurring events to move later than the next instance, or earlier than the preceding one (at least while using Outlook calendar in the browser). So you can always assume that the 3rd event is 3rd in the series, the 4th is 4th, etc.
So as long as you know the series number, you can locate it by getting all of the instances with /me/events/[event_id]/instances?startDateTime=[start_date_time]&endDateTime=[end_date_time].
The error in Outlook Calendar when I do this isn't very clear, so maybe something else is up, but I am able to move the exception events otherwise. Unfortunately, I'm not sure if there's a definite way to know what end_date_time to use, as events can be moved indefinitely later.
Based on the response object from the event marked as an exception, you can use the seriesMasterId to relate the exception to its parent recurrence.
I am fairly new to swift development but i would like to implement limiting access to specified view controllers to once per day, ideally 3am this would reset but 12am is also fine.
How could I implement this?
Thanks in advance for any help.
When you visit the view controller, save the current date to user defaults.
Next time the user clicks a button to get to the view controller, read the saved date. If there is no saved date, or the difference between the saved date and the current date is > 24 hours, allow it.
If the difference is < 12 hours, you need to check to see if the date has changed (for midnight) or if 3 am is between those 2 dates.
To see if the 2 saved Dates are on different days, use the Calendar function isDate(_:inSameDayAs:)
To see if 3 AM has passed since the last time is more complicated. Off the top of my head, I'd probably take the current Date, Date(), and use the function
date(bySettingHour:minute:second:of,matchingPolicy:repeatedTimePolicy: direction:) to create a date for 3 AM today, if it has already passed, and then see if 3AM today is between my saved date and now.
My goal is to add +1 every day to a global variable in Firebase to track how many days have passed. I'm building an app that give new facts every day, and at the 19:00 UTC time marker, I want the case statement number (the day global day variable) to increment by +1.
Some have suggested that I compare two dates and get the days that have passed that way. If I were to do that, I could hard code the initial time when I first want the app to start at 19:00 some day. Then when the function reached1900UTC() is called everyday thereafter, compare it to a Firebase timestamp of that current time which should be 19:00. In theory, it should show that 1 day or more day has passed.
This is the best solution so far, thanks to #DavidSeek and #Jay, but I would still like to figure it out with concurrent writes if anyone has a solution in that front. Until then, I'm marking David's answer as the correct one.
How would I make it so it can't increase more than +1 if multiple people call this? Because my fear is that, when say, 100 people calls this function, it increases by + 1 for every person that has called it.
My app works on a global time, and this function is called every day at 19:00 UTC. So when that function is called I want the day count to increase by one.
You should use transactions to handle concurrent writes:
https://firebase.google.com/docs/database/ios/read-and-write#save_data_as_transactions
You may know this but Firebase doesn't have a way to auto-increment a counter as there's no server side logic, so having a counter increment at 19:00 UTC isn't going to be possible without interaction from a client that happens to be logged on at that time.
That being said, it's fairly straightforward to have the first user that logs in increment that counter - then any other clients logging in after that would not increment it and would have access to that day's new content.
Take a look at Zapier.com - that's a service that can fire time based triggers for your app which may do the trick.
As of this writing, Zapier and Firebase don't play nice together, however, there are a number of other trigger options that Zapier can do with your app while continuing to use Firebase for storage.
One other thought...
Instead of dealing with counters and counting days, why not just have each day's content stored within a node for each day and when each user logs on, the app get's that days content:
2016-10-10
fact: "The Earth is an Oblate Spheroid"
2016-10-11
fact: "Milli Vanilli is neither a Milli or a Vanilli. Discuss."
2016-10-12
fact: "George Washington did not have a middle name"
This would eliminate a number of issues such as counters, updates, concurrent writing to Firebase, triggers etc.
It's also dynamic and expandable and a user could easily see that day's facts or the fact for any prior day(s)
I'm trying to split your question into different sections.
1) If you want to use a global variable to count the days from, let's say, today. Then I would set a timestamp hardcoded into the App that sets the NSDate.
Then In my App, when I need to know the days that have been passed by, I would call a function counting the days from the timestamp to NSDate().
2) If you have a function in your App that counts a +1 into a Firebase, then your fear is correct. It would count +1 for every person that uses the App.
3) If you want every User to have a variable count since when they use their App, then I would handle User registration. So I have a "UserID" and then I would set a Firebase tree like that:
UserID
------->
FirstOpen
-------> Date
That way you could handle each User's first open.
Then you are able to set a timestamp AND call +1 for every user independently. Because then you set the +1 for every user into their UserID .child
Background info: I have a simple tally counter/habit-tracking app that populates a tableview with custom cells - the counters. Tapping on a cell brings up a detailed view of a specific counter that has the name, value, and the time period for that counter (daily/weekly/monthly/yearly/total). I have also stored in CoreData the startDate and endDate for each counter, so each counter resets after a certain time.
What I would like to do: Each time a counter resets (e.g. after a day or a week), I would like its current total value to be added to a log (preferably some sort of array) specific to that counter. This will then populate another tableview so that, after a few weeks, I can look back and see the previous weekly totals and compare it to the current week.
My data structure:
Entity: Counter
Attributes: Value (Int), startDate(NSDate), endDate(NSDate), timePeriod(Int) (Note: For timePeriod, each integer from 0 to 4 represents daily/weekly/monthly/yearly/no reset.)
My question: How can I implement this? Do I create another entity with a date and value attribute that is created each time a counter resets? I'm having trouble visualizing how to do this with CoreData.
P.S. I don't think using tableview and fetch requests is what I'm looking for.
Thanks so much for your help, and ask me if you need any clarification!
The simplest way is to not "reset" the counter but create a new one. You can then easily display the past counters. That would avoid creating a new entity.
To make it even simpler to distinguish them from active counters you could add a flag like active or archived. You could use that flag for a convenient predicate in your fetched results controller.