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

tombuarts

macrumors newbie
Original poster
Jan 30, 2010
15
0
I have a view called BlueView that calls a modal view called DatePick. When DatePick is dismissed by pressing a button I would like it to call a method in BlueView. Heres what I have so far:

In BlueViewController.h;

Code:
@protocol dateset
-(void)calculate; 
@end

@interface BlueViewController : UIViewController <dateset> {
	id <dateset> delegate;
(other code here)

@property(assign)id<dateset>delegate;

In BlueViewController.m

Code:
@synthesize delegate;

-(void)calculate {
(the method I would like to be called)

In DatePickController.m

Code:
- (IBAction) selectButtonPressed:(id)sender {
	chooseDate = [datePicker date];
	gotnewdate = 1;
	[delegate calculate];
At this point I am getting an error in DatePickController.m saying that "delegate" is undeclared. Any thoughts would be appreciated. Also, if you think there are other things missing, please let me know.
 
At this point I am getting an error in DatePickController.m saying that "delegate" is undeclared. Any thoughts would be appreciated.

If delegate is undeclared, then you need to declare it.

In this case, it's worth considering why class DatePickController can/cannot refer to a variable in class BlueViewController.
 
Ok, I declared delegate as an NSObject, and now I get an error stating "NSObject may not respond to -calculate". Any ideas?
 
Ok, I declared delegate as an NSObject, and now I get an error stating "NSObject may not respond to -calculate". Any ideas?

You're in over head. Stop, go back, review the basics.

If you're using a book, go back and work through the previous example or exercise.

If you're using an online tutorial, do the same thing.

If you're not using a book or online tutorial, then what you have is someone who doesn't know Objective-C trying to teach Objective-C. Would you take a class from someone who didn't understand what they were teaching?
 
Ok, I declared delegate as an NSObject, and now I get an error stating "NSObject may not respond to -calculate". Any ideas?

Why did you declare 'delegate as an NSObject'? Why do you think NSObject should respond to your own method 'calculate:'?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.