How do I disable NSLog?

前端 未结 15 2150
陌清茗
陌清茗 2020-12-05 07:46

I\'d like to do the following in Xcode:

Find all NSLog commands without comments, and replace it with //NSLog...

In other words, I want to comment all NSLog

15条回答
  •  广开言路
    2020-12-05 08:31

    You can do this in a single find and replace operation. You can just do this simple Regular Expression replace. This handles both the commented(//) and non-commented lines. This also works even if the previous commented lines has more than two forward slashes(like ///)instead of rwo. You can refer this link. Do the following steps.

    1. Select Edit > Find > Find and Replace in Workspace
    2. Style => Regular Expression
    3. Type (/)*(NSLog.*) in Find field.
    4. Do the find operation.
    5. Type //\2 in the Replace field.
    6. Do the replace operation.

    Enjoy the beauty of regular expressions ;-)

提交回复
热议问题