To send values โโto the parent controller, you must use protocols. I will provide the appropriate steps you must take to work with your desired features.
1. Create a protocol for your AddTeacherToCourseController. In AddTeacherToCourseController.h, add the following imports below:
@protocol AddTeacherToCourseControllerProtocol <NSObject> - (void)yourDelegateMethod:(Teacher *)insegnante; @end
And below add the interface tag:
@property (strong, nonatomic) id <AddTeacherToCourseControllerProtocol> delegate;
2. In AddTeacherToCourseController.m:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[this method will call your delegation method through the protocol and pass your selected professor to the parent controller]
3. In your parent controller, your newCourseViewController.h immediately after the interface line adds:
<AddTeacherToCourseControllerProtocol>
4. If you do not have an Insegnante button action, create it in the interface builder [drag and naming]. Then add the following to this action:
5. In Interface Builder:
- Remove your segment from the Insegnante button.
- Edit the storyboard identifier 'addTeacherToCourseViewController' in 'addTeacherToCourseViewController'
6. In newCourseViewController.h write your delegation method:
- (void)yourDelegateMethod:(Teacher *)insegnante{
Let me know if you have questions, and if my answer helped someone.
source share