I have been having a strange problem using a custom delegate class in ARC. In the viewcontroller after viewDidLoad I call the toolbars setDelegate method and assign the viewcontroller as the delegate.
Whenever I try to reference delegate, it is nil, even after being set in the viewcontroller.
//MPToolbar.h
#import <UIKit/UIKit.h>
//Define the protocol for the delegate
@class MPToolBar;
@protocol MPToolBarDelegate <NSObject>
@required
- (void)writeButtonSelected;
- (void)writeButtonDeSelected;
@end
@interface MPToolBar : UIView{
    id <MPToolBarDelegate> delegate;
}
@property(strong) UIButton *lastButton;
@property(strong) id <MPToolBarDelegate> delegate;
-(IBAction)buttonSelected:(id)sender;
-(void)resizeForOrientation:(UIInterfaceOrientation)orientation;
@end
//MPToolbar.m
#import "MPToolBar.h"
@implementation MPToolBar
@synthesize lastButton, delegate;
- (id)initWithFrame:(CGRect)frame
{
    if ((self = [super initWithFrame:frame])) {
        // Initialization code
    }
    NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"MPToolBar" owner:self options:nil];
    [self addSubview:[nibViews objectAtIndex:0]];
    return self;
}
#pragma button actions
-(IBAction)buttonSelected:(id)sender{
    UIButton *btn = (UIButton *)sender;
    if(lastButton && lastButton != btn)[self deselect:lastButton];
    if (btn.selected){
        [self deselect:btn];
        return;
    }
    [btn setSelected:YES];
    lastButton = btn;
    switch (btn.tag) {
        case 0:
            [self.delegate writeButtonSelected];
            break;
    }
}
-(void)deselect:(UIButton *)btn{
    [btn setSelected:NO];
    switch (btn.tag) {
        case 0:
            [self.delegate writeButtonDeSelected];
            break;
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/
-(void)resizeForOrientation:(UIInterfaceOrientation)orientation{
    if (UIInterfaceOrientationIsLandscape(orientation)) {
        self.frame = CGRectMake(0, 44, 1024, 60);
    }
    if (UIInterfaceOrientationIsPortrait(orientation)) {
        self.frame = CGRectMake(0, 44, 768, 60);
    }
}
@end
//ViewTest.h
#import <UIKit/UIKit.h>
#import "MPToolBar.h"
@interface ViewTest : UIViewController <MPToolBarDelegate>
{
    MPToolBar *toolBar;
}
@property(strong) MPToolBar *toolBar;
@end
//ViewTest.m
#import "ViewTest.h"
@interface ViewTest ()
@end
@implementation ViewTest
@synthesize toolBar;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.toolBar = [[MPToolBar alloc] initWithFrame:CGRectMake(0, 44, 1024, 60)];
    [self.view addSubview:self.toolBar];
    [self.toolBar setAlpha:1.0];
    [self.toolBar setDelegate:self];
    // Do any additional setup after loading the view from its nib.
}
#pragma mark - MPToolBar Delegate Methods
-(void)writeButtonSelected{
    //set new annotation for write mode and size to screen bounds.
    NSLog(@"writeButtonSelected");
}
- (void)writeButtonDeSelected{
    NSLog(@"writeButtonDeSelected");
}
- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}
@end
 
     
     
     
    