Tips for developing iOS (1)

Source: Internet
Author: User
Tags instance method

The development process will encounter a lot of small problems, the solution is just a word or a small knowledge point, can not gather up a blog post, therefore, the "tips for the development of the iOS" series blog, only to record the development of "Flash", the title of the blog post with the digital marker (1) (2) (3) .... , each article 30, will continue to update ....


1. Problem: Declare a protocol in a class (CustomView):

@protocol customviewdelegate-(void) showactionsheet; @end

A proxy is also defined:

@property (Nonatomic,strong) id<customviewdelegate> delegate;

However, the use of proxies is an error:

if ([Dele respondstoselector: @selector (showactionsheet)]) {...}

Error:

No known instance method for selector ' Respondstoselector: '

Reason: Declared protocol customviewdelegate not inherited <NSObject>



2, Question: exec_bad_access

The general reason is to send a message to an already Dealloc object, which can be debugged using nszombieenabled for this reason. The steps are as follows:

(1)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/70/C2/wKiom1W8vLmS_k2OAAGAnHA1JKo227.jpg "style=" width : 300px;height:88px; "title=" QQ20150801-1@2x.png "width=" height= "0" border= "0" hspace= "0" vspace= " Wkiom1w8vlms_k2oaaganha1jko227.jpg "/>



(2)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/70/BF/wKioL1W8wHjg1Y_UAAGZxVG6xnU261.jpg "title=" QQ20150801-2@2x.png "width=" "height=" 279 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:500PX;HEIGHT:279PX; "alt= "Wkiol1w8whjg1y_uaagzxvg6xnu261.jpg"/>

In this way, any object that is released will become an _ Nszombie, and when a message is sent to _nszombie, the corresponding error message is printed without crash or strange behavior.

Note: After debugging, remember to restore the previous settings, that is, cancel the nszombieenabled, otherwise all objects will not be released .








This article is from the "Layne Learning Corner" blog, please be sure to keep this source http://laynestone.blog.51cto.com/9459455/1680871

Tips for developing iOS (1)

Related Article

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.