Parcourir la source

Update README

Fix Swift code sample so that it doesn't try to do `stringByAppendingPathComponent` on `String` object (because that method no longer exists). You can use `NSString` or shift to use `NSURL` pattern as suggested here.
Robert M. Ryan il y a 10 ans
Parent
commit
64c9266a78
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 3 3
      README.markdown

+ 3 - 3
README.markdown

@@ -283,10 +283,10 @@ To do this, you must:
 If you do the above, you can then write Swift code that uses FMDatabase. For example:
 
 ```swift
-let documentsFolder = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
-let path = documentsFolder.stringByAppendingPathComponent("test.sqlite")
+let documents = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
+let fileURL = documents.URLByAppendingPathComponent("test.sqlite")
 
-let database = FMDatabase(path: path)
+let database = FMDatabase(path: fileURL.path)
 
 if !database.open() {
     println("Unable to open database")