I am unsure why the retrieved collection becomes nil when I access its data property and cast it to an array of its custom class; I’ve done this very similarly in another app and it works just fine.
I made a few changes in the class definition and it worked for me. It is important to keep in mind that the Bool and Int properties must be initialized, if they are declared optional, serialization of the values does not properly work. Here are my property definitions:
var objectId: String?
var ownerId: String?
var created: NSDate?
var members: [BackendlessUser]?
var suhCount: Int = 0;
var sendPush: Bool = false;
var lastSent: NSDate?
var lastSender: BackendlessUser?
var group: Bool = false;
Also, check the type of the “members” and the “lastSender” properties in Backendless console. If they were created dynamically, I suspect they will have type STRING in console - make sure they are declared as relations.
This is indeed rather strange. Could you please email your app id and ios key to support@backendless.com? I’d like to run my code against your backend.
Just to remove any other possible differences, could you please use the attached Friendship.swift file and call “Friendship.retrieveAllFriendships()” from viewDidLoad() in your ViewController?
I copied in your code and ran it in viewDidLoad() and it still comes out to nil. Very weird that it works for you and not me even though we’re using the same code and backend. I’m not sure what to do
Above you’ll notice that it’s only when I try to get the data from the collection as an array of my custom data type; the retrieval of the collection appears to be successful though.
I am on Xcode 7.2.1 and using the latest Backendless iOS SDK from Github
Could something with the way the project structure / files are organized be affecting this? Any idea why my collection type is (null) while yours is TestApp.Friendship?
Yes, that’s how mine looks. I just can’t figure out why your collection is retrieved with the proper type (TestApp.Friendship) while mine comes back as (null); I think this is the problem.
If you’d like, we can review your project - we need to figure it out for ourselves too. Zip it up and upload to dropbox or google drive and send a link to support@backendless.com