Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 488337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:41:49+00:00 2026-05-13T01:41:49+00:00

I think over the last year and a half, while experimenting with Cocoa and

  • 0

I think over the last year and a half, while experimenting with Cocoa and Cocoa Touch development, I’ve been struggling with getting Xcode to support a kind of key macro to handle this specific coding scenario…

I frequently find myself not knowing ahead of time how many message dispatches to chain together while typing a new line of code. For example, I might type this… (Pipe character represents cursor location)

someVariable = [someObject someMessage]|

…I then realize that I need to chain a message from the returned object (since messaging nil is safe in ObjC, this is a common idiom.) So I would need to change the line of code to look like this…

someVariable = [[someObject someMessage] |

The big problem is having to prepend a left bracket before the bracket pair I’m at the end of, which would entail using the mouse or lots of repeated key tapping each time I needed to do this. After wasting about 40 or so hours off and on trying to find any kind of pre-existing keyboard shortcut or script (I investigated Perl, shell scripting, and even a bit of emacs Lisp scripting in my Googling.), I hacked together this monstrosity in AppleScript, of all things…

tell application "System Events"
    delay 0.2
    set editMenu to menu "Edit" of menu bar item "Edit" in menu bar 1 of
         process "Xcode"
    set kLeftArrowKey to 123
    key code kLeftArrowKey
    set theMenu to menu item "Balance" in menu "Format" of menu item
         "Format" in editMenu
    click theMenu
    set theMenu to menu item "Bracket Expression" in menu "Objective C"
         of menu item "Objective C" in menu "Insert Text Macro" of menu
         item "Insert Text Macro" in editMenu
    click theMenu
    key code kLeftArrowKey
end tell

There has got to be a better way.

I count at least five problems with the above… (which I’ll comment on if asked.) I see frequent online complaints from new ObjC developers all the time about this syntax, and I suspect this one typing issue is the major sore point. While I like how the syntax reads (so much so that I avoid the dot notation for properties out of coding consistency), how it’s first written kind of sucks. (Just like AppleScript, ironically enough, given my current hacked implementation.)

Help me end my suffering, and you’ll probably end the suffering of a lot of other ObjC developers as well…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:41:49+00:00Added an answer on May 13, 2026 at 1:41 am

    What version of Xcode are you using? In my version, left brackets are prepended automatically if I type a right-bracket after a valid selector name.

    In Xcode 3.2, go to Preferences, then “Text Editing”, then choose “Insert opening bracket”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Over the years, I think I have seen and tried every conceivable way of
I have X interfaces to Y computers that communicate over a public network (Think
One thing I really like about AS3 over AS2 is how much more compile-time
Its possible I am just really really thick. However, looking over the SDK for
I think the file that is produced is an .asm file, any idea how
I think most people know how to do this via the GUI (right click
I think most people here understand the importance of fully automated builds. The problem
I think this is specific to IE 6.0 but... In JavaScript I add a
I think it can be done by applying the transformation matrix of the scenegraph
I think that java executables (jar files) are trivial to decompile and get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.