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

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.

Related

What is best way to create zip file and save to Documents in iOS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a book, tool, software library, tutorial or other 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.
Closed 8 years ago.
Improve this question
I want to zip my documents files of my iOS app. How to do that?
path for documents:
NSString* _path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
array with file names at _path folder
NSError* _error;
NSArray* _fileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:_path error:&_error]
for zipping try to use ZipZap:
https://github.com/pixelglow/zipzap
40mb - is small file for this =)

Doc file editing in iPhone app [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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.
Closed 8 years ago.
Improve this question
Would anyone please suggest me how can we edit word document in iphone/iPad application. I wont to open word document in my app and change font style and color and save it again. Is there any paid or free API or document for this which can help me for this.
I don't understand why you guys close this question. Look In below application on app store,
https://itunes.apple.com/us/app/quickoffice-edit-office-documents/id578386521?mt=8
https://itunes.apple.com/us/app/office2-hd/id364361728?mt=8
In above app he edit word document. I also tried below site for getting my point
http://ios-blog.co.uk/tutorials/rich-text-editing-sample-project/
http://ios-blog.co.uk/tutorials/rich-text-editing-sample-project/
and many more but not getting exact idea how above application make document editable. So If you have any idea so please share.
Thanks.

ios persistent storage framework [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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.
Closed 9 years ago.
Improve this question
I'm looking to save a bunch of 'recently accessed' information in my iOS app. For example, if a user views 5 articles, those 5 articles will persistently appear in a recently viewed section.
I was looking into core data and property lists but it all seems pretty complex for such a simple feature. Is there some sort of framework (like Lockbox for keychain) to help make persistent storage a bit easier?
The simplest way has to be to use the NSUserDefaults class. This class stores app-specific preferences to a property list, but all file handling is encapsulated by the class.
To get the object:
NSUserDefaults* settings = [NSUserDefaults standardUserDefaults];
To read a setting:
NSArray* mru = [settings valueForKey:#"MostRecentlyUsed"];
NSLog(#"Setting: %#", mru);
To write a setting:
[settings setValue:#[#"A", #"B", #"C", #"D", #"E", #"F"] forKey:#"MostRecentlyUsed"];
[settings synchronize];
(The synchronize method writes the changes to the file, it is useful to do this once you have set all your settings to avoid losing them if the app terminates unexpectedly)
For very simple storage of single objects, look at NSUserDefaults
For basic storage of non-basic objects, look at NSFileManager for accessing your App's document directory and NSCoder for serialization data.

Add a PDF from Internet(URL) to NSArray [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
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
How can I add a PDF from the Internet(URL) to a NSArray?
So that I can print this PDF out with the ActivityViewController.
I will not save the URL in the Array specially the PDF itself.
EDIT;
NSArray *items = #[self.background.request.URL.absoluteString];
I use this code, but this saves only the URL and not the pdf itself.
Actually it's not a good idea to store file contents for multiple PDF files into an array, as that would consume ways too much memory (and very likely the most of the time you don't even need it).
It's better to download the files to your app's cache or documents folder and load/print files from there. Of course you can download files into memory, but this will definitely fail with big files.
So in the array you probably just want to have URL's or filenames. Once you know which file you need, you actually load it (from your download location or from the URL) and do whatever you need to do with it.
However the answer to your question would be:
// CAUTION: This will block the thread while downloading
NSArray *items = [NSArray arrayWithObject:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.background.request.URL]]];
This statement will store the contents of the PDF file as NSData and put it in an array. To put more files in the array you can use [NSArray arrayWithObjects:..., nil].

Is there anyway read MIDI file to staff on iOS? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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.
Closed 9 years ago.
Improve this question
I just wanna know, is there some library or source can read midi file, parse it to staff and show it on iOS ?
Check the MusicPlayer class. Combined with the AUSampler audio unit available since iOS 5.0 you can build a MIDI player quite easily. (The link is OS X, but it applies for iOS as well)
Apple Documentation
About the sampler audio unit see Simple embeddable MidiSynth for iOS?
Reference from How to play MIDI on the iPhone?

Resources