I am having a difficult time figuring out why I am getting Thread 1: EXC_BAD_ACCESS error when I run my app. When I comment out the fetchingFirstPageAsync() call viewDidLoad(), the error is not thrown.
func fetchingFirstPageAsync() {
print("\n============ Fetching first page using the ASYNC API ============")
let startTime = NSDate()
let query = BackendlessDataQuery()
backendless.persistenceService.of(coffee_details.ofClass()).find(
query,
response: { (results : BackendlessCollection!) -> () in
let currentPage = results.getCurrentPage()
print("Loaded \(currentPage.count) restaurant objects")
for result in currentPage as! [coffee_details] {
print("Restaurant name = \(result.name)")
}
print("Total time (ms) - \(1000*NSDate().timeIntervalSinceDate(startTime))")
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
}
}
and here is my object:
import Foundation
class coffee_details: NSObject {
var name : String?
var objectId : String?
//var telephone : String?
var address : String?
var hours : String?
}
Maybe you need to remove the line:
tableView.reloadData()
I checked your sample, it works fine for me:
data model class:
class coffee_details: NSObject {
var name : String?
var objectId : String?
var address : String?
var hours : String?
}
creating method:
func saveNewCoffeeDetails() {
for i in 0 ..< 10 {
let num = coffee_details()
num.name = backendless.randomString(10)
let dataStore = backendless.data.of(coffee_details.ofClass())
// save object synchronously
var error: Fault?
let result = dataStore.save(num, fault: &error) as? coffee_details
if error == nil {
print("Data has been saved: \(i)->\(result!.objectId)")
}
else {
print("Server reported an error: \(error)")
}
}
}
fetching method:
func fetchingCoffeeDetailsAsync() {
print("\n============ Fetching first page using the ASYNC API ============")
let startTime = NSDate()
let query = BackendlessDataQuery()
backendless.persistenceService.of(coffee_details.ofClass()).find(
query,
response: { (results : BackendlessCollection!) -> () in
let currentPage = results.getCurrentPage()
print("Loaded \(currentPage.count) coffee_details objects")
for result in currentPage as! [coffee_details] {
print("coffee_details name = \(result.name)")
}
print("Total time (ms) - \(1000*NSDate().timeIntervalSinceDate(startTime))")
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
}
I don’t have a creating method, I just want to print to the console for now. Is it critical for saveNewCoffeeDetails() to be called? if so, where is it called? in viewDidLoad? I removed the tableView.reloadData() and I still get the memory error stepping into this call: fetchingCoffeeDetailsAsync()
I simply made saveNewCoffeeDetails() to be able to check fetchingCoffeeDetailsAsync() in my Backendless app.
I created a sample project with your class (see in attachment), you can try it with my Backendless app, then set appId & secretKey of your Backendless app, and compare the results. This allows you to check SDK ‘find’ call without any additional elements. If you will be able to get your coffee_details objects with this sample app, then SDK works right and the issue is in your app code. Let me know how it goes here.