Is calling [self release] allowed to control object lifetime?

前端 未结 6 2255
终归单人心
终归单人心 2020-12-07 00:40

I want to create an object in Objective C but I don\'t hold a reference to it.

Is it allowed to let the object control its own lifetime by calling [self release]?

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 01:21

    It's legal, but be careful. You want to be sure nothing else is going to send you a message after you release yourself.

    I've done this kind of thing for a faulting scheme back before we had CoreData.

提交回复
热议问题