He estado enseñando Objective-C durante aproximadamente 6 meses y me gusta mucho usar el lenguaje. Sin embargo, no he encontrado ningún buen estándar de codificación, por lo que el código que escribo siempre termina pareciendo un desastre incoherente.Objective-C Coding Standards?
Cosas como las convenciones de nomenclatura se llevan bien, pero el espaciado, la sangría y el (imposible) ancho de línea de 80 caracteres no funcionan tan bien.
¿Qué convenciones usas con Objective-C?
Aquí es un pequeño ejemplo de algo que no está funcionando:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
self.navigationItem.leftBarButtonItem =
[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self.parentViewController
action:@selector(done:)] autorelease];
NSString* units = [[NSString alloc] initWithFormat:@"%@", @"oz"];
NSString* optionOne = [[NSString alloc] initWithFormat:@"[%d%@] Calculate", 100, units];
self.options = [[NSMutableArray alloc] initWithObjects:
optionOne,
@"Configure Portions",
@"Configure Notifications",
@"Help",
nil];
[units release];
[optionOne release];
[tableView reloadData];
}
return self;
}
https: // github.com/raywenderlich/objective-c-style-guide # language – thesummersign