2014年7月24日 星期四

2014年7月8日 星期二

防止繼承的delegate跟原本的衝突(how to extend a protocol for a delegate in objective C)

@interface PlaceView () <MapViewDelegate> {
    id placeSelegate;
}

@end

@implementation PlaceView

- (id)init
{
    self = [super initWithSearch];
    if (self) {
        super.delegate = self;
    }
    return self;
}

# pragma mark public PlaceView

- (void)setDelegate:(id)delegate
{
    placeSelegate = delegate;
}

- (void)done
{
    if ([placeDelegate respondsToSelector:@selector(placeSelected:)])
    {
        [placeDelegate placeSelected:[map placeInfo]];
    }
}