Nicholas
Nicholas

Reputation: 149

Parse Config Change Value

I am using the new(ish) Parse.com 'config' in my app. I am calling from the server to get the data and then I am displaying it to the user. Everything is great but now I am having issues trying to update the information in the server.

Here is how I am setting up the label:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [PFConfig getConfigInBackgroundWithBlock:^(PFConfig *config, NSError *error) {
        NSString *stringForStock = config[@"mainTitle"];
        self.stockOfTheDay.text = stringForStock;
    }];
}

Works fantastic. Well say I wanted to change that data in my app for whatever reason and then update the server. This is what I tried using:

[config setValue:@"New Title" forKey:config[@"mainTitle"]];

Well when I run the entire void, the process is never run.

-(IBAction)changeTitle:(id)sender
{
    NSLog(@"newTitle");
    [PFConfig getConfigInBackgroundWithBlock:^(PFConfig *config, NSError *error) {

        NSString *stringForStock = config[@"mainTitle"];
        self.stockOfTheDay.text = stringForStock;

        [config setValue:@"New Title" forKey:config[@"mainTitle"]];

        NSLog(@"Done");
    }];
}

As you may be able to see from my logs, the 'newTitle' log is run but the 'Done' log is not. What am I doing wrong?

Upvotes: 1

Views: 1119

Answers (2)

Matthew Knippen
Matthew Knippen

Reputation: 1058

The PFConfig object is read-only on a client. It must be updated from the browser.

Upvotes: 4

bhr
bhr

Reputation: 2337

As far as I understand Parse Config, it's a one way communication API, i.e. you can only get config from the server (via getConfigInBackgroundWithBlock:), but not write to new data from your client. (Source: https://parse.com/docs/ios_guide#config/iOS)

If you want to update data on the parse store, then you need to use PFObjects.

Upvotes: 4

Related Questions