This post and the next show a simple example of dragging in Cocoa. We make a single simple shape, and position it randomly within the view. This code makes use of the C functions srand() and random(), and I wrote a short function to encapsulate this:
I noticed something unexpected. When I set the contentView of the window to be of class "MyView", its
initWithFrame:method does not get called. This only happens if a put a custom view in the window. I don't know why.
In the code listing, I've tacked on the instance variables, for convenience. Some of these are only used next time.