I have an array of images that I download from the server. I need to cache them, and then bring them back to the controller from cache . How correct is this done? After NSCache takes only 1 object with a key ? We'll have to generate a key for each photo? I want to understand itself without libraries.
Related
As of now, my app contains an array and the user can manipulate the order of items in it by dispatching actions. I'm using redux persist and even if I directly change the array elements by editing the source file, the array does not update unless I clear the app cache.
What are my options to update this kind of persistent data after I publish it to the store without forcing users to clear the cache?
What are you looking for is migrations.
How it works:
Load user's previous state from local storage on app start
Update fields you need
Here is a setup example
We wanted to index our app contents (dynamic) in search engines and don't have web application. I got to know about branch Firebase App Indexing feature which seems to be perfect match for us however I am unable to understand following even after going through documentation :
Our content(coupons/offers) keeps changing every minute and hence our data is highly dynamic. How can we index all of our data existing + data which keeps getting added in our DB on regular interval.
How does whole thing works as in do we need to create Branch Universal object & branch links for all the content there in our db & if yes how can we do it incrementally rather than doing it whole thing again.
Do we need to use some API for links/object generation which we can trigger via cron jobs to generate objects & links for all the data there in the DB once daily.
If I understood documentation correctly once links/objects are created branch will automatically create internal sitemap & submit it for indexing to google without us to worrying about it right?
Unfortunately, you cannot index content directly from your DB. The best way to go about this is to have a reference to the content that you'd like to index on the app and create Branch Universal Objects to automatically index the content. For instance, whenever a user applies the offer/coupon, you will have a reference to the coupon/offer on the app and you can create a Branch Universal Object for the coupon/offer to be indexed.
Yes, you will need to create Branch Universal Objects for the Firebase App Indexing to work. One way to do it would be to create Branch Universal Object for every content that you users view. For instance, you can place the code snippet to create Branch Universal Objects on the viewDidLoad() method of offers/coupons page of your app. Thay way, all the offers/coupons viewed by your users will automatically be indexed.
No, we do not provide an API for object generation.
Yes, once you create Branch Universal Objects on your app, your app will be included in our nightly job to automatically generate sitemaps. These sitemaps can be scraped by Google, and all of the included links can then be indexed. Please note that Branch can only submit the sitemap to be scraped by Google. Once the sitemap is submitted, it is really beyond Branch's control to have Google scrape your content.
To start, this is not a question on regarding how to search or parse using UISearchBar in a UITableView.
I have already set up everything, the parsing, viewing, etc.
My question is, what is the right way to search?
My current flow is:
Parse the XML.
Add everything in an array.
Display the array in the table.
User input search.
Parse the XML again using the search input.
Add everything to the same array.
Display the array in the table
Is this fine? will this not be slow when it is on a real server? is it doing too much request?
OR this would be a better approach?
Parse the XML.
Add everything in an array.
Display the array in the table.
User input search.
Search the array.
Create a new array and add the searched items.
Display the new array.
Thanks!
Technically both the approaches are fine. However, as far as the performance is concerned, it is usually advisable to avoid repeated calling of the web service. Unless the data of your web service is changing, it is preferred to save the data from the web service in some variable (array in your case) and then use this array to access the web service data again.
Therefore, I would suggest that you should use the second approach. I will be computationally less expensive.
If I have a bucket with hundreds of thousands of images, is it ok to have to search for each image I want to display in my site via it's ID or is there a more efficient way (including having multiple folders in a bucket maybe)?
I was also thinking of giving each image a unique hash or something similar in order to stop duplicated names in the bucket. Does that seem like a good idea?
You just link to each image using normal urls. for public files the urls are in the format:
http://mybucket.s3.amazonaws.com/myimage.jpg
For private urls, you need to generate a url (which is easy using any of the sdks) in the format:
http://mybucket.s3.amazonaws.com/myimage.jpg?AWSAccessKeyId=44CF9SAMPLEF252F707&Expires=1177363698&Signature=vjSAMPLENmGa%2ByT272YEAiv4%3D
There's nothing wrong with storing each file with a unique name. If you set the correct headers on the file, any downloads can still have the original name. eg Content-Disposition: attachment; filename=myimage.jpg;
For listing a buckets contents you would use the APIs GetBucket command. I find it easier to use the SDKs for any access via the API.
It can be a pain to search or do things in parallel over bucket objects as amazon lists everything lexicographically (the only way currently supported). The problem with using random IDs is that all of it would be written to the same block storage and you cannot do search in parallel to optimize.
Here is an interesting article on performance improvements. I use it for my work and see significant difference in high load.
http://aws.typepad.com/aws/2012/03/amazon-s3-performance-tips-tricks-seattle-hiring-event.html
So, I have a bunch of HTML is being stored in a SQLite database, and they link back and forth amongst themselves. When a user clicks to follow a link, that request needs to be serviced by pulling the appropriate HTML out of the database. This could result in needing to load images, which are also being stored in the database (this is a future thing; there are no images yet, but I'd like to be able to use them). I've looked through the WebKit documentation, but can't quite figure out how to make this happen. I've mostly looked at WebFrameLoadDelegate and WebResourceLoadDelegate, but I didn't see one that would let me catch the request, grab the appropriate content, and then send that in a response.
Ideas? I'm pretty new to Objective-C and Cocoa, but I think I'm mostly getting the hang of things.
How do the pages which are stored in the database link to each other? It is probably easiest if they use some sort of customer URL scheme to start with.
The approach I would use is to implement
-webView:resource:willSendRequest:redirectResponse:fromDataSource:
in your resource load delegate. If the request is for a resource that is actually located in your database, return a new[1] NSURLRequest which uses a custom URL protocol which points to the database resource:
x-my-scheme:///table/row
[1] Unless you are already linking amongst your resources with the custom URL scheme - then you can skip this step.
Then, implement a custom NSURLProtocol for x-my-scheme which knows how to retrieve the data from the database. The PictureBrowser sample gives a simple example of how this is done.