I’m not sure what the book is really asking for here: “Create a new document-based application that allows the user to draw ovals in arbitrary locations and sizes. NSBezierPath has the following initializer:
init(ovalInRect: NSRect) -> NSBezierPath”
I’ve written a version that uses init(ovalIn: NSRect) -> NSBezierPath that will draw random sized ovals automatically with a click of the mouse, locating the origin of the oval where the mouse clicked in the view. – The book’s version of init(ovalInRect: NSRect) is now init(ovalIn: NSRect) – I had to add a custom view to the document view to get this to work. But this will only show one oval at a time (so far), and technically, I don’t think it is a real drawing app. I haven’t spent time trying to figure out how to save or undo this yet since I don’t know if it is the correct way to go.
I did another version that allowed me to draw ovals (as many as I wanted to draw) in the document view by dragging the mouse. But this version doesn’t use the suggested initializer, init(ovalIn: NSRect) -> NSBezierPath. And I haven’t figured out a way to save it yet, but can still work on that aspect if this is the correct path to take. I tried to add a computed oval over the drawn one using the mouse locations to come up with an origin and a rect of that size, then using the recommended init(ovalIn: NSRect) to draw the oval, but I get a whole list of runtime errors with that when it tries to fill().
Any ideas of what the intent was here? I know no one from BNR monitors this any more (unless some of you that have been kind enough to help me are from there) so I can’t get input from them.
Are either of these ideas on the path of what the intent for this challenge is, or am I way off? I don’t want to keep trying figure out a way to get either to work correctly if I’m way off.