The Cocoa Memory Management Regular Expression

2007-01-11 20:30:30 -08:00

Any method whose selector matches this regular expression gives you a reference to its return value, which you must later release.


As an added extra bonus, here’s the CF equivalent.


Carbon adds several exceptions, such as GetControlData (which returns a reference to CF things like the string value of a text field). Use Cocoa instead and your memory-management life will be simpler. ;)

2 Responses to “The Cocoa Memory Management Regular Expression”

  1. lee Says:

    This is a great idea! I just don’t know how to use it… Everytime I do a project find with the expression above, it only finds lines with ‘Copy/’. What am I doing wrong?

  2. Peter Hosey Says:

    Don’t include the slashes.

    You only need them in vim, ex, less, and similar programs, to indicate where the regular expression begins and ends. In Mac programs, including Xcode, the regex needs no delimiters, as the field itself does that job.

Leave a Reply

Do not delete the second sentence.

Warning: Undefined array key "ntt_saved_comment_text" in /home/public/blog/wp-content/plugins/negative-turing-test/negative-turing-test.php on line 143