Browse Source

消除leak警告

定义MJPerformSelectorLeakWarning宏,消除警告。
liuchunlao 10 years ago
parent
commit
361d81ebb3

+ 3 - 1
MJRefreshExample/MJRefreshExample/Classes/MJCollectionViewController.m

@@ -103,7 +103,9 @@ - (void)viewDidLoad
 {
     [super viewDidLoad];
     
-    [self performSelector:NSSelectorFromString(self.method) withObject:nil];
+    MJPerformSelectorLeakWarning(
+        [self performSelector:NSSelectorFromString(self.method) withObject:nil];
+                                 );
     
     self.collectionView.backgroundColor = [UIColor whiteColor];
     [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:MJCollectionViewCellIdentifier];

+ 3 - 1
MJRefreshExample/MJRefreshExample/Classes/MJTableViewController.m

@@ -467,7 +467,9 @@ - (void)viewDidLoad
     [super viewDidLoad];
     
     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-    [self performSelector:NSSelectorFromString(self.method) withObject:nil];
+    MJPerformSelectorLeakWarning(
+        [self performSelector:NSSelectorFromString(self.method) withObject:nil];
+                                 );
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

+ 8 - 0
MJRefreshExample/MJRefreshExample/Classes/MJTestViewController.h

@@ -9,6 +9,14 @@
 
 #import <UIKit/UIKit.h>
 
+#define MJPerformSelectorLeakWarning(Stuff) \
+do { \
+_Pragma("clang diagnostic push") \
+_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
+Stuff; \
+_Pragma("clang diagnostic pop") \
+} while (0)
+
 @interface MJTestViewController : UIViewController
 
 @end