Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Learning Aids/Tools 2 years ago
Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I'm just trying to build a simple delegate, it compiles successfully but it doesn't seem to do anything right now. Please review my code below, both FirstViewContoller and SecondViewController have separate xib files, the SecondViewController has a button hooked up to the myMethod of course.
I've been learning my way around objective c and iPhone SDK for a couple of months, I've been using a book and lynda.com tutorial to aid, I actually copied most of the code using the xcode template for a utility app, and I believe I understand what is going on here, but is there something I've missed, as the button isn't responding.
If you need more info please ask.
Many thanks, Chris
SecondViewController.h
#import @protocol SecondViewControllerDelegate; @interface SecondViewController : UIViewController { id <SecondViewControllerDelegate> delegate; } @property (nonatomic, assign) id <SecondViewControllerDelegate> delegate; -(IBAction) myMethod; @end @protocol SecondViewControllerDelegate -(void)viewControllerDidFinish:(SecondViewController *)controller; @end
SecondViewController.m
@implementation SecondViewController @synthesize delegate; -(IBAction) myMethod { [self.delegate viewControllerDidFinish:self]; } // @end
FirstViewController.h
@interface FirstViewController : UIViewController <SecondViewControllerDelegate>{ // @end
FirstViewController.m
@implementation FirstViewController -(void)viewControllerDidFinish:(SecondViewControllerDelegate *)controller { NSLog(@"delegate is being used"); } // @end
Edit - This is an old post but just to clarify I simply forgot to assign the SecondViewController delegate in the FirstViewController
How do you assign the delegate property of SecondViewController? This is the last part I am missing...
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.