objective C underscore property vs self

前端 未结 4 1405
伪装坚强ぢ
伪装坚强ぢ 2021-01-04 00:28

I\'m was playing around with the standard sample split view that gets created when you select a split view application in Xcode, and after adding a few fields i needed to ad

4条回答
  •  孤城傲影
    2021-01-04 00:46

    In the course of your experiment, you've set up an endless loop which is why the simulator goes non-responsive.

    Calling self.detailItem within the scope of setDetailItem: calls setDetailItem: recursively since your class implements a custom setter method for the property detailItem.

    I would refer you to the Apple documentation on declared properties for the scoop on properties, ivars, etc; but briefly, declared properties are a simplified way of providing accessor methods for your class. Rather than having to write your own accessor methods (as we had to do before Objective-C 2.0) they are now generated for you through the property syntax.

提交回复
热议问题