 
     init(documentURL: NSURL) {
         super.init(nibName: nil, bundle: nil)
+        let urlMetaData = documentURL.promisedItemResourceValuesForKeys(
+            [   NSURLIsUbiquitousItemKey,
+                NSURLUbiquitousItemDownloadingStatusKey
+            ], error: nil)
+        var ubiquityStatus = DocumentUbiquityStatus(urlMetaData: urlMetaData)
+        if (ubiquityStatus.documentIsUbiquitous && !ubiquityStatus.documentIsUpToDate) {
+            _isDownloadingDocument = true
+            NSFileManager.defaultManager().startDownloadingUbiquitousItemAtURL(documentURL, error: nil)
+        }
         var document = TextDocument(fileURL: documentURL)
         document.openWithCompletionHandler( { (success: Bool) in
             if (success) {
+                self._isDownloadingDocument = false
+                self._view?.editable = true
                 self._document = document
                 document.editorDelegate = self
                 var title = document.localizedName

                    }
                    return v
                }()
        self.view = _view! as UIView
    }
}

            }
        }
    }
    var _isDownloadingDocument: Bool = false

    var _title: NSMutableString = ""
    var _view: UITextView?
