I have a simple question. How I indent a very long line. Let’s use the traditional 80 caracters.
This is a line in my code:
NSString *count = [[NSString alloc] initWithString: [sTemp substringFromIndex:[sTemp rangeOfString:@"count="].location + [sTemp rangeOfString:@"count="].length]];
One solution was
NSString *count = [[NSString alloc] //line 1
initWithString: [sTemp substringFromIndex:
[sTemp rangeOfString:@"count="].location +
[sTemp rangeOfString:@"count="].length]];
This is not the best sample, but the idea is:
- Ok, the first line is the assignment and alloc thing.
-
The line 2 indent with a fell more right space. But, if the name of variable or type is very big, I will have the situation above. What I do?
NSStringWithVeryBigType *bigNameVariable = [NSStringWithVeryBigType alloc] initWithString: [sTemp substringFromIndex: - IN second line I create a new NSString. I can be confuse if the line 3 and 4 (in a bad situation, not this) is the main function creation, or is this new one. Have a good rule about it? And if it have a big name too, what to do again…
In other words, in a big assignment line, what rule I have to fallow?
I’d do something like: