daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Solving the warning in compiler: Sending 'BarCodeViewController *_strong' to parameter of incompatible type 'id<PerksDetailsDelegate>'
  2. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  3. {
  4.     if ([segue.identifier isEqualToString:@"showBarCode"]) {
  5.         BarcodeViewController *barCodeVC = (BarcodeViewController *)segue.destinationViewController;
  6.  
  7.         [self setDelegate:barCodeVC];
  8.  
  9.     }
  10. }
  11.    
  12. #import Card.h
  13. #import PerksDetailsViewController.h
  14. #import BarcodeViewController.h
  15.  
  16. @interface PerksDetailsViewController ()
  17.  
  18. @end
  19.  
  20. @implementation
  21. @synthesize delegate = _delegate;
  22. @synthesize myCard = _myCard;
  23.  
  24. - (IBAction)redeemPressed:(id)sender {
  25.     // get required points of a perk selected
  26.  
  27.      NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
  28.      [f setNumberStyle:NSNumberFormatterDecimalStyle];
  29.  
  30.      self.pointsRequired = [f numberFromString: (self.pointsLabel.text)];
  31.  
  32.     NSLog(@"points required by the perk %@", self.pointsRequired);
  33.  
  34.     [self.delegate perksDetailsViewController:self didPassRequiredPoints:self.pointsRequired withCard:self.myCard];
  35. }
  36.  
  37.  
  38. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  39. {
  40.     if ([segue.identifier isEqualToString:@"showBarCode"]) {
  41.         BarcodeViewController *barCodeVC = (BarcodeViewController *)segue.destinationViewController;
  42.  
  43.         [self setDelegate:barCodeVC];
  44.  
  45.     }
  46. }
  47.  
  48. @end
  49.    
  50. #import <UIKit/UIKit.h>
  51. #import "Card.h"
  52. #import "BarcodeViewController.h"
  53.  
  54. @class PerksDetailsViewController;
  55.  
  56. @protocol PerksDetailsDelegate <NSObject>
  57.  
  58. - (void)perksDetailsViewController:(PerksDetailsViewController *)sender
  59.              didPassRequiredPoints: (NSNumber *) requiredPoints
  60.                           withCard: (Card *) selectedCard;
  61.  
  62. @end
  63.  
  64. @interface PerksDetailsViewController : UIViewController
  65.  
  66. @property (nonatomic, strong) id <PerksDetailsDelegate> delegate;
  67.  
  68. @property (nonatomic, strong) Card *myCard;
  69.  
  70. @end
  71.    
  72. #import "PerksDetailsViewController.h"
  73.  
  74. @interface BarcodeViewController () <PerksDetailsDelegate>
  75. @end
  76.  
  77. @implementation BarcodeViewController
  78. @synthesize myCard = _myCard;
  79. @synthesize resultingPoints = _resultingPoints;
  80.  
  81. - (void)perksDetailsViewController:(PerksDetailsViewController *)sender didPassRequiredPoints:(NSNumber *)requiredPoints withCard:(Card *)selectedCard
  82. {
  83.  
  84.     double perksPoints = [requiredPoints doubleValue];
  85.  
  86.         self.myCard = selectedCard;
  87.         self.resultingPoints = [NSNumber numberWithDouble:[selectedCard subtractPoints:perksPoints] ];
  88. }
  89.  
  90. @end
  91.    
  92. @interface BarCodeViewController : UIViewController <PerksDetailsDelegate> {
  93. ...
  94. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top