The future of iOS Programming is… not code block evaluation assignment

Come on, it's 2014! Why isn't code block evaluation assignment being used yet, as trends show it's the future!

UIButton* button = ({
//initialize button with frame
UIButton* button = [[UIButton alloc] initWithFrame:({
CGRect frame = CGRectMake(10.0, 10.0, 200.0, 75.0);
//set button background color
[button setBackgroundColor:({
UIColor* color = [UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0];
//set button title for state
[button setTitle:({
NSString* string = [NSString stringWithFormat:@"title words"];
}) forState:({
UIControlState state = UIControlStateNormal;
//set selector
[button addTarget:self action:({
SEL select = @selector(method:);
}) forControlEvents:({
UIControlEvents event = UIControlEventTouchUpInside;
//return button
[self.view addSubview:button];

whoa! whoa!

Or the exact results can be accomplished as such:

UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(10.0, 10.0, 200.0, 75.0)];
[button setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0]];
[button setTitle:@"title words" forState:UIControlStateNormal];
[button addTarget:self action:@selector(method:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];

Now ask yourself, are trends really good to follow?

If you found this amusing, follow me on twitter @jdriselvato or up-vote this on stackOverflow

and yes, I did take this to the extreme.. a good clean example of doing this can be seen here.

Related Posts