I want to add an icon (icns & ico) to a file within my iPhone app and I'm not quite sure where to start looking! So when this file is viewed in Finder or Windows Explorer it will have a custom icon.
Can anyone point me in the right direction?
You can use -setIcon:forFile:options: method on NSWorkspace if you want to change the icon of a file or folder in Mac OS X.
I do not have an answer for Windows Explorer. For MacOS, the custom icon of a file is stored in the resource fork of the file as kIconFamilyType with id kCustomIconResource. The custom icon for a folder is stored in a file named Icon\r (\r meaning mac newline) in the folder. For volumes, the custom icon is in a .VolumeIcon.icns file at the root of the volume. In each case, you must set the kHasCustomIcon Finder flag for the item.
Cocoa does not give you access to the resource fork or the Finder flags. Use FSSetCatalogInfo to set the Finder flags. Use FSCreateResourceFork, AddResource and CloseResFile to add a custom icon family to a file. The same resource fork calls are used for the custom icon file in a folder.
The usual way to set an icon is to either paste it in from the Get Info Finder window, or send the Finder an apple event. You can send apple events from cocoa, but that is no help from an iPhone.
To create a file on an iPhone that has a resource fork, you would probably have to build a zip archive that would create a resource fork when unzipped. You would have to manually build a resource fork wrapper around the icon family data. The resource fork structure is well documented.
It would probably be easier to have a helper application on MacOS.
Related
In a macOS application written in Swift or Objective-C and targeted for the Mac App Store, how to determine programmatically if invisible files are currently shown in the Finder? I have tried to call defaults read com.apple.finder AppleShowAllFiles using NSTask, but it does not work in the sandbox. Any help is greatly appreciated, thanks.
Finder
It's irrelevant if com.apple.finder AppleShowAllFiles contains false or true. You probably misunderstood how it activates file viewer with URLs.
Example:
/Users/zrzka/.rustup
Finder is activated with content of the /Users/zrzka folder
.rustup folder is selected
/Users/zrzka/.rustup/toolchains
Finder is activated with content of the /Users/zrzka/.rustup folder
toolchains folder is selected
Sandbox
You can ask Apple for temporary exceptions. Here's more detailed answer. But it really depends on what files/folders do you want to reveal.
Could anyone send the ATN file with only one action -> opening PSD file on Mac?
I've made an action with a lot of steps, it's working good but only on Windows. There is no relative paths in PS actions, and i have no friend that has Mac. Could anyone prepare ATN file (so i will be able to copy "open psd file" step)?
Regards,
Luke
Short answer: this won't work. Even though Photoshop has "shortcuts" paths that are similar for both OSX and Windown (like ~/Desktop is a shortcut for desktop folder no matter of OS and username), Actions don't seem to recognize them. Furthermore, if you record an Open Action on Windows or Mac and open it in a different OS, you'll get a File or folder not found message for this step:
Here're two examples. In bot cases the top Action was made in Windows and the bottom one on Mac. This is a Mac screenshot:
and Windows:
Notice how Action1 on the Mac screenshot has File or folder not found message and on Windows there's the same message for Action2 from fromMac set.
Here's what you can do though.
insert Open as a Menu Item. This way user will be asked for a file you need every time a user calls the Action.
give the file you need to open as a pattern file (.pat) and ask a user to install it. This way you can fill a document with it using the Fill command.
most powerful: use a script. You can convert your action to a script file using the xtools: there's a script within it called ActionToJavascript: this will give you a .jsx file that you can use in Photoshop and that will work exactly as your action. And in this script you can specify a path for your action. Like here I'm specifying a file on my Desktop:
And this script will work on Mac.
In a Cocoa Application for macOS, I save a bundle to disk using NSFileWrapper. The Bundle is correctly saved and recognised as a bundle (Show package contents appear) but I cannot get the finder display the Icon I provide for the bundle. Here are my settings for the imported/exported UTIs:
Unfortunately, the bundle appears always with a blank file icon:
As you can see, the Finder recognises the file kind, but does not display an image for it. Any help is greatly appreciated. Thanks
In the Exported UTIs section, try setting Conforms To to com.apple.package, public.archive.
I'm no UTI expert, but that has always worked for my apps.
I'm using Titanium Alloy 3.0.2 GA (on a Mac) to build a cross-platform mobile app
Why doesn't the Resources folder show up in the Titanium Studio, even though it is present in the filesystem?
I want to store some images that will be displayed within the application, and I believe that I should store them somewhere inside the Resources folder.
When I look at the Project Explorer within the Studio, I don't see a /Resources folder.
When I tried to add a Resources folder to the root, I was told that there is already a Resources folder!
Finder confirms that there is a Resources folder.
So, how do I get the Resources folder to show up in the Studio Project Explorer?
Also- it does not show up in the App Explorer View either.
Yeah I had a problem with this as well, but thankfully this is documented in the guides section. Heres the pertinent information:
If your Resources folder is hidden, in the App Explorer view, click the View Menu button (right triangle pointing down) and select Customize Views..., then the Available Customizations dialog appears. In the Filters tab, uncheck the Titanium Resources Folder checkbox, then click the OK button. The Resources folder should appear in the App Explorer view.
For me It was actually in the "Project Explorer" view that I found the downward white arrow, and in the Available Customizations dialog I had to scroll all the way to the bottom of the Filters tab and uncheck "Titanium Resources Folder."
Hmm...
Yes I was able to view the Resources folder by going into the "Customize View" option in the Studio.
But the proper place to put local files (car images in my case) is under the \app\assets\ folder. The \assets* are copied to the \Resources folder as part of the build.
So I just put my .jpg files under a new \car_images folder (under \app\assets) and was able to access them in my code
var image = Ti.UI.createImageView({
image: '/car_images/Acura.jpg'
})
So actually there is no need to see/modify the \Resources folder as it is managed by the build process
Thanks
I'm new with Cocoa / Objective-C development and I have a question.
Last week I had to create a SWF based Screensaver for Mac, and as I didn't find a free-compatible solution for Mac OS X Snow Leopard / Lion, I created a .saver bundle with Xcode 4. It creates inside a webview and loads inside the SWF file.
You must place the SWF file inside the Resources folder inside the bundle to make it work with different SWFs.
And now, I'm trying to code a Cocoa Application to do it automatically.
It has a simple user interface so as the user can select a SWF file. Then the code makes a copy of my previously build .saver file (I have the path hardcoded), places inside it a copy of the SWF file, and saves it where the user indicates in a save panel.
And here comes my question. Now I have the path of the .saver file hardcoded, but I need to have it as a Resource inside my app. Would it be possible? How could I use/access it?
Thanks for your help and time!
Your application already has at least one resource, assuming you didn't delete the MainMenu nib. Add your .saver bundle to that build phase. In the app's code, get the URL to the screen-saver bundle the usual way.