objective c - What does "int count = [self count]" mean in this context? -


i guess basic question doing tutorial nick kuh's book "foundation iphone app development" , not understand line:

int count = [self count];

...really initiates "self"?

here whole code:

#import "nsmutablearray+shuffle.h"  @implementation nsmutablearray (shuffle)  - (void)shuffle {  int count = [self count];  nsmutablearray *dupearr = [self mutablecopy]; count = [dupearr count]; [self removeallobjects];  (int = 0; < count; i++) {      // select random element between , end of array swap with.     int nelement = count - i;     int n = (arc4random() % nelement);     [self addobject:dupearr[n]];     [dupearr removeobjectatindex:n];  }  }  @end 

since in category of nsmutablearray, self refers instance of nsmutablearray. count property of nsmutablearray returns number of objects contained array. line in question says number of items in current instance of nsmutablearray , store in variable named "count" of type int.

int count = [self count]; 

this written following, while remaining syntactically valid.

int count = self.count; 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -