Advertisement
Guest User

Vending Machinnn

a guest
Feb 18th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. //
  2. // VendingItemCell.swift
  3. // VendingMachine
  4. //
  5. // Created by Pasan Premaratne on 1/19/16.
  6. // Copyright © 2016 Treehouse. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class VendingItemCell: UICollectionViewCell {
  12.  
  13. @IBOutlet weak var iconView: UIImageView!
  14.  
  15. }
  16.  
  17.  
  18. // @IBOutlet is an Outlet
  19. https://developer.apple.com/library/prerelease/tvos/documentation/General/Conceptual/Devpedia-CocoaApp/Outlet.html#//apple_ref/doc/uid/TP40009071-CH4
  20.  
  21. An outlet is a property that is annotated with the symbol IBOutlet and whose value you can set graphically in a nib file or a storyboard.
  22. @property (nonatomic, weak) IBOutlet UITextField *nameField;
  23.  
  24.  
  25. The symbol IBOutlet is used only by Xcode, to determine when a property is an outlet; it has no actual value.
  26.  
  27.  
  28.  
  29.  
  30. From
  31. https://developer.apple.com/library/prerelease/tvos/featuredarticles/ViewControllerPGforiPhoneOS/DefiningYourSubclass.html
  32.  
  33. Delete all below to get to get to get to run code.
  34. Handling User Interactions
  35.  
  36. An app’s responder objects process incoming events and take appropriate actions. Although view controllers are responder objects, they rarely process touch events directly. Instead, view controllers typically handle events in the following ways.
  37.  
  38. View controllers define action methods for handling higher-level events. Action methods respond to:
  39.  
  40. Specific actions. Controls and some views call an action method to report specific interactions.
  41.  
  42. Gesture recognizers. Gesture recognizers call an action method to report the current status of a gesture. Use your view controller to process status changes or respond to the completed gesture.
  43.  
  44. View controllers observe notifications sent by the system or other objects. Notifications report changes and are a way for the view controller to update its state.
  45.  
  46. View controllers act as a data source or delegate for another object. View controllers are often used to manage the data for tables, and collection views. You can also use them as a delegate for an object such as a CLLocationManager object, which sends updated location values to its delegate.
  47.  
  48. Responding to events often involves updating the content of views, which requires having references to those views. Your view controller is a good place to define outlets for any views that you need to modify later. Declare your outlets as properties using the syntax shown in Listing 4-1. The custom class in the listing defines two outlets (designated by the IBOutlet keyword) and a single action method (designated by the IBAction return type). The outlets store references to a button and a text field in the storyboard, while the action method responds to taps in the button.
  49. Listing 4-1Defining outlets and actions in a view controller class
  50.  
  51. Objective-C
  52.  
  53. @interface MyViewController : UIViewController
  54. @property (weak, nonatomic) IBOutlet UIButton *myButton;
  55. @property (weak, nonatomic) IBOutlet UITextField *myTextField;
  56.  
  57. - (IBAction)myButtonAction:(id)sender;
  58.  
  59. @end
  60.  
  61. Swift
  62.  
  63. class MyViewController: UIViewController {
  64. @IBOutlet weak var myButton : UIButton!
  65. @IBOutlet weak var myTextField : UITextField!
  66.  
  67. @IBAction func myButtonAction(sender: id)
  68. }
  69.  
  70. In your storyboard, remember to connect your view controller’s outlets and actions to the corresponding views. Connecting outlets and actions in your storyboard file ensures that they are configured when the views are loaded. For information about how to create outlet and action connections in Interface Builder, see Interface Builder Connections Help. For information about how to handle events in your app, see Event Handling Guide for iOS.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement