Is it good to access View controller from Custom Gesture via the view it is connected to?

153 views Asked by At

I am trying to manipulate a 3D object with gestures. In order to accomplish my task I need to implement some custom GesturesRecognizer.

I am subclassing UIGestureRecognizer to detect the gestures.

What I need to do is to access the vertices of the 3D object, which is drawn on the screen. I have this data in my ViewController class. Say, I want to know the normal of the facet use r is touching.

Although, I can try to access ViewController from the View which will be connected to the Custom Gesture by some means, I dont think, this is a good way to access the object.

My question here is...

Is it ok to make an instance variable of some struct holding vertex/normal information of a 3D object in View controller.

If not what would be the best way to store such information to render objects.

Another thing I want to ask here is

Is it a good way to access View Controller from Custom Gesture through the view it is connected to?

Kindly suggest me the best way handle my problem.

1

There are 1 answers

2
ayoy On

Can't you set up and handle the gesture recognizer in view controller's code instead of view's code? That would enable you to access view controller's data in an easy and clear way.

And regarding vertex/normal struct, have you considered creating a model (data source) for your view and keeping that kind of data over there? That would seem a sane solution from MVC point of view.