Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Without see any of your code, it sounds like you are in need of a protocol, which is that same thing as an interface in the java language. Protocols are a series of methods that a group of a few unrelated classes may need to used. For example, in a drawing program like PhotoShop, Rects, Ovals, and Images are all valid objects that can be stored as layers in a .psd document, however, they all share traits like the ability to change object properties in a particular way. An example would be adjusting an objects' opacity or rescale an objects size, etc. Methods that access the objects properties for scaling or functions that can be shared between unrelated objects types call for protocols.</p> <p>They are essentially .h files that list out the methods. The .m file that defines implementation of the code can store a tag in it's .h file.</p> <pre><code>// example of a class that acts as a protocol implementor @interface LayerObject: NSObject &lt;Resizable&gt; </code></pre> <p>The tag says, "I am a member of the protocol named X, you can find one/some of the methods of protocol X in my .m file." All you would have to do is import the protocol to the desired classes using the following syntax:</p> <pre><code>// Declare protocol @protocol Resizable; // List methods wanted from protocol - id resizeRect: id layerObject; </code></pre> <p>to gain the methods defined in the protocol.</p> <p>Here is a website that describes protocols through an example: <a href="http://agilewarrior.wordpress.com/2012/03/19/simple-objective-c-protocol-example/" rel="nofollow">http://agilewarrior.wordpress.com/2012/03/19/simple-objective-c-protocol-example/</a></p> <p>Another solution would be to create a class hierarchy that uses an abstract class to put the given drawRect method you are working in. From here you could define the two subclass you are working on as a subclass of the abstract class in which they would inherit the drawRect method code, keeping you from repeating the code in two separate classes.</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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