How to have folders first before any file in finder (Mac) programmatically? - xcode6

I am new to Mac OS. I want to have the folders first before any other file in finder through my cocoa app.
Can anyone suggest me a way of doing this like xtraFinder, PathFinder etc apps do?
I have gone through the followings links. One way is this:
http://hints.macworld.com/article.php?story=2011072120153685
http://mygeekdaddy.net/2013/10/24/change-mavericks-finder-app-sort-order/
And the other way I got is to drag the folders to first in the spotlight (in system preferences) then sort by kind.
But in both ways I don't know how to do this programmatically. Can anyone tell me step by step how to do this through my app?

OS X Sierra finally has an option for this:
Open Finder
Go to Finder Menu -> Preferences
Go to "Advanced" tab
Check the "Keep folders on top when sorting by name"
Now, When you sort by name, can see folders at top of files (like as windows)
Good Luck ;)

For Mavericks and Yosemite: From any Finder window either right-click in the window or select the icon that looks like a gear from the menu bar.
Next, select "Show View Options".
Set "Arrange by" to Name.
Set "Sort by" to Kind.
Optionally, you can save these settings as a default.
Also note that you may need to do this for each drive and/or "top" folder.

I pretty much like everything mac, but this windows-like feature is kinda nice to your eyes.
thanks
Memariaan solutions also works in 10.14.2 Mojave but there are two selections now instead of one.

According to crunchgeek (And validated myself on Mac OSX 10.9.5)
cd /System/Library/CoreServices/Finder.app/Contents/Resources/English.lproj/
sudo plutil -convert xml1 InfoPlist.strings
sudo nano InfoPlist.strings
Now change <string>Folder</string> by adding a space to get <string> Folder</string>. Finally "encode [the] file back into binary format."
sudo plutil -convert binary1 InfoPlist.strings
Now open Finder View Options via Command+J and select Kind under "Sort by".

To make the folders come first in finder, change the order of data categories in spotlight.
Hit Command plus spacebar and then type spotl. That opens spotlight preferences. You will see all the data categories you have checked, or are checked by default. Simply drag "folders" to the top of the list. You can also arrange all the data categories in the order you want. So when you are looking in Finder and opt to arrange by "kind" the folder show up first together with any other changes in the order that you made.
Thanks to David Pogue's OSX Yosemite, the missing manual, Page 132.

Related

Collapse all Folders on directories tab in SmartSVN Foundation

Is there any way to Collapse all folder on the Directories Tab in SmartSVN Foundation 8.0.1?
I Accidentally pressed Ctrl+A (Select All) and ALL THE FOLDERS COLLAPSED!
Now if i want to add a specific folder i need to collapse some or all... or most, but there's no easy way to do it, right now i'm doing it one by one, but the vendor folder (all composer packages) is enormous.
Any ideas?
Seems odd. I've tried to replicate this and have been unable (I'm assuming you're on Windows?) even if I select all and then click the collapse icon on one folder it just collapses that folder.
More than happy to raise a feature request for you if you could give me a bit more detail about what you're after? For example, adding a 'collapse/expand all' and/or a 'collapse/expand selected' option to the View menu that you could set a custom shortcut for in the Edit -> Customize -> Accelerators options?

Force item icon refresh in Finder 10.8.2

Can anyone lead me to any useful link for forcing file icon refresh in new 10.8.2 version of Finder?
I'm working on this problem for last few days and I have tried almost any solution which can
be found on internet, but those are all old samples which are compatible with old versions of Finder and do not work on newer versions of Finder (which are rebuilt on Cocoa framework).
I tried to use few commands from apple script tool to update files in Finder ('update item with necessity'), I tried few plugins from internet (nudge, finder-Refresh...), I also tried support for communication with external Mac application through ScriptingBridge framework (although very useful) but nothing gave me a desired result.
I have noticed that NSWorkspace class contains two methods: iconForFile and setIcon:forFile,
and although I could integrate this two functions in application, iconForFile function is returning image of reduced quality, so I'm stuck in that direction also.
Any idea or suggestion will be highly appreciated.
If you need to update one Application icon, just touch the App.app folder.
Close the finder windows and issue the command:
touch /Applications/App.app
Create a visible file and delete it. This will refresh finder window.
To reset for every application under Mountain Lion, try the following in Terminal:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -seed -r
That will kill all existing objects in launch services and reseed them recursively from the standard locations (/Applications, etc).
If you have a specific application whose data you need to override existing information, you can try:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f <path>
Although I've had limited luck with the latter working in some cases, so you may end up doing the former afterwards.
Type into Terminal
killall Finder
Then
killall Dock
I had this problem too. I had a .app i wanted to change the icon of.
Structure of my .app:
...noida.app/
...noida.app/Contents/
...
...noida.app/Contents/Resources
...noida.app/Contents/Resources/myicon.icns
...noida.app/Contents/MacOS
...
...noida.app/Contents/plist.Info
Now I would change the icon in the resources folder. Then I made new files in all folders. It wouldn't work. The only place that i could make a new file tha twould update the icon was in the ...noida.app/ so i made new file at ...noida.app/junk folder and then it updated.
Very interesting.
I was just fighting with this on 10.10 (although it's been a problem for years now) and the only solution I found to force refreshing a bundles icon in the Finder was to:
Open the "Get Info Window" of the bundle you want to update and select the icon by clicking on it.
Paste another image as the icon (you could have copied this from another file or from any other location with this pasteboard data).
Press return and make sure the icon changed in the Finder.
Delete the icon by pressing the delete key.
After that the bundles icon was refreshed to the new .icns file in the bundles resource folder.

How to open files in Intellij-IDEA with double click?

My first day using this IDE...
is there a way to configure the IDE to open files in the project by double click? It is rather painful having to drag files from the project overview into the editor window.
You can change the KeyMap.
Go to File->Settings and find the keymap section.
You will have to create a new KeyMap by clicking copy, and then look in the View section for "Jump to Source" and change/add the keymap you want.
However, as Bozhidar Batsov noted, double clicking may not always work so well. Whether it works may vary by OS and/or windowing system. I have no trouble with it in Mac OS X, but it doesn't seem to work well in openSUSE.
There are also other predefined keymaps that you can select from this settings screen. They're set up to resemble other IDEs, so you might find them helpful if you're transitioning from something else.
It is easy way to do in windows.
I found a great solution to this problem by Jelmer Kuperus over at Orange11.
Create an .Xresources file in your home directory. Add the following line:
*multiClickTime: 400
Jelmer explains that this setting changes the default double-click speed from 200ms to 400ms, effectively slowing it down. Save the file and then run:
xrdb ~/.Xresources
The effect is immediate, no need to logout or reboot. Double-click in Intellij works as expected. I did try changing the mouse double-click speed in System Settings first before trying this out to see if that made a difference but it did not.
I am using Ubuntu 11.04, Intellij 10.5.2, and Sun JDK 1.6.0_26. YMMV
Use F4 to open quickly the selected files. Btw double clicking on files should work as well(at least in theory). Swing's buggy handling of such events, however, causes the double click to not always work in IDEA, so I eventually stopped double clicking and switched to using F4. You can also use "Autoscroll to source" from the projects menu - this will open the source files as soon as you select them in the project browser.

Where to find the Objective-C Runtime and Headers?

The documentation says:
/usr/include/objc
However, on my mac there is no such folder anywhere. Or can't I just see these with Finder? If so what Tools do I need to take a lookt at them? I'm just very interested to see these headers. Just for fun.
Not sure what "documentation" you're looking at, but the header files for the system frameworks can be found under their containing frameworks at /System/Library/Frameworks. So NSObject.h resides at /System/Library/Frameworks/Foundation.framework/NSObject.h.
Edit: I just checked both my machines (Tiger and Snow Leopard), and they both have /usr/include/objc/ also. So not sure why you don't.
In Finder, press shift-cmd-G and type /usr/include/objc
Or you could go to the "Go" menu in Finder and select "Go to Folder..."
It's a hidden folder.
Do you have XCode/SDK installed? If not - register at http://developer.apple.com and get them.
The folder exists and is indeed hidden from the Finder. You can show it if you know what you're doing, but it can also lead to problems if you ever accidentally delete or move something in the /usr hierarchy. Instead, use a terminal if you want to read the headers.
You can open objc.h in XCode by jumping to the definition of id, SEL or Class (in a source file, cmd-doubleclick the name or right-click it & choose "Jump to definition"; with id, then click "typedef id").
I was having a similar issue on my Mac OS 10.8 machine, so I did a bit of digging through the Xcode files. It would appear that, for reasons I cannot entirely explain, newer versions of Xcode have these file embedded in their packages.
To find them, right click on Xcode.app and select Show Package Contents. Then navigate to the following path:
Xcode.app/Contents/Developer/Platforms
This directory should include three folders, one for Mac OS X, one for iOS, and one for the iPhone simulator. Each contains its own set of header files and resources. As an example, say I chose the Mac OS X platform. The objc headers can be found in this directory:
MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/objc/
As to why they are here and not in /usr/include/objc, I do not know. On a similar Mac machine also running OS X 10.8, I found them in their proper locations. However, this should be a somewhat accurate method of locating them if they are not there.

Enabling tabs in xcode? Or lessening the pain of not having them?

I am currently using xcode and I find it's lack of tabs quite disturbing.
I currently use command-shift-d to search through all the files, or ctrl-1 to open the history of files that were recently opened.
It works but I find it less effective than just tabbing through the few files i am currently working on.
Is there any way, third party or not, to enable some sort of tabbed organization?
If not, is there any other way to quickly navigate through a subset of files?
XCode 4 now supports tabs. You can enable by selecting "View / Show Tab Bar" menu.
Not really, but one alternative is View > Show Favorites Bar and drag five or six frequently-used source files into it. Not as flexible as tabs but satisfies your request for "quickly navigate through a subset of files".
The traditional way is to use the detail view. Get the files you want in the Detail view by one of these means:
Put them all in the same group, then select the group
Enter a filter expression in the Search Bubble that narrows the items shown
Define a Smartgroup that includes just the files you want
Get a list of the files as a Find in Project result, then select that item in Find Results
Then you can use the Detail View as your list of interesting files and navigate through it quickly with the up and down arrows.
First of all, you can use Textmate (which I believe has Xcode integration). Otherwise:
Window (Menu) -> Organizer (ctrl-command-o)
At the bottom of that window, if you don't have two panes, click the square to the right of the gear. Now drag code files of interest to the left, grey pane--a single click or arrow up/down will open the file in the editor pane.
If you do open a bunch of windows, as vog suggested, you'll need to command-~ through them--not alt-tab.
Cheers.
The Xcode source code editor allows you to choose the file from a list. It's two clicks instead of one (as it would be with tabbing), but it's better than nothing.
In addition, you can simply Alt-Tab through your open source code windows. This is not slower than tabbing, and has the same effect since the source code windows are usually placed exactly one in front of another.
You'll definitely want to read through this. (XCode Tips and Tricks you wish you know about two years ago - SO)
You can navigate between files using "Recent Files"
Write simple applescript:
tell application "Xcode"
tell application "System Events"
keystroke "1" using {control down} -- open "Related Files"
key code 125 -- choose "Recent Files" ("keystroke down" doesn't work)
keystroke return -- enter to "Recent Files"
key code 125 -- choose previous file
end tell
end tell
And bind it to some shortcut using for example FastScripts(free up to 10 bindings)
I have this script on "Control" + "`". (XCode 4)
Hope this will help
You may also try an Xcode plugin I've just released - it's called Code Pilot and solves a lot of issues of Xcode's navigation, making it more TextMate/Eclipse-like.
Check it out here: http://macoscope.net/en/mac/codepilot/
I hope this helps!
It is simple with XCode 7.2
GoTo View>>Show Tab Bar
This will show the tab bar.
RightClick on the New Tab and click -->"NEW TAB"
Then We can see all the files in tabs.