Where to save video on iPhone? [closed] - ios

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
My app is recording video and creating other documents and meta data - looks like all the Apple docs and other code refer to saving it in photos album or camera roll [are these two different?] using AssetsLibrary - would this not mix up all my app's videos with the rest ?
I cannot find either Apple or any book that gives best practice to store custom media files separately in the file system and display using custom gallery - no good pointers even in Stackflow. Can some iOS guru point me to some good examples.
Note I am not asking about how to read/write video, etc. The question is how to organize a custom gallery using filesystem and a datastore and is it the right way to do it? If not, what other options? What are the pros/cons of AssetsLibrary?
Thanks.

You can store them in your documents directory. This is only accesible to your application. You can get a reference to that folder with this:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
Apple recommends using NSFileManager to create, move, and delete files.
NSFileManager *fileManager = [NSFileManager defaultManager];
The NSFileManager class enables you to perform many generic file-system operations and insulates an app from the underlying file system.
NSFileManager documentation.
NSSearchPathForDirectoriesInDomains

Related

Accessing Document directory in iOS storing and retrieving data [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm building a data which can store images into iOS document directory. I'm able to store the data in the document directory but how can I access it.And what is purpose of directory in iOS apps when there is persistent data store technologies like core data.Whether I can use directory to get persistent storage or I should go for core data.
I think, document directory is better solution in your case. Core data is useful for maintaining records corresponding to multiple fields.
Just use NSFileManager, something like this:
[[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&error];
It will give you an array with all the file paths for all files in the given path.
This is how you load the images from the array of URLs.
NSArray *paths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:&error];
for (NSURL *url in paths)
{
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]];
}
Have you tried using UIDocumentPickerViewController?
This is Apple documentation: https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller
Here is a tutorial:
https://medium.com/flawless-app-stories/a-swifty-way-to-pick-documents-59cad1988a8a

How to access phone memory from application - iOS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have an music application that plays songs from urls using AVPlayer. According to new requirement user should be able to listen their local songs (contines in phone memory) also through this music app. I want to know few things about this.
1) How to access local memory within my application.
2) Can I use already exists AVPlayer to play local songs too.
Any tutorial or examples uch appreciated.
Thanks
1) It depends on what you mean by 'local memory'. You app's local folder, or the device's iPodLibrary?
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentsDirectory = [NSHomeDirectory()
stringByAppendingPathComponent:#"Documents"];
NSLog(#"Content of local documents directory: %#",
[fileManager contentsOfDirectoryAtPath:documentsDirectory error:nil]);
This will print out all the files that's currently in your app's document-folder. You can store files here too. This is only for your app, not shared by any other app on your device. I do not think you're able to find the .m4a-audio files from your iPod from your application, I'm guessing Apple has hidden them so developers can't mess with them, or start pirating etc.
2) As it turns out, it looks like you can! Take a look at this answer.

Interaction of a iOS app with server [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I am currently working with an iOS app that needs a remote interactive server.In my app i have to request some queries as well as post some data to server.Which is the right way or appropriate way to do so. which one is better REST or JSON or SOAP to do this? Is there any tutorial or documentation site?Thanks
REST is the most common way to do so.
Basically, REST relayes on simple HTTP requests & JSON,
both are very easy to use with iOS SDK.
If your model is simple, you can go straight forward with HTTP & JSON.
If it's more complicated, i recommend using REST Kit, here's a link
For straight-forward solution, if you only need a simple GET call to an existing REST API,
here are a few basic lines of code (These shouldn't run on main thread)
// Preform this on background thread
NSError *anError;
NSData *apiCallResponseData = [NSData dataWithContentsOfURL:#"http://yourdomain.com/apicall?param=value"];
NSDictionary *response = [NSJSONSerialization JSONObjectWithData:apiCallResponseData options:kNilOptions error:&anError];
//Lets say result is { "key" : "value" }
NSString *someFieldValue = response[#"key"];
//.. do what you need with the result values...

Storage folder for video files and video "description" files in iOS - Apple Guidelines [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Currently I'm developing an app which will download some videos from a "computer device".
These videos will be played in the app -> for proper sync. another file is needed (each video has its coresponding file).
I have done some research on where should I store this... but there is no certain anwser (at least for me at this point).
Read this Guide to some point
I assumed the "/cache" folder is suitable?
Which folder should I use in this case? I want the video to be playable in an "offline" situtaion. These videos can "weight" a little thus I don't want any iCloud sync for them.
While items in the caches directory do not get backed up to iCloud they can be purged by the system if under pressure to reclaim disk space. You could potentially store it in the users documents directory if it's "user generated" data.
An appropriate place to store downloaded content that your app needs offline would be the Application Support directory (Library/Application Support).
NSArray *appSupportURLs = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask];
NSURL *applicationSupportDirectory = appSupportURLs[0];
You should also set attributes on files located elsewhere (Application Support, Documents, etc.) if you do not want them to be backed up. You can find more on it here: http://developer.apple.com/library/ios/#qa/qa1719/_index.html
Use NSCachesDirectory. It won't be backed up in iTunes or iCloud.
NSArray *cachedirs = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachedir = cachedirs[0];

remove application ipad from my system [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How can I uninstall my application from my iPad?
I'm using this code to delete the Documents directory:
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES); NSString *documentsDirectoryPath = [paths
objectAtIndex:0];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:documentsDirectoryPath error:NULL];
You cannot delete the Documents directory and there are no APIs to programatically uninstall an app from an iOS device.
The user is the one in control of whether or not to remove an app from their device and, when they choose to do it, any files in the Documents, Library and Temp folders will be removed from the device.
Anything stored in the application User Defaults database will be removed too. Anything stored in the keychain will remain on the device.

Resources