Skip to content

Instantly share code, notes, and snippets.

@callmewhy
Last active August 29, 2015 14:21
Show Gist options
  • Save callmewhy/e566594af00cdbf97ede to your computer and use it in GitHub Desktop.
Save callmewhy/e566594af00cdbf97ede to your computer and use it in GitHub Desktop.
check NSNotificationCenter with python
import os
def check_file(file_path):
file = open(file_path, "r")
haveNotification = False
haveRemoveNotification = False
lines = file.readlines()
for line in lines:
if line.find('[NSNotificationCenter defaultCenter] addObserver') != -1:
haveNotification = True
for line in lines:
if line.find('removeObserver') != -1:
haveRemoveNotification = True
if haveNotification:
if haveRemoveNotification == False:
print(file_path)
file.close()
def check(path):
if not os.path.isdir(path):
print("NOT a PATH")
return
for root, dirs, list in os.walk(path):
for i in list:
dir = os.path.join(root, i)
if dir[-2:] == ".m":
check_file(dir)
check("path to your project folder")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment