<span id="Label3"></p><p><p>today, Liu Guobin Teacher spoke about the OC language of the delegation mode (proxy mode), through a dozen hamster game explained the function of the commissioned mode, and then explained the Protocol's writing and Use.</p></p><p><p>The mouse function including the screen randomly appears on the mouse, click disappear, if not 5 seconds after the automatic disappearance, the upper right corner of the screen has a label to show the number of clicks; writing thinking is, first in the file to see a class, rewrite the Init method in the class, plus Each. 5 Seconds of events, pour the viewcontroler file, declare an attribute delegate in the rodent, the button click event plus the creation of the object point delegate call Viewcontroler in the addition method.</p></p><p><p>The use of the protocol to create the object first, the three-step sequence is generally used by Apple to write to us the control, do not write the Protocol.</p></p><p><p>one, with the object point delegate</p></p><p><p>second, If you can point out the delegate then the control has a protocol, to interface to write the protocol</p></p><p><p>third, See if there are any methods that must be implemented in the Agreement.</p></p><p><p>-(void) Viewdidload {</p></p><p><p>[super viewdidload];</p></p><p><p>Self.lb=[[uilabel alloc]initwithframe:cgrectmake (0, 0, 55,55)];</p></p><p><p>Self.lb.backgroundcolor=[uicolor redcolor];</p></p><p><p>[email protected] "0";</p></p><p><p>[self.view addSubview:self.lb];</p></p><p><p></p></p><p><p>[nstimer scheduledtimerwithtimeinterval:1 target:selfselector: @selector (moo) userinfo:nil repeats:yes];</p></p><p><p></p></p><p><p>}</p></p><p><p>-(void) moo{</p></p><p><p>Mouse *mm=[[mousealloc]initwithframe:cgrectmake (arc4random ()%333,arc4random ()%666, 33, 33)];</p></p><p><p>Delegate mode, An instance of an object, in the Mose another attribute Viewcontroller *vc, called the object mm point out his attributes, and then put their own page to the attribute VC Mm.</p></p><p><p>mm.vc=self;</p></p><p><p>[self.view addsubview:mm];</p></p><p><p></p></p><p><p>}</p></p><p><p>Declares the method, called the mouse class, each time this method is called the text value of the label plus One</p></p><p><p>-(void) adds{</p></p><p><p>int old=self.lb.text.intvalue;</p></p><p><p>int new=old+1;</p></p><p><p></p></p><p><p>[email protected] (new). stringvalue;</p></p><p><p>}</p></p><p><p></p></p><p><p>Lan Yi iOS Delegate mode proxy mode</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service