Pages

Good to know ObjectiveC tips

  • To check arc is enabled or not, you can use macro called __has_feature, __has_feature(objc_arc) Macro expands to 1 if enabled else 0
  • If you wondering which code is modifying one of the property in your controller/class accidentally, You can just override setter method for that property in implementation file and set breakpoint inside it. This will aid you to finding the missing piece.
  • To avoid memory leaks on iOS projects. Never ever forget to write -dealloc method even you are using ARC. After some changes in you code always make sure if dealloc in all your classes is getting called or not.
  • In your code if you are allocating large number of objects using loops try to use @autoreleasepool  block which will revoke memory allocated to large number of objects after @autoreleasepool block scope is reached.