The canonical Objective-C block syntax reference misses some cases that I use frequently. At the end of last year, as I was getting back into full-time Objective-C development, I made the following example file that covers every block usage I could think of. It is my go-to reference whenever I'm in doubt as to how to write a particular kind of block.
Here's another AppleScript I wrote. It would be great if Xcode would show the current Git branch and working directory status in the main window. Unfortunately, the only way to see the current branch is to select the Source Control menu. There's no quick way to see if you have uncommitted modifications.
I wrote this AppleScript, which I have bound to ⌥⇧⌘G using FastScripts. It pops up a notification showing the current branch and status.
This is a notification showing the master branch with no changes or additions:
This is what it looks like when there are modifications:
And, this is the notification when there are modifications and additions:
I'm on a bit of an AppleScript kick lately. It's a frustrating language to use as it's often counterintuitive. I'm constantly looking up the right syntax to do things. But, it's a great way to patch little annoyances you encounter in Mac software.
The latest annoyance involves Tweetbot image windows. While I'm reading my timeline, I click on lots of links and images. After a while, I find I have a ton of image windows left over.
There's no good way to close all of those windows without quitting and restarting the app. Holding down ⌥ and clicking on the Window menu shows Close All bound to ⌥⌘W, but it doesn't work for me. The alternative is to click on each window and ⌘W on the keyboard, but who wants to do that?
I wrote a little AppleScript to do it. Tweetbot isn't strictly AppleScriptable, but using System Events and Accessiblity gets the job done. The script is a bit kludgy as the inner
repeat loop fails after closing three or four windows. To get around it, I wrapped it in a
try...on error block and repeat that until there's only one window left.
I've got this bound to ⇧⌘W using FastScripts.
This seems to happen whenever someone on the team updates the provisioning profile and commits the change to the
.xcodeproj file. The build fails and Xcode complains that it can't find a provisioning profile identified by a UUID.
To fix it, I have to stop what I'm doing, open Preferences, click the right Apple ID (I have one for each client), click the team, click View Details, click the refresh button, and then close out the action sheet and the Preferences dialog. Not the end of the world, but it gets old after a while.
To get around this issue, I wrote an AppleScript to automate the process. It's a bit fragile, as it's using Accessibility and System Events to poke around in the Preferences dialog. It probably will break in a later version of Xcode (it works in Xcode 5.1).
To use the script save it to your computer and set the
appleID variable to your Apple ID. I use FastScripts to bind the script to ⌥⇧⌘R while in Xcode.
Autocorrect has been driving me nuts in Skype. I found an easy way to disable it without disabling it system-wide.
- Right-click in an editable text area.
- Select "Spelling and Grammar"
- Uncheck "Correct Spelling Automatically"
It looks like this also works in other apps that support autocorrect.