HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Initializing a window in Cocoa

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
windowcocoainitializing

Problem

This is some of the code I have:

[window setLevel:kCGScreenSaverWindowLevel];
[window setOpaque:NO];
[window setStyleMask:0];
[window setBackgroundColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.3]];
[window setAlphaValue:0];

[window setFrame:[window frameRectForContentRect:[[window screen] frame]] display:YES animate:YES];

[window makeKeyAndOrderFront:self];
[[window animator] setAlphaValue:1.0];


I was just wondering if there was any way to compact it, all of those commands to my window. Any ways to improve it too?

Solution

This is a highly readable style, and simple. You might be able to make a loop and run through the list in some fashion, but it's unlikely to actually lower complexity, just shift it around a bit.

Context

StackExchange Code Review Q#286, answer score: 4

Revisions (0)

No revisions yet.