ios - How to bind the control on the form with variable -
i start studying ios developing watching stanford ios course, looks have missing something.
i have form uilabel , uibutton. when user press button title of button must added text of label.
here current calculatorviewcontroller.h:
#import <uikit/uikit.h> @interface calculatorviewcontroller : uiviewcontroller @property (weak, nonatomic) iboutlet uilabel *display; @end and here calculatorviewcontroller.m:
#import "calculatorviewcontroller.h" @implementation calculatorviewcontroller @synthesize display = _display; - (ibaction)digitpressed:(uibutton *)sender { nsstring *digit = [sender currenttitle]; uilabel *mydisplay = self.display; mydisplay.text = [mydisplay.text stringbyappendingstring:digit]; } @end the problem self.display (and mydisplay) variables have nil value. looks need link variable control on form. ?
thanks in advance.
you need link control, uilabel in interface builder variable in calculatorviewcontroller class.
it file's owner (talking xib file) calculatorviewcontroller, need control+drag file's owner (or object representing vc) control , shown menu possible iboutlet variables declared in class, select 1 want represent control.
you can check if link set in 2 ways: (1) select uilabel in interface builder , see if there's connection variable in connections inspector, or (2) in code you'll see bullet near iboutlet declaration, if bullet hollow connections not set, if bullet filled connection set.
Comments
Post a Comment