Getting error in retrieve data using Syn call

I am using this code to get the value:

dataQuery = [BackendlessDataQuery new];

dataQuery.whereClause = [NSString stringWithFormat:@"objectId = \'%@\'", strUnfollowObjId];

BackendlessCollection *collection = [backendless.persistenceService find:[Retailer class] dataQuery:dataQuery error:&fault];

but I am getting this error:

Types::NSObject (Properties) -> resolveProperty:value: description <__NSCFString> EXCEPTION = [<Retailer 0x156f5c30> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key description.

Aman,

Please keep in mind that if you store your app users in a table other than the built-in Users table, you will not be able to use Backendless security system at all. You really should store your app users in the Users table and not your custom one.

Mark

Hi Mark,

As you know, I faced problem with BackendlessUser table in maintaining the create/update/delete relation for one to many property. I discussed this with you on separate topic, you guys gave me suggestion but still I was unable to fulfill my app requirement with Users table that’s why decided to move on Custom user table. Let me talk to my client and then get back to you…

Can you attached your Retailer class and header to this ticket?

Also can you attach a screenshot of the Retailer table schema (not the table, but specifically the schema)

Mark

Please see the attached file…

Retailer.txt (1.48kB)

Hi Aman,

You should rename the property “description” in your Retailer class, because NSObject class already has this property: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/index.html#//apple_ref/occ/intfm/NSObject/description

Also your Retailer class has property

@property (nonatomic, strong) NSMutableArray *GeneralMessage;
but your app has a class with the same name - maybe you should rename this property, for example:

@property (nonatomic, strong) NSMutableArray *generalMessage;

Regards,
Slava

Got it! I will try to do these changes as you suggested… Thanks!

Now I am not getting any error. But the relation is not going to remove from table CustomUsers. I am using this query:

dataQuery = [BackendlessDataQuery new];

dataQuery.whereClause = [NSString stringWithFormat:@"objectId = \'%@\'", strUnfollowObjId];

BackendlessCollection *collection = [backendless.persistenceService find:[Retailer class] dataQuery:dataQuery error:&fault];





Retailer *oRetailer = [[Retailer alloc] init];

oRetailer = [[collection data] objectAtIndex:0];



[oCustomUsers.retailers removeObject:oRetailer];

[backendless.persistenceService save:oCustomUsers error:&fault];

what is “oCustomUsers” ?

I just make the object of CustomUsers class. Sorry I forgot to mention this code

dataQuery = [BackendlessDataQuery new];

dataQuery.whereClause = [NSString stringWithFormat:@"email = \'%@\'",strUsername];

queryOptions = [QueryOptions new];

queryOptions.related = [NSMutableArray arrayWithArray:@[@"retailers"]];

dataQuery.queryOptions = queryOptions;



BackendlessCollection *collection = [backendless.persistenceService find:[CustomUsers class] dataQuery:dataQuery error:&fault];

NSLog(@"%@", fault);

oCustomUsers = [[CustomUsers alloc] init];

oCustomUsers = [[collection data] objectAtIndex:0];

If your CustomUsers object already has a collection of related retailers, why do you load retailers again?

Do this as a test:

    Load CustomUsers with related Retailers Delete one of the retailers from the related collection Save CustomUsers object Check the collection of related retailers in the console

To delete one of retailers from the related collection, I need to have a retailer class object. Thats why I try to get the retailer class object based on objectid. If i am wrong, please tell?

To delete a retailer from CustomUsers, you need to have a retailer object in the “retailers” collection. You already request to load it here:

queryOptions.related = [NSMutableArray arrayWithArray:@[@“retailers”]];

When you get your CustomUsers collection back, then use what you got, you do not need to load anything else to delete the relations.

If you have got oCustomUsers object with loaded one-to-many relation ‘retailers’, then to remove the retailer with objectId = strUnfollowObjId from oCustomUsers.retailers:

for (Retailer *retailer in oCustomUsers.retailers) {
 if ([retailer.objectId isEqualToString:strUnfollowObjId]) {
 [oCustomUsers.retailers removeObject:retailer];
 break;
 }
}
oCustomUsers = [backendless.persistenceService save:oCustomUsers];
NSLog(@"oCustomUsers has been updated: %@", oCustomUsers.retailers]);

Thanks Mark and Slava! This works for me. I believe I was getting a problem because I was using a separate Retailer collection, I should have used the same CustomUsers collection and pass its object to remove retailer.

I just want to share one thing with you that I have to move to CustomUsers table to maintain the users’ credential, relations and data. As I was getting problem with backendless Users table in maintaining(Add/update/delete relation) the relation with in it. I worked with you in previous tickets but sometimes I got the relations and sometimes not, this happens randomly. Without putting much time in debugging the backendless Users table, I decided to make a CustomUser table as I have a limited time to complete an app.

So. I want to know Can I maintain the Facebook and Twitter login with this new table CustomUsers?

For example, you can add the one-to-one relation of BackendlessUser class in your CustomUsers class, and save the appropriate BackendlessUser object there.

Aman,

We are not aware of any problems with create/update/delete for one-to-many relations. If you ran into a problem, it must be a coding/configuration error. Creating your own table to maintain users is a very bad idea.

Mark