Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Solving the warning in compiler: Sending 'BarCodeViewController *_strong' to parameter of incompatible type 'id<PerksDetailsDelegate>'
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
- {
- if ([segue.identifier isEqualToString:@"showBarCode"]) {
- BarcodeViewController *barCodeVC = (BarcodeViewController *)segue.destinationViewController;
- [self setDelegate:barCodeVC];
- }
- }
- #import Card.h
- #import PerksDetailsViewController.h
- #import BarcodeViewController.h
- @interface PerksDetailsViewController ()
- @end
- @implementation
- @synthesize delegate = _delegate;
- @synthesize myCard = _myCard;
- - (IBAction)redeemPressed:(id)sender {
- // get required points of a perk selected
- NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
- [f setNumberStyle:NSNumberFormatterDecimalStyle];
- self.pointsRequired = [f numberFromString: (self.pointsLabel.text)];
- NSLog(@"points required by the perk %@", self.pointsRequired);
- [self.delegate perksDetailsViewController:self didPassRequiredPoints:self.pointsRequired withCard:self.myCard];
- }
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
- {
- if ([segue.identifier isEqualToString:@"showBarCode"]) {
- BarcodeViewController *barCodeVC = (BarcodeViewController *)segue.destinationViewController;
- [self setDelegate:barCodeVC];
- }
- }
- @end
- #import <UIKit/UIKit.h>
- #import "Card.h"
- #import "BarcodeViewController.h"
- @class PerksDetailsViewController;
- @protocol PerksDetailsDelegate <NSObject>
- - (void)perksDetailsViewController:(PerksDetailsViewController *)sender
- didPassRequiredPoints: (NSNumber *) requiredPoints
- withCard: (Card *) selectedCard;
- @end
- @interface PerksDetailsViewController : UIViewController
- @property (nonatomic, strong) id <PerksDetailsDelegate> delegate;
- @property (nonatomic, strong) Card *myCard;
- @end
- #import "PerksDetailsViewController.h"
- @interface BarcodeViewController () <PerksDetailsDelegate>
- @end
- @implementation BarcodeViewController
- @synthesize myCard = _myCard;
- @synthesize resultingPoints = _resultingPoints;
- - (void)perksDetailsViewController:(PerksDetailsViewController *)sender didPassRequiredPoints:(NSNumber *)requiredPoints withCard:(Card *)selectedCard
- {
- double perksPoints = [requiredPoints doubleValue];
- self.myCard = selectedCard;
- self.resultingPoints = [NSNumber numberWithDouble:[selectedCard subtractPoints:perksPoints] ];
- }
- @end
- @interface BarCodeViewController : UIViewController <PerksDetailsDelegate> {
- ...
- }
Add Comment
Please, Sign In to add comment