PHAsset - Property way to save captured PHAssets locally? (in app) - objective-c

trying to understand the concept for Photos/Photos.h framework.
my goal is:
write captured video url (or asset) to app's "userDefaults".
read from "userDefaults", & fetch each saved asset data (thumbnail & url)

Since you're not providing any code (nor asking for any), I can help sort some of this out for you -- but you need to study a bit more before you can put it all together. Especially if you think you've asked a question which has one simple correct answer.
UserDefaults is not a good place to store an image. Images are big. (You should look at Apple's documentation of what UserDefaults is for/how it's intended use).
UserDefaults
There's more than one place to store images. Do you want the system to delete them if you start running out of memory? Then it belongs in cache:
let cachesPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).last!
Do you want to depend on it being around the next time the app is run? There is a standard place for that as well:
let userDocumentsFolder = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
Do you want iTunes to back up the images for you automatically? It expects files to be in a certain place for automatic backup. Do you have a way to keep track of where it is (the path to the file can change if the app is re-run). For that you might require persistent storage, so CoreData or Realm might be an option for you. Or you could scan your directory and create a list of files you've already saved. Then you'll need a way to select the correct one. (What did you call it? Should the user select it?)
Apple has very clearly written and useful documentation on access to the Photos library and using PHAssets. Here's just one example:
PHAsset - Photos
There are a lot of talented people on this site, and they are willing to help you, but you need to do your homework before coming here.
I recommend you read these linked documents, start writing some code, and if you run into problems please come back and ask any specific question you have about any specific problem you've encountered. Include the code which causes the problem, as well as the exact error message you are getting. We will be glad to help.

Related

How can can i insert a user with profile picture using Blazor-server

I want the user to upload his picture when he registers his information.
The thing is when the user uploads his image.. should automatically create a folder with his ID to be like this wwwroot/images/UserID/fadi.jpg
Basically: you really shouldn't. The wwwroot is for static assets used by the application. You're using server-side, so in theory it might be possible but that's not what the folder is meant for. An alternative method like AWS would be preferred, but if you can't do that (either because of payment requirements or other complications) I would suggest saving the image to your database. One way to do this would be to base64 encode the image and save it that way. I'm not going to give an example of that here, there are plenty available elsewhere. One such example is this.

Need advice on creating an online contract generation system

First of all, be assured I am not asking how to write up a contract; I already have that covered. My question is how I can best program a system for generating it for clients to digitally sign?
My original plan that just seems like overkill to me is this:
I fill in all the details.
Click a button to preview it, making sure everything is correct.
Click a button to simultaneously create a directory for the client and create 3 files inside that directory.
The three newly created files are:
the unsigned contract.
a confirmation page of having signed the contract, with other details the client will need to know.
the actual signed contract that the client can now view online at any time by going to a URL such as /clients/username/index.php
I have it working, though I keep thinking it could be simplified further, but not sure of the best way to do it.
Any suggestions?
I recently helped on a project much like this, & I think you've got the right idea...
Write up the contract & preview (make sure it's right)
Have them come "sign" it
Save it
Only thing I'd change is, I'd use a DB instead of file creation. Personally, I find that simpler, but it might not feel that way to everybody. It's definitely more flexible though, 'cause you can easily generate an HTML or a PDF from the DB data, but you'd have a harder time doing that from a file on the system. Assuming you're using PHP (based on the .php you mentioned), there's a whole section of functions for generating PDF's in PHP.

Using JSON to update app's content in iOS

I'm about to create an application that uses JSON to update its content.
This is how I planned it to work:
When application starts, it checks (with internet connection is available) if the JSON file set on remote server is newer than the one stored localy - if it is then it's downloaded.
Then, the application applies data from that JSON to the content. For example, to the "Contact" information - it applies data like phone numbers etc.
My question is, is it in your opinion, a good technique to update appliactions content?
Does anynone had an experience with building app with this kind of idea?
Best regards,
Zin
Of course you can do this. One thing that may lead to a better user experience would be to ask the user for his permission to download new content (if there is something new).
This is a normal thing to do. I have a phonebook app that does exactly this. On a side note, if you need a network class to handle the web-service interaction, see this SO post. I wrote a custom network class that works with AFNetworking.

iOS 5 Newsstandkit where does it store downloaded issues?

I'm trying to figure out more about iOS 5 newsstand kit and where it stores the downloaded issues, I have read the documentation and can see that there is an NKLibrary class but cannot see any indication on how to handle the downloads or where they are actually stored.
Thanks
Ok, so NewstandKit works a little differently than you might expect. Take a look at this for the nitty gritty: http://developer.apple.com/library/ios/#documentation/StoreKit/Reference/NewsstandKit_Framework/_index.html
But, Basically during the issue download the app should be passing its (the product's) information including it's NSURL an NKIssue via [NKIssue addAssetWithRequest]. Assuming the download doesn't fail and you have done the other Newstand stuff right, the product should be saved in the properly and you do not have to worry about dictating a specific location for it to be saved.
Another reason to not worry too much about where the issues are being saved, is that Newstand will delete old issues if the device's storage becomes limited.
Hope that helps.
Never worrying about the downloads's destination might not be the best way to deal with the problem. It's true that the destination is chosen automatically when downloading an asset. However, what's saved then is just a temporary file, which must be moved somewhere else and which might also need to be processed in whatever way.
Take a look at the "contentURL" property in NKIssue. This is the location which NewsstandKit recommends as the very destination of issue-related assets.
Cheers :)

How can I retrieve the HTML to be loaded into a WebView (or WebFrame) from a local persistent store?

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.