Take the 2-minute tour ×

I have one view controller (AViewController) and there I have table.
In that controller I have added another view controller view as a subview (BViewController):

BViewController *barCodeScanner = [[BViewController alloc]init];
[self.view addSubview:barCodeScanner.view];

BViewController has a delegate and one delegate method in it and it works.
But I want to refresh table on AViewController.
So I moved delegate to AViewController and try to change delegate code from:

rdr.readerDelegate = self;


rdr.readerDelegate = AViewController;

but it doesn't work. Why?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

You need to create an instance for AViewController and set it as a delegate to rdr:

rdr.readerDelegate = aViewControllerInstance;
share|improve this answer
add comment

AViewController is a type (a class) , not an instance of the type. Delegate accepts the instance of class, not class name.

share|improve this answer
add comment

hi may be this will clear you question.

AViewController *aView = [[AViewController alloc]init];

rdr.readerDelegate = aView ;

You need to set the object of AViewController as the delegate.

share|improve this answer
add comment

Your Answer


