EXC_BAD_Access when loading User as Related

Hi

After updating the Backendless SDK to the latest version yesterday, I am having this issue. When loading the user table as related query I just get a bad access error. When I set the field as autoload in the dashboard, I get the same error.

Thanks

Do you have any recursive references in the user table? A user contains himself through relation?

Mark,

No, the only relation in the Users’ table is to Locations.

Could you copy/paste the thread dump you get in the XCode log?

I have attached a screenshot

One more question:http://support.backendless.com/public/attachments/1008f34c304d7f67c4ffcb1689058d4d.jpg</img>

1008f34c304d7f67c4ffcb1689058d4d.jpg

It seems to have some of the user properties loaded…

Please show what the code for retrieving this data looks like and also what your application id is.

Sure the application id is: 6D271EB3-6886-F063-FF23-4CA3E4EEB000


BackendlessDataQuery *query = [BackendlessDataQuery new];

QueryOptions *queryOptions = [QueryOptions new];

queryOptions.related = [NSMutableArray arrayWithArray:@[@"user", @"location"]];

query.queryOptions = queryOptions;







    [backendless.persistenceService find:[Seek class]

                               dataQuery:query

                                response:^(BackendlessCollection *response){

                                    

                                    

                                    seeks = [response.data mutableCopy];

                                    

                                    for (int r=0; r<seeks.count; r++)

                                    {

                                        [cellHeights addObject:@kCloseCellHeight];

                                    }

                                    

                                    [_seeksTableView reloadData];

                                    

                                    NSLog(@"%@", response);

                                    

                                }error:^(Fault *error){

                                    

                                    NSLog(@"Error: %@", error);

                                    

                                }

     ];



Thanks. What does your Seek class look like?

Did you use CocoaPods or github for updating?

Martin,

I connected to your app and ran the following code:

- (void)viewDidLoad {
    [super viewDidLoad];


    BackendlessDataQuery *query = [BackendlessDataQuery new];
    QueryOptions *queryOptions = [QueryOptions new];
    queryOptions.related = [NSMutableArray arrayWithArray:@[@"user", @"location"]];
    
    query.queryOptions = queryOptions;
    
    [backendless.persistenceService find:[Seek class]
    dataQuery:query
    response:^(BackendlessCollection *response){
        NSArray *currentPage =[response getCurrentPage];
        NSLog(@"Loaded %lu seek objects", (unsigned long)[currentPage count]);
        NSLog(@"Total seek objects in the Backendless starage - %@", [response getTotalObjects]);
                                    
        for (Seek *seek in currentPage) {
           NSLog(@"Seek name = %@", seek.title);
        }
                                    
        NSLog(@"%@", response);
                                    
        }error:^(Fault *error){
           NSLog(@"Error: %@", error);
     }];
}

Here’s the output I received:

2016-05-04 20:05:44.821 SampleProject[24979:30063497] Loaded 3 seek objects
2016-05-04 20:05:44.821 SampleProject[24979:30063497] Total seek objects in the Backendless starage - 3
2016-05-04 20:05:44.821 SampleProject[24979:30063497] Seek name = Find me a good car insurance
2016-05-04 20:05:44.822 SampleProject[24979:30063497] Seek name = Logo design for my new business
2016-05-04 20:05:44.822 SampleProject[24979:30063497] Seek name = I need someone to book me a ticket to Paris
2016-05-04 20:05:44.822 SampleProject[24979:30063497] &lt;BackendlessCollection&gt; -> type: Seek, offset: 0, pageSize: 100, totalObjects: 3, data: (
    "&lt;Seek: 0x7fa5e0556dc0&gt;",
    "&lt;Seek: 0x7fa5e055b8c0&gt;",
    "&lt;Seek: 0x7fa5e055f7f0&gt;"
), query: &lt;BackendlessDataQuery&gt; -> properties: (null), whereClause: (null), queryOptions: &lt;QueryOptions&gt; -> {
    offset = 0;
    pageSize = 100;
    related =     (
        user,
        location
    );
}

This confirms that the API is functioning properly. The error must be somewhere in your code.

I have used CocoaPods

This is strange, and Im not really sure if it is from my code, because it was working fine before the update, that’s why I’m a bit confused here.

In my Seek class I have a property for the user of Users class. Here is the Users class, please have a look at it, maybe something has changed that I am not aware of:

#import "BackendlessUser.h"

#import &lt;UIKit/UIKit.h&gt;




#import &lt;Backendless-ios-SDK/Backendless.h&gt;







@interface Users : BackendlessUser




//@property NSString *objectId;

@property NSDate *created;

@property NSDate *updated;

@property NSDate *lastLogin;




//@property NSString *name;

//@property NSString *email;

//@property NSString *password;




@property (strong, nonatomic) NSString *firstName;

@property (strong, nonatomic) NSString *lastName;




@property (strong, nonatomic) NSString *image;

@property (strong, nonatomic) GeoPoint *location;




@property (strong, nonatomic) NSString *about;




@property (nonatomic) CGFloat seekerRating;

@property (nonatomic) NSInteger seekerTotalRatings;

@property (nonatomic) CGFloat providerRating;

@property (nonatomic) NSInteger providerTotalRatings;







@property (strong, nonatomic) NSString *payId;

@property (strong, nonatomic) NSString *defaultCardId;

@property (strong, nonatomic) NSString *defaultBankId;

@property (strong, nonatomic) NSString *provideWalletId;










- (NSURL *)imageURL;







- (instancetype)initWithCurrentUser;




@end



Hang on, Users class? That’s a very bad idea to extend BackendlessUser. You should not do this. Instead you should use BackendlessUser and then rely on the following methods to get the property values:

https://backendless.com/documentation/users/ios/users_user_properties.htm

Oh, I never knew that was a bad idea! I will try with the BackendlessUser to see what the results are.

Thanks