0

Basically I am doing some computation for which I need to have an Int variable initiating with 0 in cellForRowAtIndexPath everytime I reload the table view.

In Objective-C, I used this in cellForRowAtIndexPath of UITableView

static int rowSum= 0; 
rowSum += [[myArray objectAtIndex:indexPath.Row] intValue];

How do we do this in Swift language ? The suggested link does not do that.

iOS_Passion
  • 788
  • 1
  • 7
  • 17
  • 1
    How did you do it in Objective-C? It doesn't sound like a `static` at all, from what you've said so far. – matt Jun 28 '15 at 13:29
  • It compiles in objective-c but what purpose was served by calling it static? – matt Jun 28 '15 at 13:49
  • I have a textfield in cell in which a number will be entered by the user. So Something like this I want to do - static int rowSum= 0; for(int i=0; i<=10;i++){ rowSum+= rowSum + TextFieldValue} – iOS_Passion Jun 28 '15 at 13:53
  • 1
    exact duplicate of [Static function variables in Swift](http://stackoverflow.com/questions/25354882/static-function-variables-in-swift) – nhgrif Jun 28 '15 at 13:54
  • Matt - please see the edit :-) – iOS_Passion Jun 28 '15 at 14:19

0 Answers0