Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

beardedpig

macrumors member
Original poster
Dec 17, 2008
57
0
I have written a class that is a subclass of UIImageView and has some custom methods in it.

I now find I need yet another UIImageView subclass along the same lines but with a different version of some of the methods.

I have been looking at using @Protocol but suspect as usual I haven't grasped the bleedin concept!

My thoughts were this:

Create the inteface file of the custom class like with the protocol in it like so:

Code:
#import <UIKit/UIKit.h>

@interface CustomImageView : UIImageView {

}

@protocol CustomImageViewMethods

-(void) doubleTap;

@end

I read that I do not need to create an implementation file as the class subclassing this will do so.

So I then create a class of type CustomImageView like so

Code:
@interface myImageView : CustomClassView <CustomImageViewMethods> {
}

and subsequently get more errors than you can wave a stick at!

Am I so far off beam I should be thrashed with a large iceberg lettuce?
 

d.ma

macrumors newbie
Jan 14, 2007
4
0
Just out of curiosity, what are the errors, specifically?
Also, does your myImageView class have a call to doubleTap the exact type and argument set that the protocol states?
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Couple random comments.

@protocol is related to delegation. If you're not setting up a delegate then your protocol doesn't make sense.

@protocol goes outside the @interface, not inside as you've shown it. The protocol is like a class declaration, although it has no code. A given class, the delegate, would adopt the protocol and implement it.
 

beardedpig

macrumors member
Original poster
Dec 17, 2008
57
0
Hi chaps,

yes I realise my error not only in protocol usage but also in the fact that all I needed to do was create a custom class of the required type and then subclass this!

live and learn....live and learn :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.