Autorelease and "assign" properties in Objective-C? (On iPhone) -
I have an example of a UITableView, and a different class that follows the representative and the data source protocol. I am doing this:
SubjectTableViewHandler * handler = [[SubjectTableViewHandler alloc] init] maintained]; Tv.delegate = Handler; Tv.dataSource = Handler; [Handler Autorequez]; I do not want to maintain the handler as an Ivor, and if I finally call keep , when autorelease Is sent to release , then added to the pool, which causes an EXC_BAD_ACCESS currently, the maintenance count is:
(1) Init: 1 (2) In maintaining: 2 (3) Representative / Data source properties are 'Assign', even though 2 (4) Autorelease: 1, now in the autorescence pool. But once again, 'Assign', they will never be released, counting will not be a hit anytime, and the handler will never be deprived. Is there any more efficient way to keep the handler as an Ivor and release it in the dealloc method?
When you initialize the object using init, you are claiming ownership of it And there is no reason to maintain. You also do not want to call autorelase because it will cause the object to be released in the loop to run.
Since you need to place a handler (methods so that your table view representative / data source may call) and a reference to the handler after the method returns (so that you can issue it to the table when it Can be issued), a clear perspective would be to make it an ivar.
Comments
Post a Comment