One of the requested features for my apps is to have an export feature. Most of the time the data is table-like in nature. As an example, users might enter every day what types of food they ate that day, and how many portions of each food type. As the data is table-like, I figure the most useful for export would be into CSV format. Then it can be read in spreadsheet software.
I'm confident I can get the data into a CSV like format without too much trouble, and found this post would should help me: How to convert data to CSV or HTML format on iOS?
What I'm wondering about is what I can do with the file once it has been created? Can I attach it to an email? How else can I make it available to the user so that it has some use?
Alternatively, am I going about this the wrong way and would there be a better way to offer an export function?
I would suggest using MFMailComposeViewController and attaching your CSV file to it. This has the benefit of allowing the user to forward to the file to multiple recipients, customize the email body etc. You can also insert HTML into the email body, so if the data isn't too large you could simply present a table of the information within the email itself.
To send an attachment follow the instructions here.
Usually when an iPhone app needs exporting functionality you have the following options:
Attaching it to an email (as you mentioned)
Sending it to a server (with HTTP or any other TCP/IP based protocol)
Exposing it with a small WebServer you code inside your app (like the Video Camera APPs for 3G and older iPhones do)
Unfortunately, you can't use iTunes for sync your exported file. At least you can't with the current version of the SDK.
Instead of CSV, I would use XML. It can also be read with Excel (or any other spreadsheet), plus you won't have to deal with COMMA (or any other separator for that matter) escaping.
Related
I'm currently working on a simple frontend that will allow users to input data into text fields and also upload files on the same form.
I know that I'll have to use multipart/form-data in order to send the files, but I'm curious as to what would be the best way to also send the text data. My options are:
Submit files and text data in a single form using multipart/form-data
Separate files and text data between two different endpoints, allowing me to format the text data to JSON client-side before sending it off
I don't think doing either would be terribly difficult, but I'm curious as to what is generally considered to be the best practice in this scenario.
This depends on the workflow you expect of your users.
If the fields you want them to fill in are tightly bound to the file you upload, do them all in one form. For example, if it's an image being uploaded and the field contains the image's caption, they go together and should be in a single form.
If it makes sense from your page to just upload the file, or just fill out the fields in the form and submit them, use two form objects.
You probably won't know how well this works until you do some usability testing. You may have to change it up to get everything working smoothly.
Good day,
I want to communicate between two Web Api's, the first web api lets call Api1 not written by me and that api interacts with my data base to spit out information needed.
I have web api2 which would be written by me and why i have this is because my application needs data in certain kind of format (.dll) format.so api2 purpose is to get the information from api1 and then transform or package my data in a way that the my application would understand.
The question, is this possible?. can i use wrappers, so when i get my information from api1 then i wrap my information in the desired format before sending it off to the application. Does anyone have any other suggestions ?
Thank you in advance,
What you describe is possible but the requirements are too vague to give a useful answer.
The file extension doesn't really mean anything so not sure why you need .dll format for the message. I would use a standard format like Json or Xml. Or if using datawindow you could simply do saveas on sending side (or comma delimited, tab delimit) and file import on receiving end, so many options.
Too vague.
Async or Sync interface?
Files transferred via REST, OLE, DDE, or files written to location on server?
Are the files/data transferred specific to a logged in user?
How much data is being transferred, rows of information or configuration data? Answer will help in deciding on appropriate format & best method.
What type program is API #1 not in your control? That is important factor.
I'd like to provide backup functionality to my app, it's a financial app.
I'm not really sure what type to provide, dropbox or wifi, or something different?
I just want to provide something simple / quick to develop, so users can import / export aka restore / backup.
Any suggestions / thoughts ?
Possibly the quickest way is to use iCloud - that said, Apple strongly discourage you from using iCloud in apps to store sensitive data. If your data is very sensitive (ie, financial), it sounds like you might need to look into some kind of secure system. Plain e-mail as suggested may not be the best solution.
From what I understand you want your users to be able to backup their data from within your application. If this is correct then you can create a CSV file and then send it to either your server to store, or maybe allow your users to email themselves the file (as long as you allow some sort of method to import CSV files - preferably if you stored this on your own servers and database for the user).
Here is a good link for converting your users data to a CSV file.
How to convert the NSMutableArray to CSV file on iPhone?
I'm creating an iPhone app which is going to have an online spreadsheet to download information from, problem is i have no idea how to do this. I'm not sure how many rows there will be, but there will be 6 columns. How do I access information from this spreadsheet?
Links to tutorials would be nice
Your best bet is to make some sort of API call on the server to output the spreadsheet in CSV format, then use a CSV parser on the device once you fetch the data. A Google search turn up several solutions for a parser.
In my application i need to create and save data into an xml file on my webspace and then i want to parse that xml into my iphone app. The question here is this is being done by two different parties a sender and a receiver.
But i don;t know how to parse that xml file into my app when i don't have the excat url of that xml because there will be number of people who will be using this app so how i can allocate the xml a specific url and pass that url at receiver end.
Thanks,
As there is a lot to this question I can only give you a vague answer to keep it short. The type of communication I recommend using is NSURLConnection. That will allow you to get the contents of say an xml from a URL.
As far as identifying individual users there is a few ways all of them a fair bit of work. You could create a sign in where the user has a unique username or email. Store that in the database on your server and pass it as part of the url.
You could also sort of use push notification registration where your server is required to keep an iPhone unique identifier to push information to Apple. I don't know enough to push notification to give you much guidance in this but if you don't want the user to create an account I think this would be the way. You could also query the server for a unique ID and store it in NSUserDefaults.
I would recommend the user account creation though. Also have a look at NSXMLParser for your xml parsing.
Beyond this help ask a more specific question. There are also many other ways to do this, its just the way I do it.
I can help you with the parsing of the XML.
iOS (like mac) has a built in XML parser.
Still I would recommend you use an external library, there are several available out there.
In a recent project, I very successfully used TouchXML: http://github.com/schwa/TouchXML
Here is a very simple tutorial on how to use the TouchXML library to parse XML files:
http://foobarpig.com/iphone/parsing-xml-element-attributes-with-touchxml.html