浏览代码

datasource load

Marino Faggiana 8 年之前
父节点
当前提交
2c4e9ca3a9
共有 2 个文件被更改,包括 35 次插入14 次删除
  1. 1 1
      Picker/Base.lproj/MainInterface.storyboard
  2. 34 13
      Picker/DocumentPickerViewController.swift

+ 1 - 1
Picker/Base.lproj/MainInterface.storyboard

@@ -47,7 +47,7 @@
                     <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
                     <size key="freeformSize" width="350" height="400"/>
                     <connections>
-                        <outlet property="tableView" destination="vA7-yc-aM1" id="fNd-ns-6FT"/>
+                        <outlet property="tableView" destination="vA7-yc-aM1" id="nuO-LH-LFc"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="UoZ-ya-W3e" userLabel="First Responder" sceneMemberID="firstResponder"/>

+ 34 - 13
Picker/DocumentPickerViewController.swift

@@ -62,8 +62,13 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
         } else {
             
             // Close return nil
-            dismissGrantingAccess(to: nil)
-            
+            let deadlineTime = DispatchTime.now() + 0.1
+            DispatchQueue.main.asyncAfter(deadline: deadlineTime) {
+                
+                print("Error close")
+                self.dismissGrantingAccess(to: nil)
+            }
+
             return
         }
         
@@ -75,19 +80,12 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
         
         super.viewWillAppear(animated)
         
-        /*
-        NSPredicate(format: "(account == %@) AND (directoryID == %@)", , "33")
+        let directoryID : String? = CCCoreData.getDirectoryID(fromServerUrl: localServerUrl!, activeAccount: activeAccount!)
+        let predicate = NSPredicate(format: "(account == %@) AND (directoryID == %@)", activeAccount!, directoryID!)
         
-        let recordsTableMetadata = CCCoreData.getTableMetadata(with: "(account == %@) AND (directoryID == %@)", fieldOrder: <#T##String!#>, ascending: <#T##Bool#>)
-        */
+        let recordsTableMetadata = CCCoreData.getTableMetadata(with: predicate, fieldOrder: CCUtility.getOrderSettings()!, ascending: CCUtility.getAscendingSettings())
         
-        /*
- 
-        NSArray *recordsTableMetadata = [CCCoreData getTableMetadataWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (directoryID == %@)", app.activeAccount, directoryID] fieldOrder:[CCUtility getOrderSettings] ascending:[CCUtility getAscendingSettings]];
- 
-         _sectionDataSource = [CCSection creataDataSourseSectionTableMetadata:recordsTableMetadata listProgressMetadata:nil groupByField:_directoryGroupBy replaceDateToExifDate:NO activeAccount:app.activeAccount];
- 
-         */
+        sectionDataSource = [CCSection.creataDataSourseSectionTableMetadata(recordsTableMetadata, listProgressMetadata: nil, groupByField: "none", replaceDateToExifDate: false, activeAccount: activeAccount)]
         
         tableView.reloadData()
     }
@@ -105,3 +103,26 @@ class DocumentPickerViewController: UIDocumentPickerExtensionViewController, CCN
     }
     */
 }
+
+/*
+// MARK: - UITableViewDataSource
+extension DocumentPickerViewController: UITableViewDataSource {
+    
+    // MARK: - CellIdentifiers
+    fileprivate enum CellIdentifier: String {
+        case NoteCell = "noteCell"
+    }
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return notes.count
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier.NoteCell.rawValue, for: indexPath)
+        let note = notes[(indexPath as NSIndexPath).row]
+        cell.textLabel?.text = note.title
+        return cell
+    }
+}
+*/
+