Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aGupieWare/a5b73dde57c210f78e1f to your computer and use it in GitHub Desktop.

Select an option

Save aGupieWare/a5b73dde57c210f78e1f to your computer and use it in GitHub Desktop.
Swift client, url for item with description . . .
// extract the first two characters of an item's id //
let rangeOfHello = Range(start: itemID.startIndex, end: advance(itemID.startIndex, 2))
let prefixItemID = itemID.substringWithRange(rangeOfHello)
var url : NSURL?
switch prefixItemID
{
case "PT":
let filePath : String = "http://localhost:8888/api/v1/plumbing_tools/\(itemID).json"
url = NSURL(string: filePath)
case "CP":
let filePath : String = "http://localhost:8888/api/v1/copper_pipes_and_fittings/\(itemID).json"
url = NSURL(string: filePath)
default:
url = NSURL(string: "")
}
return url;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment