1
@interface ChargeView (){
    NSString* billid;
    int clickRow;
    NSMutableArray  *arr1;
}

@property (nonatomic, strong) NSMutableArray *arr2;

What's the difference between arr1 and arr2? Which is better or write it anywhere if I like?

Gank
  • 4,507
  • 4
  • 49
  • 45
  • 1
    possible duplicate of [Is there a difference between an "instance variable" and a "property" in Objective-c?](http://stackoverflow.com/questions/843632/is-there-a-difference-between-an-instance-variable-and-a-property-in-objecti) – Droppy Jun 04 '15 at 07:51
  • 2
    Could you search for one of the approximately 100 answers to this question? – gnasher729 Jun 04 '15 at 07:52
  • checkout http://stackoverflow.com/a/14236931/1298043 – Puttin Jun 05 '15 at 05:45

1 Answers1

4

The property also generates the accessors -(NSMutableArray *)arr2 (getter) and -(void)setArr2:(NSMutableArray *)arr2 (setter). It further generates a corresponding instance variable _arr2 (the underscore is convention for ivars). The attributes of the property determine the behavior of the accessors. For instance, if the property is marked atomic, the accessors will synchronize access to the ivar.

On the other hand, arr1 is just an ivar and you have to write accessors (if you need any) yourself.

Frank Rupprecht
  • 9,191
  • 31
  • 56