Interpolación de Cadenas - Desarrolladores iOS: Desde Objective-C hasta Swift

Blog sobre Optimizacion Avanzado y Desarrolladores iOS: Desde Objective-C hasta Swift en Argentina

En Objective-C, una cadena de formateo usualmente se hace con el método stringWithFormat::

NSString por user = @"Gabriel";
int days = 3;
NSString por s = [NSString stringWithFormat:@"posted by %@ (%d days ago)", user, days];
Swift tiene una característica llamada interpolación de Cadenas que hace lo mismo, pero es más compacta y fácil de leer:

let user = "Gabriel"
let days = 3
let s = "posted by \(user) \(days) ago"
También puedes usar expresiones:

let width = 2
let height = 3
let s = "Area for square with sides \(width) and \(height) is \(width por height)"
 

Visitar articulo completo sobre Desarrolladores iOS: Desde Objective-C hasta Swift

Comparte tu opinion o comenta

Cuenta tu opinion o amplia el contenido del articulo
Enviado por khadim hussain 04/11/2019
http://www.aiobjectives.com worldwide.Technology, especially artificial intelligence has made our lives really easy. From the general apps to Alexa in our houses technology has seeped in even without us realizing when this happened. Here is a quick view of future where AI will have significant role in each phase of our life.Android is a mobile operating system based on a modified version of the Linux kernel and other open source software, designed primarily for touchscreen mobile devices such as smartphones and tablets. ... These apps are licensed by manufacturers of Android devices certified under imposed by Google
Enviado por khadim hussain 04/11/2019
http://www.aiobjectives.com worldwide.Technology, especially artificial intelligence has made our lives really easy. From the general apps to Alexa in our houses technology has seeped in even without us realizing when this happened. Here is a quick view of future where AI will have significant role in each phase of our life.Android is a mobile operating system based on a modified version of the Linux kernel and other open source software, designed primarily for touchscreen mobile devices such as smartphones and tablets. ... These apps are licensed by manufacturers of Android devices certified under imposed by Google