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 an app that has a view (lets call it BlueView) that has various buttons on it that when pressed load a modal view that lets you select a date (lets call this view DatePick). I figured out how to pass the date back to the BlueView. The date that was picked will be used in a sub that exists in BlueView called calculate. What I need to figure out now is how do I call the calculate sub from the DatePick view as it is being dismissed? I don't know if i explained this good enough, and I've researched this as best I can. I simply don't know what the command/code that would invoke this is called. I am fairly new to this, but I have been able to work through numerous obstacles so far in my app design. I'm not looking for someone to post code that I can cut and paste, I just need to be lead in the right direction. Any help would be greatly appreciated. Thanks.
 
First, by "sub" do you mean "method"? Using the proper terminology will help the rest of us to better understand what you're asking.
 
First, by "sub" do you mean "method"? Using the proper terminology will help the rest of us to better understand what you're asking.

Yeah he means a method, bit of VB terminology there if I'm not mistaken.
 
It actually depends on the sub. For instance, chicken breast with Southwestern dressing crashes any app, I am told.
 
If it's an app wide command, and not unique to a particular pair of objects, sending a Notification from the caller, and registering a notification handler in the callee would also work.
 
Ok, I've been trying to figure this out and I am missing something. I set up the Protocol in BlueViewController.h like so;

@protocol dateset
[self performSelector:mad:selector(calculate)];
@end

I added #include "BlueViewController.h" to DatePickController.m and in the selectButtonPressed method I put

@protocol (dateset);

The date definitely gets passed to the BlueView when I press the Select button, but I can't call the calculate method in BlueViewController.m. I know something with the syntax for the protocol is incorrect, but I can't figure out what. I probably didn't describe this perfectly, but by the other posts I hope you can figure out what I am doing. Thanks for helping a newbie.
 
This sounds like a problem which can be solved by delegation.

Add a delegate instance variable to your DatePick. Have your blueView assign itself as the delegate for your DatePick. Have DatePick check for the existence of a delegate, and, if so, call the delegate method when it is being dismissed (or whatever).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.