Sto scrivendo una semplice applicazione che legge file CSV in Swift e mi piacerebbe poter usare lo stesso codice in Playground e come file di input per il comando swift
.Come determinare se un codice Swift è in esecuzione all'interno di XCode Playground
Per leggere un file in Playground devo usare questo codice
let filePath = XCPlaygroundSharedDataDirectoryURL.URLByAppendingPathComponent("data.csv")
vorrei realizzare qualcosa di simile:
#if PLAYGROUND
import XCPlayground
let filePath = XCPlaygroundSharedDataDirectoryURL.URLByAppendingPathComponent("data.csv")
#else
let filePath = NSURL.fileURLWithPath("data.csv")
#endif
Penso che si possa utilizzare l'identificatore pacchetto per determinare voi 're runni ng nel parco giochi - come ricordo è qualcosa come "com.apple.". playground. – Michael