CGRect rect1 = CGRectMake(0, 0, 100, 200);
CGRect rect2 = {0, 0, 100, 200};
CGRect rect3 = {.origin = {0, 0}, .size = {100, 200}};
CGRect rect4 = {.origin = {.x = 0, .y = 0}, .size = {.width = 100, .height = 200}};
// ({})で囲まれたブロックが即時実行され、最後に評価された変数がreturnされる。
self.helpButton = ({
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect buttonRect = innerBounds;
buttonRect.size = [button sizeThatFits:CGSizeMake(400, 400)];
buttonRect.origin.x = CGRectGetMaxX(innerBounds)-CGRectGetWidth(buttonRect);
button.frame = buttonRect
[self addSubview:button];
button; // buttonがself.helpButtonに代入される
});
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title"
message:@"message" delegate:nil
cancelButtonTitle:@"\u26D4 NG"
otherButtonTitles:@"\u2705 OK", nil];
NSString *msgFullString;
if (msg) {
msgFullString = [NSString stringWithFormat:@"Message: %@", msg];
} else {
msgFullString = [NSString stringWithFormat:@"Message: %@", @"Unknown error"];
}
NSString *msgFullString = [NSString stringWithFormat:@"Message: %@", msg ? msg : @"Unknown error"];
NSString *msgFullString = [NSString stringWithFormat:@"Message: %@", msg ? : @"Unknown error"];