2017-08-18 78 views
1

嗨,我是新來的Backendless。請幫忙。我在使用ios時遇到了使用未聲明類型'BackendlessCollection'的錯誤。迅速使用未申報類型'BackendlessCollection'

我已經寫功能retrieveBlurbs()在主頁視圖controller.I已創建了一個更對象medicineList類這樣

class medicineList : NSObject 
{ 

    var objectId : String? 
    var name : String? 

    var desc : String? 
    var created : NSDate? 
    var updated : NSDate? 

} 


func retrieveBlurbs() 
{ 
    var backendless = Backendless.sharedInstance() 
    let query = BackendlessDataQuery() 
    // Use backendless.persistenceService to obtain a ref to a data store for the class 
    backendless.persistenceService.ofTable(medicineList.ofClass()).find(query, response: { (medicineList : BackendlessCollection!) ->() in 
     let currentPage = medicineList.getCurrentPage() 
     print("Loaded \(currentPage.count) medicineList objects") 
     print("Total restaurants in the Backendless starage - \(medicineList.totalObjects)") 

     for medicineList in currentPage as! [medicineList] 
     { 
      print("Medicine name = \(medicineList.name)") 
     } 




    } , error: { (fault : Fault!) ->() in 
      print("Server reported an error: \(fault)") 
     }) 
} 

回答

0

enter image description here我不知道,這將是有幫助的

我查看了API,因此如果您使用的是異步方法簽名,則使用查詢變量的「查找」方法有兩個非可選塊用於響應和錯誤。

我會努力改變像這樣的方法:

func retrieveBlurbs() 
{ 
    var backendless = Backendless.sharedInstance() 
    let query = BackendlessDataQuery() 
    // Use backendless.persistenceService to obtain a ref to a data store for the class 
    backendless.persistenceService.ofTable(medicineList.ofClass()).find(query) { medicineList in 
     let currentPage = medicineList.getCurrentPage() 
     print("Loaded \(currentPage.count) medicineList objects") 
     print("Total restaurants in the Backendless starage - \(medicineList.totalObjects)") 

     for medicineList in currentPage as! [medicineList] 
     { 
      print("Medicine name = \(medicineList.name)") 
     } 

    } , { fault in 
      print("Server reported an error: \(fault)") 
     } 
} 

如果這不會幫助,那麼也許你已經做出從一開始的SDK安裝,一些模塊或文件可能會被中失蹤第一次設置

+0

我編輯woof答案...但仍然得到一個錯誤,如'不能轉換任何類型的值!到期望的參數類型字符串!'錯誤行PersistanceService行代碼 –

+0

後端連接我在開始時正確 –

+0

你可以給我發送一個示例代碼來檢索後臺表中的所有名稱列表..我需要在表視圖控制器中顯示該表列表。 –