objective c - What is the default value of an NSUInteger in local scope? -


this question has answer here:

given following snippet:

- (void)dosomething {     nsuinteger count; } 

what count? guaranteed 0?

no, isn't guaranteed zero, since it's local automatic variable. without initialization, value indeterminate. if want zero, either initialize it:

nsuinteger count = 0; 

or define static:

static nsuinteger count; 

since variables static storage duration implicitly intialized zero, note has side effects (namely value persists between function calls).


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -