• About
grant davis' blog

Author Archives: Grant

Gravity – An iOS toolbox

January 1, 2014 8:48 pm / Leave a Comment / grant

Gravity is an Objective-C static library with categories, utilities, and custom components used to solve common iOS problems and to speed up development. I use this library on every one of my personal and client projects and provides me with a handy set of tools that have become invaluable to my development process.

Gravity is currently in a very raw state and needs a lot of trimming and love to make it a more manageable and organized library. That said, I will be working over the next year to refine and refactor out components into their own libraries and organize Gravity into a light-weight library that helps solve a lot of common development problems. Other developers are free to use Gravity at their own risk under the MIT license and is available on Cocoapods.org.

If you would like to contribute to the Gravity library please fork the library and send a pull request on Github.

Posted in: Cocoapods, iOS, Objective-C

GDIIndexBar – A component for scrolling UITableViews

January 1, 2014 8:29 pm / Leave a Comment / grant
iOS7 Screenshot iOS7 Screenshot

Today I released my latest open-source component, a custom index bar used to scroll a UITableView, called GDIIndexBar. This component is built to be a drop-in reproduction of the index bar used in the Contacts app. It supports iOS6+ and styles appropriately for iOS6/7. This is the first of several components I’ll be releasing soon as Cocoapods to the OS community and would love to hear your feedback. Thanks and hope it helps you on your next project!

GDIIndexBar is distributed using Cocoapods and can be installed by adding the following to your Podfile:

pod ‘GDIIndexBar’

Posted in: Cocoapods, iOS, Objective-C

Adding Custom Key Commands in Xcode 4

July 26, 2012 6:17 pm / Leave a Comment / grant

One of my favorite IDEs to program in, even if it feels clunky and rough around the edges, is Eclipse. I used it for years and became accustomed it its handy built-in key actions such as Duplicate Line, Delete Current Line, Move Line, etc.

Once I moved into Xcode and began working primarily as an iOS developer I quickly became annoyed at the limitations of the built-in key strokes. I’ve since discovered a way to add your own custom actions into Xcode which essentially duplicates the functionality of Eclipse, which is awesome!

To do this, you want to start by creating some actions that we’ll add to Xcode’s default key commands. Xcode uses plist filled with dictionary objects that represent sets of commands. We’re going to create our own group of commands and add it to the default set of Xcode key commands.

Here’s what my commands look like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<key>GDI Commands</key>
<dict>
    <key>GDI Duplicate Current Line</key>
    <string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
    <key>GDI Delete Current Line</key>
    <string>moveToEndOfLine:, deleteToBeginningOfLine:, deleteBackward:, moveDown:, moveToEndOfLine:</string>
    <key>GDI Move Current Line Up</key>
    <string>selectLine:, cut:, moveUp:, moveToBeginningOfLine:, insertNewLine:, paste:, moveBackward:</string>
    <key>GDI Move Current Line Down</key>
    <string>selectLine:, cut:, moveDown:, moveToBeginningOfLine:, insertNewLine:, paste:, moveBackward:</string>
    <key>GDI Insert Line Above</key>
    <string>moveUp:, moveToEndOfLine:, insertNewline:</string>
    <key>GDI Insert Line Below</key>
    <string>moveToEndOfLine:, insertNewline:</string>
</dict>

Once you’re happy with your commands, locate the plist file we’re going to modify:

1
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist

Open this in a text editor and add the xmlandelements we created about to the end of the file, but before the finaltags.

Your file should look similar to this when finished:

 

Save the file and then open up Xcode. If you already had it open, you’ll need to restart. Go into Preferences, Key Bindings.

Here make a new set and search for your commands. I prefixed my commands with GDI so I can do a quick search and see all my custom commands.

Now, just double click the Key column for each command, add your keystroke, and start using your custom commands!

Posted in: Tutorials, Xcode

Archives

  • January 2014
  • July 2012

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© Copyright 2025 - grant davis' blog
Infinity Theme by DesignCoral / WordPress