Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

save file with % swift

func getDocumentsDirectory() -> URL {
    let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
    return paths[0]
}
Comment

save file with % swift

let str = "Super long string here"
let filename = getDocumentsDirectory().appendingPathComponent("output.txt")

do {
    try str.write(to: filename, atomically: true, encoding: String.Encoding.utf8)
} catch {
    // failed to write file – bad permissions, bad filename, missing permissions, or more likely it can't be converted to the encoding
}
Comment

PREVIOUS NEXT
Code Example
Swift :: How to convert String into Array of character 
Swift :: swift double v float 
Swift :: === in swift 
Swift :: swift create an empty dictionary 
Swift :: Single Line Comment 
Swift :: can you pass an enum as a parameter to a function swift 
Swift :: Swift Swift Function Return Values 
Swift :: uikit call swiftui view 
Swift :: swift ui view 
Swift :: two variable sum 
Swift :: swift out of bound elelemnt 
Swift :: swift session.input 
Swift :: Swift for Loop with where Clause 
Swift :: Log httpurlresponse swift 
Swift :: swift loop through array of objet 
Swift :: swift - salesforce chat only 
Swift :: Closure as function parameter 
Swift :: UISearchController keys 
Swift :: single word search swift 
Swift :: how to change the tint color of tab bar on storyboard swift 
Swift :: how request prefix of string in swift 
Swift :: ternary operator in swift 
Swift :: swift error handling 
Swift :: load plist swift 
Ruby :: how to match email in regex in ruby 
Ruby :: ruby select first n elements from array 
Ruby :: travis ci NameError: uninitialized constant SimpleCov 
Ruby :: ruby/rails file get line number 
Ruby :: rails change column type string to integer 
Ruby :: httparty SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate) (OpenSSL::SSL::SSLError) 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =