Apple Watch Complication extension - ios

I'm creating a Complication for Apple Watch and I've came across a doubt.
For now, I've set an Array of 5 entries for the timeline, and everything is working correctly.
my question goes, what happens when the request returns nil, like after the 5 entries were displayed?
Does the Watch refreshes itself and executes all of the delegate methods again to populate the entries, or does it stops working because it hasn't more information to display since the 5 entries were displayed already?
If so, is there any way of adding another entry to the end of the array itself? When the first entry of the array has passed is there a way for me to append a new one to the end of it, so I'd get always 5 entries to display and the app wouldn't run out of information to display?
It could sound confusing, but I hope you'd get what I meant to say, hope my English is understandable.
Kind regards.

Related

Questions about ios14 widgets -- fetching dynamic data from container app

I am mainly just looking for clarification or resources. Let me explain my situation.
I have an app that internally relies on an always-up-to-date database of items. I'd like to show off items that were released close to today's date. I originally thought I'd just query my database and fetch the relevant items from there. So I began the long process of updating target values so the widget could see my classes, etc... But that was such a HEADACHE.
I thought surely there must be a more lightweight method the designers had in mind, so I then read about "app groups" and being able to pass information via saved settings/preferences. So basically when the app runs, you store some data as json and then you can fetch that information in your widget.
But then, to my knowledge, the data won't update unless the user runs the app again. I was hoping I could keep this widget up to date even if the user hasn't used the app in a long time.
What exactly is the process I should be using to achieve this? Are "app groups" basically the only way to do this? Will I just have to accept that I will often times have stale data?

Multiple queries asynchronously

I need your opinion in which do you think are the best practices to do multiple queries to cloudkit.
I've an app that has a Main feed - I query this feed when the app launches and everything works perfectly, but I want to achieve , or at least understand how it's done in the, for example, Medium app for iOS for the bookmarks tab.
In the Medium app, after the first query in app launch if you click on the Bookmarks tab, all the posts are 'already there' so I assume they query that table asynchronously after the first query.
I thought that I could do a second query , after the first 'main' one, to the bookmarks table for the given user, and fill an array with those objects, then populate the table view as soon as the user clicks the tab.
My worries are on having an array, which main contain a lot of data and it's not used, and even could not be used for a good portion of the time during the app usage
Do you think that is a good practice or that I could achieve this on a different approach?
Thanks ;)

Local storage on Rails

I've built a Rails app, basically a CRUD app for memos/notes.
A notes title must be unique. If a user enters a name already taken a warning message is shown prompting them to chose another.
My question is how to make this latency for this feedback as close to zero as possible. When creating a note little UX speed bumps like this will get annoying for user quickly.
Of course the main bottleneck is the network. Inspired by Meteor (and mini-mongo) I was thinking some kind of local storage could be a solution?
I.E. When app first loads, send ALL JSON to the client with ALL note titles. The app (front end is Angular JS) could check LocalStorage (or App Cache, Web SQL?) instead of incurring a network round trip. The feedback would be instant.
I've used LocalStorage in the past to augment an app, but in the scenario it'd really seriously depend on it. I'm not sure how confident I'd be building on something that user might not have. Also as the number of user Notes/Memos I have doubts how feasible it is to send a JSON object down the wire with ALL the note titles. That might get pretty big. On the other hand MeteorJS seems to do this with no probs.
Has anyone done something similar or have any pointers? Thanks!
I don't know how Meteor works here, but you're right that storing all note titles in localStorage is not a good idea. Actually, you don't need localStorage here, you can just put it in a JS array, because you need this data only once (when checking new note title).
I think, there could be 2 possible solutions:
You can change your business requirements and allow non-unique title. Is there really a necessity for titles to be unique?
You can verify note title when user submits form. In this case you can provide suggestions for users, so they not spend time guessing vacant title.
Or, if titles must be unique only within a user (two users can have same title for their notes), you can really load all note titles in JS array and check uniqueness while users types in a title.
Or you can send an AJAX request checking title uniqueness as soon as user finished typing the title. In this case you can win some seconds.
Or you can send an AJAX request as soon as user typed in 3 symbols. The request will return all titles that begin with these 3 symbols, so you don't need to load all the titles.

Change JSON values from iphone app (possible API needed?)

I have an app with tutorials. I also have a tab where users can suggest tutorials. Right now, the app loads a table view with an JSON array taken from my website. Every tutorial object in the array looks like this:
{"string" : "Tutorial Name", "value":1, "devices":["deviceid1","deviceid2"]}
The string is the name of the tutorial they want to see. The value is how many people have voted for it. The devices is an array of strings where I would save the device ID of each user who votes for that tutorial. This is to make sure they do not vote more than once.
Now, what I want the app to do is to change the value key to add one and to add its deviceID to the array.
How do I do that in xcode? I am assuming I might have problems with 2 users trying to change the values at the same time. Should I maybe create a small API for this? Possible create a file that would get the values for me and change them as well?
If so, how do I go about doing this?
Thanks!
If you are making changes to the JSON from your app, you are only changing the values locally. This means that the changes won't be updated on the devices of other users who are accessing the app. I think the best way to do this would be to create a small API.
1) You will need to setup a MySQL database that has keys for "string" and "value".
2) Create a PHP script that takes in a string and then adds one to the value field of the database row. This script will be called when a user "votes" for a tutorial.
3) Create a PHP script that queries the data from the database and converts it to JSON format. When loading the app, this script would be called and your app would parse the JSON data and display it into a tableview with the updated values.
Hope this sets you off in the right direction!

iOS: Store names in a plist

It's been years since I've done iOS, but I'm jumping back into it and have a quick, beginners question. When the app launches, it will launch with a search field. You type in a persons name, hit enter, and info about the name will appear. I'm thinking about storing all the most common names in a plist, and having the search run through the plist after the user hits "enter", then display info about the name they typed in. This is where I'm stuck. After you type in the name and hit enter, I have no clue about how to make it display the info about the name, or even where to store data about the name. Any help is much appreciated, thanks!
I'll give you half of the answer you need here, the "loading" and "saving" part.
The "plist" you're talking about here is actually an array of names.
And -- how handy! -- "NSArray" has both an "initWithContentsOfURL:" method and a "writeToURL:atomically:" method.
Any more than just a few names and people will start suggesting using Core Data.
Also, if you want to be able to change and/or save the names while the app is running, you'll need to use a "NSMutableArray" instead of an immutable array.
As for the displaying part, you should probably learn how to use table views (UITableView) and binding (i.e. you "bind" to the array and values get displayed based on whatever the user typed into the search field). There are lots of tutorials and examples on this, as well as related questions here on StackOverflow.

Resources