宽容他人,放过自己。

可变数组宏_双层数组内元素的移除

Posted on By anchoriteFili

#import "ViewController.h"

#define KBArr(obj1,obj2,obj3) [NSMutableArray arrayWithObjects:\
                              [NSMutableArray arrayWithObjects:@"我的会员成长中心",obj1, nil],\
                              [NSMutableArray arrayWithObjects:@"营销中心",@"专属APP",obj2, nil],\
                              [NSMutableArray arrayWithObjects:@"圈付宝",@"占位符",obj3, nil],\
                              [NSMutableArray arrayWithObjects:@"摇钱树",@"邀请同行有礼",@"设置",@"关于旅游圈", nil],\
                              nil];

@interface ViewController ()

@property (nonatomic) NSArray *desArr;
@property (nonatomic,strong) NSMutableArray *KBArr;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.KBArr = KBArr(@"测试1", @"", @"");
    
    for (int i = 0; i < self.KBArr.count; i ++) {
        
        NSMutableArray *arr = self.KBArr[i];
        for (int j = 0; j < arr.count; j ++) {
            
            if ([self.KBArr[i][j] isEqualToString:@""]) {
                [self.KBArr[i] removeObject:self.KBArr[i][j]];
            }
        }
    }
    
    NSLog(@"self.KBArr ===== %@",self.KBArr);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end