Note that there are some explanatory texts on larger screens.

plurals
  1. POConceptually, how should this be structured in OOP?
    primarykey
    data
    text
    <p>So I have an UIImageView which can be rotated about its center with touchesMoved.</p> <p>Currently all the code is inside my ViewController, detecting the touch, calculating and tracking current rotation, the image itself and the actual rotation of the image.</p> <p>But now I want to tidy this up and do it properly. This 'spinner' I have created should be a distinct object which can be instantiated multiple times and dropped in wherever I need it.</p> <p>So I create my new Spinner class and it keeps track of its own image and angle properties...</p> <p>But should this be an NSObject with an UIImageView property, or is it an actual UIImageView itself? And how should the touches be handled, does the ViewController need to play a part or can the object somehow track its own touches?</p> <p>-</p> <p>Edited: Still hoping for a clear answer to this old question of mine.</p> <p>UIControl subclass I suppose kind of makes sense when my spinner is little more than an abstract image which spins and respond to touches.</p> <p>But when it is more complex with position, velocity, needs to interact with other objects, persist across multiple launches (NSManagedObject subclass?) etc. Touch and image become only a small part of the whole. This is why I was thinking the UIImage would just be another property of the object.</p> <p>As a simple example think of a bunch of balls bouncing around in a box. They need to bounce off the sides, bounce off each other, spin around, respond to gravity, respond when touched - and persist between launches.</p> <p>So conceptually, how should this be structured in OOP?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload