You can also just create a category on UIView that defines a property which could store a object.
@property (nonatomic, strong) id context;
or
@property (nonatomic, weak) id context;
if you are sure the context will always exist.
Re:Android Development Tips For iOS Devs
by bookwormAT on Thursday March 13, 2014 @06:32PM
(#7395596)
If you use ViewHolder, consider using custom views instead:
http://blog.xebia.com/2013/07/22/viewholder-considered-harmf...
I refactored all my code after reading this, and now I consider the ViewHolder an antipattern.
It is incredible how much cleaner and readable my codebase is with custom views. And the performance is the same.
Yes, but if it's something like a ListView, don't put offset in array there, because the views are recycled (when user scrols), so you're likely to end up with corrupted data. I got bitten by this in the beginning. You can go to great lengths to prevent this from happening, but it will be hard for a reason, because that's abusing the design principles.
I'd recommend reading up on the ViewHolder pattern in this context.
Long story short: cache all the references to all specific sub-views of the row view in the tag (so you don't have to retrieve them again and again) - that's good practice. Just don't store any position-specific data in it.
Watch http://youtu.be/wDBM6wVEO70?t=9m50s - very informative