Selectores en Objective-C
Los nombres de método se intercalan con sus argumentos, por partes.
#import <Foundation/Foundation.h>
int main(void) {
@autoreleasepool {
// A selector's name interleaves with its arguments: this one
// is stringByReplacingOccurrencesOfString:withString:.
NSString *sleeve = @"mono pressing, mono mix";
NSString *fixed =
[sleeve stringByReplacingOccurrencesOfString:@"mono"
withString:@"stereo"];
NSLog(@"%@", fixed);
// Ranges pair a location with a length.
NSRange hit = [fixed rangeOfString:@"stereo"];
NSLog(@"First hit at %lu, length %lu",
(unsigned long)hit.location, (unsigned long)hit.length);
}
return 0;
}
Cómo funciona
stringByReplacingOccurrencesOfString:withString:es un solo nombre.- Cada dos puntos marca dónde encaja un argumento.
rangeOfString:devuelve un struct NSRange, leído con puntos.
Palabras clave y builtins usados aquí
NSStringintlongreturnunsignedvoid
El intento, en números
- Líneas
- 19
- Caracteres a escribir
- 549
- Tokens
- 90
- Ritmo de tres estrellas
- 60 tpm
Al ritmo de tres estrellas de 60 tokens por minuto, este intento toma unos 90 segundos.
Paso 2 de 3 en Mensajes; paso 5 de 27 en Fundamentos del lenguaje.