#import "UIViewController_TourGuide.h" #import "NSObject_Swizzle.h" static char tourStepsKey; @implementation UIViewController (TourGuide) + (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ [self swizzleInstanceSelector:@selector(viewWillAppear:) withNewSelector:@selector(tourGuideWillAppear:)]; }); } - (NSArray*) getTourSteps { return objc_getAssociatedObject(self, &tourStepsKey); } - (void) setTourSteps:(NSArray*)tourSteps { objc_setAssociatedObject(self, &tourStepsKey, tourSteps, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - (void) displayTour { // run the tour, and save the fact it was run } - (BOOL) isTourRan { // return TRUE if tour has been run } - (void) tourGuideWillAppear:(BOOL)animated { // call the old implementation, now under the new message signature [self tourGuideWillAppear:animated]; if (![self isTourRan]) { [self displayTour]; } } @end