Guest User

Passing object from controller to a view

a guest
Feb 27th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #import "PolygonShape.h"
  2.  
  3. @interface CustomView : UIView {
  4. IBOutlet PolygonShape *polygon;
  5. }
  6. - (NSArray *)pointsForPolygonInRect:(CGRect)rect numberOfSides:(int)numberOfSides;
  7.  
  8. @end
  9.  
  10. #import <UIKit/UIKit.h>
  11. #import <Foundation/Foundation.h>
  12. #import "PolygonShape.h"
  13. #import "PolygonView.h"
  14.  
  15. @interface Controller : NSObject {
  16. IBOutlet UIButton *decreaseButton;
  17. IBOutlet UIButton *increaseButton;
  18. IBOutlet UILabel *numberOfSidesLabel;
  19. IBOutlet PolygonShape *polygon;
  20. IBOutlet PolygonView *polygonView;
  21. }
  22. - (IBAction)decrease;
  23. - (IBAction)increase;
  24. - (void)awakeFromNib;
  25. - (void)updateInterface;
  26. @end
  27.  
  28. #import "PolygonShape.h"
  29.  
  30. @interface CustomView : UIView {
  31. IBOutlet PolygonShape *polygon;
  32. }
  33.  
  34. @property (readwrite, assign) PolygonShape *polygon;
  35.  
  36. - (NSArray *)pointsForPolygonInRect:(CGRect)rect numberOfSides:(int)numberOfSides;
  37.  
  38. @end
  39.  
  40. @implementation CustomView
  41.  
  42. @synthesize polygon;
  43.  
  44. ...
  45.  
  46. @end
  47.  
  48. - (void)awakeFromNib {
  49. // configure your polygon here
  50. polygon = [[PolygonShape alloc] initWithNumberOfSides:numberOfSidesLabel.text.integerValue minimumNumberOfSides:3 maximumNumberOfSides:12];
  51. [polygonView setPolygon:polygon];
  52. NSLog (@"My polygon: %@", [polygon description]);
  53. }
Add Comment
Please, Sign In to add comment