is a microblog
home archives search feed blogroll

How I Declare Private Variables In Objective-C

In the implementation (.m) file.

@implementation MyClass {
  NSObject *_myPrivateObject;

You could also do this (still in the implementation file).

@interface MyClass () {
  NSObject *_myPrivateObject;

@implementation MyClass


It makes less sense to me. Private variables are related to the implementation, not the interface. It also takes more lines of code to do basically the same.

Posted on 2018-03-29   #objc  

← Next post    ยท    Previous post →