I have a Users class where each user has a collection of music artists he/she follows from an Artist Class. Lets say I have an artist called H3nry and I want to find out which users are following H3nry I used this logic I got from this forum:
func getFollowers(followers: String)
{
let dataQuery = BackendlessDataQuery()
dataQuery.whereClause = "following.objectId = \'\(followers)\'"
var error: Fault?
let bc = backendless.data.of(BackendlessUser.ofClass()).find(dataQuery, fault: &error)
if error == nil {
print("People Who Follow:")
print("Followers have been retrieved: \(bc.data)")
}
else {
print("Server reported an error: \(error)")
}
}
The query works 100% but it returns a whole lot of other stuff and all I want is just the users who follow H3nry. In the case below I just want that ‘User: masinh’ and I dont know how to access that from the NSObject Array. How do I get these users when the query returned gives me this output:
People Who Follow:
Followers have been retrieved: [<BackendlessUser> {
Phone = 08553;
“___class” = Users;
“__meta” = “{“relationRemovalIds”:{},“selectedProperties”:[“country”,“eventsGoing”,“created”,“ownerId”,“password”,“Phone”,“following”,“name”,”___class",“eventNotGoing”,“updated”,“objectId”,“eventsMaybe”,“likes”],“relatedObjects”:{“eventsGoing”:[“r8AF46ekNW”],“following”:[“APmGwuh34L”,“ecKLP1cYhF”,“jSBAVivc4a”],“likes”:[“a2aHY43Pap”,“A618950C-D147-4602-FFD3-366AA9924C00”,“RH4BgjEnAx”,“vSKAhUILfQ”]}}";
country = “<null>”;
created = “2016-02-28 16:16:12 +0000”;
email = “<null>”;
eventNotGoing = (
);
eventsGoing = (
“<Yzia.Shows: 0x14cff9770>”
);
eventsMaybe = (
);
following = (
“<Yzia.Artist: 0x14cffb5b0>”,
“<Yzia.Artist: 0x14e3001e0>”,
“<Yzia.Artist: 0x14e301260>”
);
lastLogin = “2016-05-02 13:56:03 +0000”;
likes = (
"<Yzia.Songs: 0x14e302860>",
"<Yzia.Songs: 0x14e303de0>",
"<Yzia.Songs: 0x14e305400>",
"<Yzia.Songs: 0x14cff6610>"
);
name = masinh;
objectId = "986D6461-07CC-02EE-FFFD-54CDD38B6800";
ownerId = "8E81D09B-362C-7DF3-FFFE-9AF86C56B200";
password = "<null>";
updated = "2016-05-02 13:17:05 +0000";
userStatus = ENABLED;
}]