Parse Object throws unrecognized selector when I set a property value

50 views Asked by At

I am using Parse with ObjectiveC to store some information about a color theme. Here is my current PFObject model:

CloudThemes.h

#import "Parse/Parse.h"
@interface CloudThemes : PFObject<PFSubclassing>

@property (nonatomic, strong) NSDictionary <NSString *, NSDictionary<NSString *, NSString *> *> * themes;

@end

CloudThemes.m

#import <Foundation/Foundation.h>
#import "CloudThemes.h"
#import "Constants.h"

@implementation CloudThemes

    @dynamic themes;

+ (nonnull NSString *)parseClassName {
    return kCloudThemesModelClassName;
}
@end

Whenever I try to give my themes object a value, it rejects it, with an error saying

-[CloudThemes setThemes:]: unrecognized selector sent to instance 0x283be0000

on the line themes.themes = myTheme;

    CloudThemes * themes = [[CloudThemes alloc] initWithClassName:kCloudThemesModelClassName];
    
    NSDictionary * myTheme = @{@"Cloud": @{@"Background" : @"FEFFFF", @"Secondary" : @"EAEAEA",
                                           @"Label" : @"170A4E", @"Accent" : @"2E6C8B",
                                           @"Like" : @"A3D16E", @"Star" : @"EC6C58", @"StatusBar" : @"Light"}};
    themes.themes = myTheme;
        [themes saveInBackgroundWithBlock:^(BOOL succeeded, NSError * _Nullable error) {
            if(succeeded){
                NSLog(@"done");
            }
    }];

Link to the error picture: https://i.stack.imgur.com/otrym.png

However, since I was using the Back4App dashboard with Parse, I manually added my own Object that matched everything, to test if I could query for it. When I queried with:

    PFQuery * query = [PFQuery queryWithClassName: kCloudThemesModelClassName];
    [query whereKeyExists:@"themes"];
    [query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
        if(error) {
            completion(nil, error);
            return;
        }
        if(objects){
            NSLog(@"found");
            if(objects.count > 0) {
                completion(((CloudThemes *)objects[0]).themes, nil);
            } else {
                completion(nil, nil);
            }
        } else {
            NSLog(@"No objects found");
            completion(nil, nil);
        }
    }];

I always end up with No objects found.

I'm not sure how this is happening, any thoughts?

0

There are 0 answers