But then, when I try to manipulate the view from the view controller, I get an error. For instance:
myView.layer.position = CGPointMake (20, 160);
When I use CALayer, this code works fine. But now that I'm inheriting from it, it produces an error saying that the property has not been found for this class.
Does anyone know why I'm not being allowed to do this?
But then, when I try to manipulate the view from the view controller, I get an error. For instance:
myView.layer.position = CGPointMake (20, 160);
When I use CALayer, this code works fine. But now that I'm inheriting from it, it produces an error saying that the property has not been found for this class.
Does anyone know why I'm not being allowed to do this?
Any help appreciated,
Thanks,
Adam
Show us the header file for your custom CALayer subclass CustomLayer
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
When a layer is animating from one point to another, I need a way of figuring out its exact position on screen at any one time. These properties were to help me do that.
Thanks,
Adam
When a layer is animating from one point to another, I need a way of figuring out its exact position on screen at any one time. These properties were to help me do that.
Thanks,
Adam
position is probably a "fake" property that has a setter, but not an iVar. I've run into odd compiler issues with properties before where the "dot notation" won't work, but the setter form will. Try rewriting your line like this:
[myView.layer setPosition: CGPointMake(x,y)];
Code:
Also, if you want to change one of the properties of your custom subclass of CALayer, remember you need to cast the view property to your custom type before you can refer to your custom properties:
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Thanks for the help, I thought that had solved it. Only now, when I want to retrieve the position of the layer, by writing this:
Code:
[myView.layer position];
I get a warning telling me that there are multiple methods named "position". It doesn't do this when try to set the position.
I haven't written any methods called position myself. Any ideas why this might be happening?
Again, thanks a lot for the help.
No, I don't know why you're getting that warning. Odd.
BTW, you should almost always declare your properties as (nonatomic).
If you don't, the system adds code that applies multi-threading locks to your getters and setters, which slows down your code unnecessarily. The only time you want your properties to be atomic is if you're reading/writing them from multiple threads at the same time.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.