NSLevelIndicator

After a year or so of low-level C coding, I’ve decided to switch over into the Xcode/Objective-C development side of things (GUI apps are a lot prettier than command-line apps). I’ve never been one to learn from books, so my current coding style is such that whenever I encounter a problem, I turn to Google.

Today, Google failed me.

I felt like playing around with NSLevelIndicator, as it’s a fancy 10.4 indicator that just looks cool. After hooking it up in Interface Builder, I tried to interact with it. Aside from setting the runtime value, I couldn’t figure out the command to set the value on the fly. The Apple documentation was no help, as all it provided was information on setting ranges and tick marks.

discreteLevelIndicator
greenLevelIndicator
yellowLevelIndicator
redLevelIndicator

No other sites could help me either. It turns out the solution was easier than I had expected: [NSLevelIndicator setDoubleValue:1.3]; (or any double value). It should also respond to setIntValue:n and setFloatValue:n.nn.

Other useful tidbits:

[NSLevelIndicator setFrameRotation: 90.0]; //makes a vertical NSLevelIndicator
[NSLevelIndicator setContinuous:YES]; //allows user interaction via dragging
[NSLevelIndicator setEnabled:NO]; //disables user interaction, enabled by default

One Response to “NSLevelIndicator”

  1. Matt Says:

    Thanks that was very helpful :)