Reputation: 922
I'm not very experienced with either C++ or iOS, so I'm just curious if iOS the reference counting works basically alike in boost shared pointers and in NSObject?
Upvotes: 4
Views: 1463
Reputation: 56976
From what I gather here, using ARC is very similar to using std::shared_ptr
("strong" pointers) and std::weak_ptr
("weak" pointers).
Abuse the former, and avoid the latter. Anyway, prefer std::unique_ptr
if you can.
(Also, I am somewhat astonished that you had to release pointers manually when programming for iOS. In the 21st century.)
Upvotes: 2
Reputation: 4289
I'm not very experienced with C++ so I may be not completely correct about shared_ptr, but for me they doesn't seem alike. In Obj-C there're two options. Manual memory management - you manually increment and decrement reference counts for your objects, no magic occurs here. And new ARC which is mostly compile-time feature, while shared_ptr is just runtime implementation.
Upvotes: 0