Buscar..


Cómo obtener el último componente de cadena de NSURL String.

 NSURL *url = [NSURL URLWithString:@"http://www.example.com/images/apple-tree.jpg"];
 NSString *fileName = [url lastPathComponent];
 // fileName = "apple-tree.jpg"

Cómo obtener el último componente de cadena de la URL (NSURL) en Swift

Swift 2.3

let url = NSURL(string: "http://google.com/lastPath")
let lastPath = url?.lastPathComponent

Swift 3.0

  let url = URL(string: "http://google.com/lastPath")
  let lastPath = url?.lastPathComponent


Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow