Great challenge! (Could do with a cheat Appendix, though!)
I’m happy enough (I think) to pick up the checks but how to I programmatically remove the ticks? I found from the net but I can’t get IB to recognise it as a property/method of the Slider (which I have set up as an Outlet!). The answers in other forms seem very terse and no-one likes to give code snippets!
Are you sure that’s the method name?
Forget the 'net; Apple’s documentation is more reliable.
Well, that was the name I picked up but I’m still struggling to work out the way various elements are named in the documentation. (I’m a windows renegade and there’s still a lot about the Apple world that I’m finding a challenge.)
However, I’ve sorted my problem, thanks. I was trying to link to the Slider when I should have been referencing the SliderCell. Once I did that, it was relatively easy to find the right method. I had a similar what-am-I-actually-linking-to problem at the other end of the equation: I had an IBAction on the radio button Matrix when it ought to have been on the individual button cells.
I’m learning - and I think the challenge is a great idea.
[Wish/gripe: why doesn’t the property/method API documentation provide small gobbits of code to provide an idea of what they really look like - dare I say, as .NET docs.)
gc3186: thanks for the response, anyway.
Glad you got it working, Len!
Apple DOES publish some code samples, but you’re right – they’re not always easy to find, and they’re not right there with each method in the docs. Instead, their code samples are in stand-alone projects. I think the intent is to provide enough working code as a base for further experimentation.
Here’s a link to the NSSlider documentation on their web site (probably more useful than the link I posted previously). At the bottom of the left nav are links to sample projects.
Clicking the Mac Developer Library link at the top left of the page takes you to the firehose from which to drink.
Lastly, you mentioned earlier about wanting a “cheat Appendix”. I’m not sure if this is what you meant, but solutions to the exercises are available for download (see “Download Solutions”).
Oh, and welcome to Cocoa! You picked a good time (with the move to Swift rapidly underway) and – for my money, anyway – the right place (BNR) from which to learn. (I’m not affiliated either with Apple or with BNR, except in the latter case as a former student.) Best of luck!
As a footnote, I should add that I was slow in grokking the slider (and especially the radio buttons). Objective-C (particularly pre-dot-notation), I understand. But I wasn’t getting the translation to Swift.
Inferring from this video brought it home for me, though as with the book (p. 81) I used specific class names for the senders rather than ‘AnyObject’ from the video. (And from watching that, I didn’t have an outlet either to NSSliderCell or to NSButtonCell, only to NSSlider and to NSMatrix…FWIW.)
Now I think I get it:
// Obj-C (pre-dot-notation)
[verticalSlider setNumberOfTickMarks: 0];
// Obj-C (dot notation)
verticalSlider.numberOfTickMarks = 0 //...which gets converted to the above
// Swift
verticalSlider.numberOfTickMarks = 0
Silly me: I kept trying to call setNumberOfTickMarks from Swift, where I should be thinking in terms of ObjC dot notation (as far as the documentation goes).