WeiLeiming
2/8/2017 - 1:37 AM

NSArray迭代的快捷方法

NSArray迭代的快捷方法

// shortcut method for NSArray iterations
static void each_object(NSArray *objects, void (^block)(id object)) {
    for (id obj in objects) {
        block(obj);
    }
}

// shortcut to change each label attribute value
#define EACH_LABEL(ATTR, VALUE) each_object(self.labels, ^(UILabel *label) { label.ATTR = VALUE; });