I think that over the past year and a half, experimenting with the development of Cocoa and Cocoa Touch, I have been struggling to get Xcode to support my key macro to handle this particular coding scenario ...
I often find that I donβt know in advance how many messages are sent to the chain when typing a new line of code. For example, I can enter this ... (the pipe symbol represents the location of the cursor)
someVariable = [someObject someMessage]|
... I then understand that I need to associate the message with the returned object (since nil messaging is safe in ObjC, this is a common idiom.) So I will need to change the line of code to look like this ...
someVariable = [[someObject someMessage] |
The big problem is adding the left bracket to the pair of brackets that I have at the end, which will entail using a mouse or a lot of keystrokes every time I need it. After you spent about 40 hours and tried to find some pre-existing keyboard combinator or script (I explored Perl, shell scripts and even some emacs Lisp scripts in my Googling.), I hacked this monster in AppleScript, of all of 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 to be a better way.
, , ... ( , .) - ObjC , , . , (, ), . ( AppleScript, , .)
, , , ObjC...