Hi,
I have an NSArray and i'd like to calculate the sum of the lenght of all previous objects with the length of current object.
Can you please help me? Thanks!
I have an NSArray and i'd like to calculate the sum of the lenght of all previous objects with the length of current object.
Can you please help me? Thanks!
PHP:
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSArray *myArray = [NSArray arrayWithObjects:@"One", @"Two", @"Three", nil];
unsigned count;
unsigned arrayCount = [myArray count];
for (count = 0; count < arrayCount; count++) {
NSInteger len = [[myArray objectAtIndex:count] length];
NSLog (@"thisObject: %i", len);
// How can i get the sumlen like this:
// sumlen #1 = 3
// sumlen #2 = 6
// sumlen #3 = 11
}
[pool autorelease];
return 0;
}