I got a compiling error "Implicit conversion of 'int' to 'UILabel *' is disallowed with ARC" in the code below.
UILabel* (^makeLabel)(CGFloat, CGFloat, CGFloat, CGFloat, NSString*) = ^(CGFloat x, CGFloat y, CGFloat w, CGFloat h, NSString* title) {
UILabel* label = [[UILabel alloc] init];
label.frame = CGRectMake(x, y, w, h);
label.text = title;
label.font = [UIFont systemFontOfSize:14];
return label;
};
UILabel* lblEmail = mekeLabel(30, 100, 100, 30, @"이메일");
What should I do to solve this problem?
you need to define the return type explicitly everywhere, like:
UILabel * (^makeLabel)(CGFloat, CGFloat, CGFloat, CGFloat, NSString *) = ^UILabel *(CGFloat x, CGFloat y, CGFloat w, CGFloat h, NSString * title) {
UILabel * label = [[UILabel alloc] init];
label.frame = CGRectMake(x, y, w, h);
label.text = title;
label.font = [UIFont systemFontOfSize:14];
return label;
};
then this will work flawlessly:
UILabel * lblEmail = makeLabel(30, 100, 100, 30, @"이메일");