how to open an apple unsupported file in our ipad app - objective-c

i need to open an Apple unsupported file in my ipad app using "Open In" feature. The file extension in ".lasso" . I said that file is unsupported by Apple, because i cant find it description in Apple System-Declared Uniform Type Identifiers.
I was try to solved that using CFBundleDocumentTypes in info.plist, but i still can not open it. i was write this in my plist :
but when i try to open a .lasso file from another apps, there always show an alert "Can not open this file in another apps".
do somebody know how to solved it?

You need to create your own UTI for your file type, something like com.yourcompany.lasso. Your Info.plist is claiming to export the public.plain-text UTI which of course already exists. You would also list the pre-existing UTIs that your new UTI conforms to. You don't show what's under the "Conforms to UTIs" key in the screenshot, but it should apparently be public.plain-text if .lasso files are indeed plain text. (If there's a specific encoding for .lasso files, such as UTF-8, you should consider something more specific, such as public.utf8-plain-text.)
Also, you should either have a custom MIME type or not use one at all. You don't want to redefine the "text" MIME type to suggest that all data streams of that type are Lasso files, do you?
And why are you using all-caps for "LASSO". I assume that, in real use, files will have an extension in lowercase like ".lasso". Right?

Related

iOS custom email attachment handling in iOS6

My app allows for a text file to be emailed to other users with or without images and audio. When there's no images or audio, then the app sends the text file "as is" with a custom extension (e.g. text.xxx). When there's audio and images, the app zips the text file along with the images and audio into a file named something like text.xxx.zip.
Prior to iOS 6 this worked fine. Pre iOS 6, the app was given the URL of the text.xxx.zip file. Now, with iOS 6, it appears that the file is already unzipped by Mail, and only the text.xxx is sent to the openURL handler.
Does anyone out there have any experience with this? Suggestions for a better approach? I'm thinking I'll need to come up with a unique extension for the zipped case...
So after pounding my head on this for the last 24 hours or so, this is what "solves" the problem:
1) Change any existing attachment filenames from test.xxx.zip to test.zip. It looks iOS6 Mail is assuming that anything of the form filename.xxx.zip, is really just a compressed version of filename.xxx. (Maybe that's a standard somewhere?) Also noted that if I changed the filename to test.yyy.zip it then said it couldn't open the attachment. (presumably since no one registered for the ".yyy" extension).
2) Rewrite code to not use .zip extension in the future to prevent similar issues.
I also discovered that for multiple document types (e.g., .xxx, .zzz) you must specify a different mime type for each in the UTI declaration - otherwise Mail appends the first UTI extension it finds to the object and then calls openURL. So, in other words, if you're set up to handle a flat file (.xxx) and a zip file (.zzz), but you use the same mime type (e.g. application/myappname) and "xxx" is defined first, when openURL is called for your file "test.zzz", it will actually pass it to openURL as "test.xxx".

Get list of file extensions of public.movie UTI

I'm trying to create an NSOpenPanel that only looks for movie files. I'd like to do this by looking up the registered movie file extensions using the public.movie UTI. Can anyone help me out?
You don't need to retrieve the file extensions of the UTI: you can use the UTI directly.
According to the documentation, the method setAllowedFileTypes: of the NSSavePanel class (superclass of NSOpenPanel) accepts UTIs as well as file extensions.
So this should work, without having to wonder about associated file extensions.
[yourOpenPanel setAllowedFileTypes:[NSArray arrayWithObject:#"public.movie"]];

<Error>: FT_Open_Face failed: error 85

I am trying to install a custom font into my iPhone application. When I add the 'Fonts provided by application’ key into my info.plist file I get the following error ': FT_Open_Face failed: error 85.’
I am not sure what the problem is as I have successfully been able to use custom fonts in the past.
Any help will be appreciated.
If you leave the first element in your font array in the plist (index 0) blank, you will get this error.
PostScript fonts cannot be used with UIFont directly. You can use them only with CoreText or CATextLayer.
This can occur if the font in question is a Font Suitcase format. Open your application package, and if the font .ttf file shows a size of "Zero bytes", it's probably a font suitcase.
Files of this type can be converted using Fondu.
When running Fondu, I had to specify not just the suitcase file, but the resource fork inside it:
fondu mysuitcasefont.ttf/..namedfork/rsrc
This will extract any fonts in the suitcase to the current directory. It is these extracted files you will want to include in your iOS project and reference from the .plist.
I received this error when using a .ttf font. I was able to correct it by removing the file extension from the filename in (a) the resource in xcode and (b) the "Fonts provided by application" array in the .plist file.
Hopefully this will help.
I was trying to use Google Signika font on my App, and got the exact issue.
I solve the issue by using the .otf version of the font
Accepted answer is totally wrong and unnecessary. Probably you made a mistake when writing your font name.
Thats rules for that.
First Step : Write font name before .ttf extension. Example: For FFFTusj.ttf => FFFTusj
Second Step : Write - and after font style. Example: Bold or Medium etc. Example: #"FFFTusj-Bold"
And also dont forget add your font file to your project.
Check this link:
http://www.bycoder.com/post/2013/03/28/XCode-Custom-font-doesnt-work
If your font is REGULAR dont write -Regular at end of font name.

Custom fonts on iOS app - working in Simulator but not iPad

Encountering a weird problem here. I'm developing a game for my school project (non-commercial), and I'm using a custom font Black Chancery (free under GNU GPL). I followed the instructions from multiple sources, which includes:
Add the font to the project (TTF).
Modify app-Info.plist to add the font to it ("Fonts provided by application").
Using [UIFont fontWithName:#"BlackChancery" size:30] when the font is needed.
I could get the font displayed in the Simulator, however when I load it into my iPad, the default system font is used. I'm pretty sure there isn't a problem with the font itself as it displays in the simulator, and I've used FontForge to open the font without any warnings (following from This Question).
Any help is greatly appreciated. Thanks! :)
I can only guess as you haven't posted the contents of your plist or a directory listing of the bundle, but many cases of "resource works on the simulator but not on the device" are caused by the fact that the OS X filesystem is normally configured to be case-insensitive while the filesystem on the device is case sensitive. For example, if your file is named "BlackChancery.TTF" and your plist refers to it as "BlackChancery.ttf", it will be found on the simulator but not on the device.
I was having problem with font not recognizing, I fixed it by checking the correct name of the font by checking info of the font file by Get Info option. In my case the file name was written xyzfont.ttf but actually it was XyzFont.TTF in the info, i replaced and it worked.
Hope, it helps someone.
Another Way
I have come across one more way of finding the correct name, is by installing the font in the FontBook..
Just open FontBook from Finder and select User now from File->Add Fonts select the font you want to add into your application, after little processing the FontBook will show the Font listed in with the Correct name, use the name in the FontBook ignoring the actual ttf file name you have imported or, added to plist.. It should work..
I had the same problem which was resolved with a slight variation on iphonc's solution. The case sensitivity was directly related to the file extension. The problem was associated with my font file named: Choc.TTF
I had to remove the reference to the file in xCode 4.1
Rename the file to Choc.ttf (note lower case file extension)
Add the reference back into xCode
Perform a clean and re-build for the device
Conclusion (in my particular case):
Case sensitivity applies not JUST to the file name, but to the file extension as well (i.e. iOS device appears to tolerate only lower case).
My answer is different from all the rest. I had a problem because the font was all one word and lowercase "compassnormal.ttf" and the name in the file was Compass. So, my code was:
[UIFont fontWithName:#"Compass" size:24]]
Bundle Resource said:
compassnormal.ttf
~info.plist said:
compassnormal.ttf
None of this worked until I changed the actual filename to match it's official name in fontbook.
deleted all references from Bundle Resources and ~info.plist;
added font with updated name to Bundle Resources;
updated plist with new name;
tested in simulator and on device, Voila!
I have also experienced a problem with fonts containing the dash (-) character. Remove that character from your font names and try with that.
So your font named Gotham-Black.ttf should be named GothamBlack.ttf
Also check that your fonts are not zero bytes. I had this same issue and it turned out that my font files had emptied themselves at some stage. Probably when rearranging them in XCode and AppCode.
You have to use the real font name in the [UIFont fontWithName:#"... method! Not the ttf filename!!!
This real name is mostly far away from the filename. Just open the rtf in the Mac font utility. In the header you see the font family!!! Only the family!!! if you now use
NSArray *fontNames = [UIFont fontNamesForFamilyName:#"MyFontNameFamily"];
NSLog(#"%#", fontNames);
in your code, you get the real real real name in the console ;-)
But in the plist entry you still need the (case sensitive) filename!!!
I have the same issue on Xcode 6. My file name was My Font.ttf, it doesn't work. I manage to make it works when I rename it to My Font.TTF, just change the file extension to uppercase.

Objective C: Register file extension

I am creating an app which needs to be opened if a user double clicks on a file with a certain extension.. How do i register the file extension with my app? and then read the contents?.
E.G the file could have the extension words.ThisApp and it could be in XML Format.. how could I read that in objective c into an array?
I think you should read the Document-Based Applications Overview.
To register an extension to your application, bring up the Target info window (Project » Edit Current Target "My Target"... at the bottom) and open the "Properties" tab. Fill in the blanks for your document type there. For more info, read Storing document type informations in the Application's Property List, contained inside the above guide.
To read XML data, consider using a NSXMLParser (google it for examples) to drive the results into a NSMutableArray as you see fit; and to get the data into your application, consider using a NSDocument subclass, as suggested (again) in the document-based application overview.
As you might understand, this document is quite a vital read.