Question

I have a single MKAnnotationView that changes it's image based on various situations in my app.

I'm building a finite state machine that defines each of these states and interprets events that bring them about.

I'm considering building my state machine inside a subclass of MKAnnotationView that I only assign to the user location annotation, and then sending it messages based on events.

Is this a good idea? Or should my state machine should be a singleton, kind of hovering and separated from the objects themselves?

Thanks

Was it helpful?

Solution

I wouldn't go singleton unless the state of the machine should be consistent across multiple annotations on multiple views.

I would generally be looking at giving the ownership to the view controller which owns the annotation. The view controller subscribes to all of the events and updates the state machine, it then applies the state machine result to the annotation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top