views:

50

answers:

1

Hi,

I followed on some advice given on this very forum and I am still having difficulty

I have the following:

    #import <UIKit/UIKit.h>


    @protocol UIViewForWheelProtocol

    - (void) returnImageNumber:(int)imgNum;

    @end


    #import <UIKit/UIKit.h>
    #import "UIViewForWheelProtocol.h";


    @interface UIViewForWheel : UIView {
        id<UIViewForWheelProtocol> delegate;
    }

    @property (nonatomic, assign) id<UIViewForWheelProtocol> delegate;



    @implementation UIViewForWheel

    @synthesize delegate;

    -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
       int num =1 ;
       [self.delegate returnImageNumber:num];
    }

#import <UIKit/UIKit.h>
#import "UIViewForWheel.h"
#import "UIViewForWheelProtocol.h"


@interface MainMenu : UIViewController <UIViewForWheelProtocol> {

}

-(void) returnImageNumber:(int)whichImage;

@end


    #import "MainMenu.h"


    @implementation MainMenu

    - (void) returnImageNumber:(int)whichImage
    {
        NSLog(@"HI %i", whichImage);
    }

HI 1 is not being displayed because although it is going to the touchesMoved function it is not going to the returnImageNumber in the MainMenu class.

Can someone please explain what I am doing wrong please?

+2  A: 

Ensure that you have manually assigned the delegate for UIViewForWheel, and that MainMenu conforms to that protocol UIViewForWheelProtocol.

Richard J. Ross III
what do you mean by manually assigned the delegate?
Lily
Like this: `UIViewForWheelProtocol p1 = [[MainMenu alloc] init]; myUiViewForWheel.delegate = p1;`
Richard J. Ross III
@Richard J. Ross III: `MainMenu* p1 = [[MainMenu alloc] init]; myUiViewForWheel.delegate = p1;` or `id<UIViewForWheelProtocol> p1 = [[MainMenu alloc] init]; myUiViewForWheel.delegate = p1;`
JeremyP
thanks Ill try this
Lily
this is in the UIViewForWheel class correct?
Lily