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].
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I would like to know about the 'Copy' option/action available while viewing the documents attached in the email. I am referring to the default 'Email' app present on the iOS devices.
Following are more specific questions:
What does the Copy action copy? A complete document or part of it?
Where does the Paste action come in picture for the copied action in email viewer?
This is the screenshot:
I've been checking, searching and researching around this question about .PDF files for the past half an hour, but not finding any answer to that file type. However since you haven't asked about PDF files specifically, I'm putting my answer here.
The Copy option is not available for all file types attached to an email; for example a .zip file or even a .txt or .doc file does not have this option. Video files also come with a different option called Save Video.
So, this option seems to be available for image and PDF files only. If you copy an image file using that option, and then compose a new mail, you can simply paste it by long-tapping the email body section and select paste option.
And that will insert the copied image in-line into your mail which does not work with PDF files. You can copy them, there's no place to paste them. The same paste option wouldn't show up after copying a PDF file. I'd say this is another iOS bug/future-feature that Apple is trying to include in later versions, as file attachments have always been a problem even after almost 8 versions and 8 years.
Log a bug and report this if you have a developer account.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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
Closed 9 years ago.
Improve this question
I hope to convert an app to lib(.a) file for other projects.
The app(lib) has self's ui, other projects use api to start the app(.a file ), the app can exit and return to the project which call it.
Is it possible?
Your comment welcome
In theory it's possible to put most of an application's code into a static library archive (.a file), but any assets that are not compiled into the static library archive (such as nib files, plists, and images) will need to be provided as well, and will need to exist at a path that the static library can find them.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm new in coredata, and I don't understand few things.
I'm trying to make web browser history. And if I save in webviewdidFinishLoad string webpage title and url, it does it well. But if I visit in same page again, it saves same title and url again. I want something that replace old string with new. Like it happens in SQLite - if I write "TEXT UNIQUE".
It's probably is wierd question, but I can't find anything useful!
First of Core Data is not a SQL data base, it just makes it easy to persist and handle related objects. You will need to write code to fetch the entire entries persisted and then have a for loop or NSPredicate to check the uniqueness and then persist if not already present.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
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
Closed 9 years ago.
Improve this question
Can i save more variables as NSUserDefaults?
When these variables get released?
Thank you.
When you remove the app from the device then only the data in the NSUserDefaults will be erased .
NSUserDefaults is not a mechanism for extending the lifetime of objects. It may not retain them at all (specifically, it may copy them and retain the copy instead)! It may save them to disk at arbitrary and unknowable intervals, and release them then. It may release them in response to memory pressure, or it may not.
NSUserDefaults is, only, a mechanism for storing and retrieving preferences. It's extremely good at that. Don't use it for other things.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
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.
Improve this question
I had explored for a PDF Reader in iOS. I found out 2 useful libraries, Leaves PDF Reader and VFR - PDF Reader from Github. But am having issues with these two libraries.
In the case of Leaves PDF Reader, I had integrated it with my application. If I did pinch zooming, the page will be zooming. But the texts in the pages will be blurred and could read it out.
In the case of PDF Reader from Github, it's a fully functional library. I like this reader most when compared to Leaves PDF Reader. But this library will render the PDF's perfectly if the PDF is taken from the bundle folder of the application. In my case, I wanted to integrate this with a newsstand application. So the downloading PDF's are stored in a cache library which is predefined for Newsstand application's library folder. If I gave this path as input to the PDF Reader library, the application got crashed. So I copied the PDF file from the newsstand library path to a NSDocument directory folder. Still the issue is same. This library render the PDF only if the PDF's are kept in the Bundle folder.
Can anybody help me in any of the above case.
Thanks in advance
You can use the document viewer. This works fine for all type of files.
http://developer.apple.com/library/ios/#samplecode/DocInteraction/Introduction/Intro.html