0

I have an Xcode project with 200 or so class files. All of these classes need to have addObserver/removeObserver balanced or there's a risk of crashes so I'm trying to find a way to show the problem files without having to manually scan each one.

Tried this regex from another post...

^(?!.[\s\S]*removeObserver).[\s\S]*addObserver.*$

...but it is returning classes that contain removeObserver.

Community
  • 1
  • 1
Kirby Todd
  • 11,254
  • 3
  • 32
  • 60
  • 1
    What are the `.` dots for ? and I don't think a regular expression is the best solution here, why not just use string methods ? – Ibrahim Najjar Oct 18 '13 at 10:52
  • I don't know what the dots are for. I just copied it from [here](http://stackoverflow.com/questions/15209711/regex-to-find-files-containing-one-word-but-not-another). Is there a way to use the search function to do compound searches without using regex? – Kirby Todd Oct 18 '13 at 10:56
  • I don't work with XCODE at all but there must be, anyway how big is the text your searching ? – Ibrahim Najjar Oct 18 '13 at 10:59
  • It's an Xcode project with 200 or so class files. – Kirby Todd Oct 18 '13 at 11:03
  • I see, but how much each class file can contain, number of lines ? – Ibrahim Najjar Oct 18 '13 at 11:06
  • I am not aware of a simple way to do this with Xcode's search facility (doesn't mean it doesn't exist, though) but have you considered to simply do two `grep`s from the command line? One to find a list of files with `addObserver` and one to find the files in that list that also contains `removeObserver`. Diff the two and you have your result. I am sure some real Unix hackers can come up with a smarter solution than that, too. – Monolo Oct 18 '13 at 12:11

0 Answers0