Reading/writing data to encrypted custom file type - iphone

I'd like to create a custom file type, say, .cstm, and be able to create .cstm files on the mac, and read them on the iPhone.
I want the .cstm file to contain XML data. Currently I've got the mac app to successfully make .xml files and the iPhone app to successfully read .xml files, but I'd like to create a proprietary custom file type.
How would I go about doing this? I know how to allow the iPhone app to open a custom file type, but that's as far as I know.
Thanks!

You don't need anything special per se. You can just save and load to the URL with the ctsm extension. To support your app automatically launching as an editor of that extension in OSX, you will want to add an entry to your Info.plist file CFBundleDocumentTypes array entry declaring your app as an editor of that extension
https://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-101685-TPXREF107

Related

Recognize my mime type without file extensions on iOS

I am writing an application that needs to recognize my custom mime type so that when such file is downloaded from a server my application will be launched. I read the great article of Brad on how to write a mime type recognizer under iOS at How do I associate file types with an iPhone application? and it works well if and only if the extensions of the file is also specified in the UTExportedTypeDeclarations / UTTypeTagSpecification section of my plist and the server serves the files with the same extension. If the server serves the file with a different extension or if no extensions are specified in the plist but the mime-type is matching, the following happens:
The browser (or the application that received the file) shows the correct icon of my file type with the correct [Open in myApplication] button but clicking on the button does nothing, my application is not launched and if it is running, no application:openURL:sourceApplication:annotation: message is sent.
Is there any way to write a file type recognizer based only on the mime-type, without a specific file extension?
this has been answered, you'd want to use NSURLRequest, this will allow you to get to the mimeType which you can use to determine the file extension as needed. the full code and additional hints and tips are available at this post:
https://stackoverflow.com/a/1401918/728261

Can I download and rename a file from .abc to .json in my app?

I would like to take a json file (.json) and rename it to my app's file type (.abc) and then attach it to an email and then open this file up in another instance of my app and then read this .json file.
Would this be possible? i.e. can I take this file save it and rename it back to .json and then read it using a json parser all within my running iOS app?
Short answer is yes, but why bother with extensions? Anyways, take a look at these NSFileManager methods :
– replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error:
– moveItemAtURL:toURL:error:
– moveItemAtPath:toPath:error:

Is it possible to add custom info to manifest file used to distribute iPhone enterprise applications?

I am creating an application that will be distributed using the iOS Enterprise Program. I know I'll need to create a manifest file that will be used to download and install the application. What I want is to add some custom info within the manifest file and read this info in the installed application. Does anyone know if this is possible and how can I do that?
Thanks
If by 'manifest file' you mean the .plist defining the IPA url etc. then yes, you can add your own custom key/value pairs. It's just a standard plist format which you can edit like any other, and additional key/value pairs will be ignored by the Over The Air distribution mechanism.
If you want to read these values from the application itself, the app will have to download the .plist again itself and parse out the values.

how to creating localizable.strings file by code in iPhone

I am working on one multilanguage project which will download string from server depend on language selected by user. I would like to save this downloaded string into localizable.string file. So how could I do that? I know how genstrings works but I would like to generated *.strings file by code and save it. My code will read this *.strings file for localizable. Anybody know which api i have to use?
thanks in advance
Manu
Typically, localization depends on strings files that are within the app bundle. Since you can not modify the app bundle at run time, you will have to put the strings files you downlaod elsewhere and you will have to modify the usual localization methods to find and use those strings files.
Look at Apple's iPhone samples to see how they do localization and fetching of the strings, and see if you can replace all the local accesses of the localization resources with resources in another directory.

How do I make the iTunesArtwork image without an file extension?

Apple seems to say that this image should have no extension. But how is that possible to have a file without an extension? Does this make sense? Or did I get that wrong?
It does make sense. Files are allowed to have no extensions. In fact, the extensions are basically a legacy form of metadata that allows the OS to identify their type without having to look inside for header information. Go ahead and rename a .PNG or .JPG file to have no extension and you should have no problems.
It works fine without an extension. When iTunes loads it out of your bundle (for ad hoc distributed apps), it peeks inside the file to figure out if it's a png or jpg.
Note that when you submit an app to the app store at the iTunesConnect web site, you don't put this image in your app bundle, but upload it separately. It should be a jpg file and must have a .jpg extension or iTunesConnect rejects it.
It's possible for a file to have no extension - just save it from a program that lets you specify "all types". It 'makes sense' insofar as the data is still there, but no instruction set is included for how to interpret the data: If Apple has said don't provide an extension, then don't and it should be fine.