iOS usual note 1

Source: Internet
Author: User

There are some errors when writing the OC code look at your friends in the usual attention to write a small error I will continue to summarize

1.

[Nstimer scheduledtimerwithtimeinterval:1 target:self selector: @selector (timesaction:) Userinfo:nil Repeats:yes]; This is a timer initialization method but remember the usual when writing, when the timer method may be timesaction: in the: Lost at this time Xcode will not error, but the compiler will not be reported when the initialization timer method instead of stopping in

[[Nsrunloop Currentrunloop]run];

Unrecognized selector sent to instance 0x100202c60 explained that he did not find a matching method.

2. When using KVO, it is not possible to reduce the attribute value with a--because in this method when writing the listener

[_children addobserver:self forkeypath:@ "Happy" options:nskeyvalueobservingoptionnew | Nskeyvalueobservingoptionold context:@ "Hahahah"]; on which he returned the dictionary key to old and new on the other, if it is a--it will be the value of the original value assigned to old and new and then the value will be unchanged. Because he hears the value and the original value has not changed, if the value has not changed, then will not carry on the method of the reaction, note: a--is the first value and then self-reduction.

3. How do you do it? The value of an int is divided into hundred

NSLog (@ "The child's cleanliness%0.1f%%", tim/100.0*100); In this%0.1f%% ", tim/100.0*100 the first percent is a must write the mark can not tube, tim/100.0* 100 This allows one decimal to be left at the end of the calculated number.

iOS usual note 1

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.