Skip to main content
Added image
Source Link
NSNoob
  • 5.6k
  • 6
  • 44
  • 58

I am developing an app by using parse for backend. In the app, I have a registration module. User enters his email and password, and I send the data to parse and set the username temporarily to temp. On the next screen, the user is prompted to select a username, and I shall update the username in the backend accordingly. Now here's the problem: the field username's value doesn't get updated. These are few ways I have tried after looking up the internet.

//sharedclass is a singleton class, i save object id of the registered user to its attribute objectid.
NSString * objectID = sharedClass.sharedInstance->objectid;
NSLog(@"%@", objectID);
PFObject *pointer = [PFObject objectWithoutDataWithClassName:@"User" objectId:objectID];
sharedClass.sharedInstance->user.username = self.userName.text;
[pointer setObject:self.userName.text forKey:@"username"];
[pointer saveInBackground];

This one says that no object found. even though i get the objectID alright. Then there is this one here:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];
[query whereKey:@"objectId" equalTo:objectID];//objectId is default parse field and objectID is the string i created
[query getFirstObjectInBackgroundWithBlock:^(PFObject * users, NSError *error) {
    if (!error) {
     
        [users setObject:self.userName.text forKey:@"username"];
        
    
        [users saveInBackground];
        NSLog(@"Done");
    } else {
        // Did not find any UserStats for the current user
        NSLog(@"Error: %@", error);
    }
}];

This one says no results matched the query.

Then I have this one:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];

[query getObjectInBackgroundWithId:objectID block:^(PFObject *username, NSError *error) {
    username[@"username"] = self.userName.text;
    [username saveInBackground];
}];

It has the same error that query has no matching results. How do I get the query right? Can someone explain why these queries aren't working? this is how I retrieve the object id when user registration is successful

//objectid is a native string and objectId is the parse default field
sharedClass.sharedInstance->objectid = sharedClass.sharedInstance->user.objectId;

Here is screenshot of data on parse to understand the structure. http://i61.tinypic.com/21j3o8k.png

enter image description here

I am developing an app by using parse for backend. In the app, I have a registration module. User enters his email and password, and I send the data to parse and set the username temporarily to temp. On the next screen, the user is prompted to select a username, and I shall update the username in the backend accordingly. Now here's the problem: the field username's value doesn't get updated. These are few ways I have tried after looking up the internet.

//sharedclass is a singleton class, i save object id of the registered user to its attribute objectid.
NSString * objectID = sharedClass.sharedInstance->objectid;
NSLog(@"%@", objectID);
PFObject *pointer = [PFObject objectWithoutDataWithClassName:@"User" objectId:objectID];
sharedClass.sharedInstance->user.username = self.userName.text;
[pointer setObject:self.userName.text forKey:@"username"];
[pointer saveInBackground];

This one says that no object found. even though i get the objectID alright. Then there is this one here:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];
[query whereKey:@"objectId" equalTo:objectID];//objectId is default parse field and objectID is the string i created
[query getFirstObjectInBackgroundWithBlock:^(PFObject * users, NSError *error) {
    if (!error) {
     
        [users setObject:self.userName.text forKey:@"username"];
        
    
        [users saveInBackground];
        NSLog(@"Done");
    } else {
        // Did not find any UserStats for the current user
        NSLog(@"Error: %@", error);
    }
}];

This one says no results matched the query.

Then I have this one:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];

[query getObjectInBackgroundWithId:objectID block:^(PFObject *username, NSError *error) {
    username[@"username"] = self.userName.text;
    [username saveInBackground];
}];

It has the same error that query has no matching results. How do I get the query right? Can someone explain why these queries aren't working? this is how I retrieve the object id when user registration is successful

//objectid is a native string and objectId is the parse default field
sharedClass.sharedInstance->objectid = sharedClass.sharedInstance->user.objectId;

Here is screenshot of data on parse to understand the structure. http://i61.tinypic.com/21j3o8k.png

I am developing an app by using parse for backend. In the app, I have a registration module. User enters his email and password, and I send the data to parse and set the username temporarily to temp. On the next screen, the user is prompted to select a username, and I shall update the username in the backend accordingly. Now here's the problem: the field username's value doesn't get updated. These are few ways I have tried after looking up the internet.

//sharedclass is a singleton class, i save object id of the registered user to its attribute objectid.
NSString * objectID = sharedClass.sharedInstance->objectid;
NSLog(@"%@", objectID);
PFObject *pointer = [PFObject objectWithoutDataWithClassName:@"User" objectId:objectID];
sharedClass.sharedInstance->user.username = self.userName.text;
[pointer setObject:self.userName.text forKey:@"username"];
[pointer saveInBackground];

This one says that no object found. even though i get the objectID alright. Then there is this one here:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];
[query whereKey:@"objectId" equalTo:objectID];//objectId is default parse field and objectID is the string i created
[query getFirstObjectInBackgroundWithBlock:^(PFObject * users, NSError *error) {
    if (!error) {
     
        [users setObject:self.userName.text forKey:@"username"];
        
    
        [users saveInBackground];
        NSLog(@"Done");
    } else {
        // Did not find any UserStats for the current user
        NSLog(@"Error: %@", error);
    }
}];

This one says no results matched the query.

Then I have this one:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];

[query getObjectInBackgroundWithId:objectID block:^(PFObject *username, NSError *error) {
    username[@"username"] = self.userName.text;
    [username saveInBackground];
}];

It has the same error that query has no matching results. How do I get the query right? Can someone explain why these queries aren't working? this is how I retrieve the object id when user registration is successful

//objectid is a native string and objectId is the parse default field
sharedClass.sharedInstance->objectid = sharedClass.sharedInstance->user.objectId;

Here is screenshot of data on parse to understand the structure.

enter image description here

deleted 1 character in body
Source Link
Arslan Ali
  • 17.9k
  • 10
  • 65
  • 85

I am developing an app by using parse for backend. In the app, I have a registration module. User enters his email and password, iand I send the data to parse and set the username temporarily to temp. onOn the next screen, the user is prompted to select a username., and iI shall update the username in the backend accordingly. Now here's the problem. The: the field username's value doesn't getget updated. These are few ways iI have tried after looking up the internet.

//sharedclass is a singleton class, i save object id of the registered user to it'sits attribute objectid.
NSString * objectID = sharedClass.sharedInstance->objectid;
NSLog(@"%@", objectID);
PFObject *pointer = [PFObject objectWithoutDataWithClassName:@"User" objectId:objectID];
sharedClass.sharedInstance->user.username = self.userName.text;
[pointer setObject:self.userName.text forKey:@"username"];
[pointer saveInBackground];

This one says that no object found. even though i get the objectID alright. Then there is this one here:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];
[query whereKey:@"objectId" equalTo:objectID];//objectId is default parse field and objectID is the string i created
[query getFirstObjectInBackgroundWithBlock:^(PFObject * users, NSError *error) {
    if (!error) {
     
        [users setObject:self.userName.text forKey:@"username"];
        
    
        [users saveInBackground];
        NSLog(@"Done");
    } else {
        // Did not find any UserStats for the current user
        NSLog(@"Error: %@", error);
    }
}];

This one says no results matched the query.

Then I have this one:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];

[query getObjectInBackgroundWithId:objectID block:^(PFObject *username, NSError *error) {
    username[@"username"] = self.userName.text;
    [username saveInBackground];
}];

It has the same error that query has no matching results. How do I get the query right? Can someone explain why these queries aren't working? this is how iI retrieve the object id when user registration is successful

//objectid is a native string and objectId is the parse default field
        sharedClass.sharedInstance->objectid = sharedClass.sharedInstance->user.objectId;

Here is screenshot of data on parse to understand the structure. http://i61.tinypic.com/21j3o8k.png

I am developing an app by using parse for backend. In the app, I have a registration module. User enters his email and password, i send the data to parse and set the username temporarily to temp. on the next screen user is prompted to select a username. and i shall update the username in the backend accordingly. Now here's the problem. The field username's value doesn't get updated. These are few ways i have tried after looking up the internet.

//sharedclass is a singleton class, i save object id of the registered user to it's attribute objectid.
NSString * objectID = sharedClass.sharedInstance->objectid;
NSLog(@"%@", objectID);
PFObject *pointer = [PFObject objectWithoutDataWithClassName:@"User" objectId:objectID];
sharedClass.sharedInstance->user.username = self.userName.text;
[pointer setObject:self.userName.text forKey:@"username"];
[pointer saveInBackground];

This one says that no object found. even though i get the objectID alright. Then there is this one here:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];
[query whereKey:@"objectId" equalTo:objectID];//objectId is default parse field and objectID is the string i created
[query getFirstObjectInBackgroundWithBlock:^(PFObject * users, NSError *error) {
    if (!error) {
     
        [users setObject:self.userName.text forKey:@"username"];
        
    
        [users saveInBackground];
        NSLog(@"Done");
    } else {
        // Did not find any UserStats for the current user
        NSLog(@"Error: %@", error);
    }
}];

This one says no results matched the query.

Then I have this one:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];

[query getObjectInBackgroundWithId:objectID block:^(PFObject *username, NSError *error) {
    username[@"username"] = self.userName.text;
    [username saveInBackground];
}];

It has the same error that query has no matching results. How do I get the query right? Can someone explain why these queries aren't working? this is how i retrieve the object id when user registration is successful

//objectid is a native string and objectId is the parse default field
        sharedClass.sharedInstance->objectid = sharedClass.sharedInstance->user.objectId;

Here is screenshot of data on parse to understand the structure. http://i61.tinypic.com/21j3o8k.png

I am developing an app by using parse for backend. In the app, I have a registration module. User enters his email and password, and I send the data to parse and set the username temporarily to temp. On the next screen, the user is prompted to select a username, and I shall update the username in the backend accordingly. Now here's the problem: the field username's value doesn't get updated. These are few ways I have tried after looking up the internet.

//sharedclass is a singleton class, i save object id of the registered user to its attribute objectid.
NSString * objectID = sharedClass.sharedInstance->objectid;
NSLog(@"%@", objectID);
PFObject *pointer = [PFObject objectWithoutDataWithClassName:@"User" objectId:objectID];
sharedClass.sharedInstance->user.username = self.userName.text;
[pointer setObject:self.userName.text forKey:@"username"];
[pointer saveInBackground];

This one says that no object found. even though i get the objectID alright. Then there is this one here:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];
[query whereKey:@"objectId" equalTo:objectID];//objectId is default parse field and objectID is the string i created
[query getFirstObjectInBackgroundWithBlock:^(PFObject * users, NSError *error) {
    if (!error) {
     
        [users setObject:self.userName.text forKey:@"username"];
        
    
        [users saveInBackground];
        NSLog(@"Done");
    } else {
        // Did not find any UserStats for the current user
        NSLog(@"Error: %@", error);
    }
}];

This one says no results matched the query.

Then I have this one:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];

[query getObjectInBackgroundWithId:objectID block:^(PFObject *username, NSError *error) {
    username[@"username"] = self.userName.text;
    [username saveInBackground];
}];

It has the same error that query has no matching results. How do I get the query right? Can someone explain why these queries aren't working? this is how I retrieve the object id when user registration is successful

//objectid is a native string and objectId is the parse default field
sharedClass.sharedInstance->objectid = sharedClass.sharedInstance->user.objectId;

Here is screenshot of data on parse to understand the structure. http://i61.tinypic.com/21j3o8k.png

edited title
Link
NSNoob
  • 5.6k
  • 6
  • 44
  • 58

How to update a field in User class using parse for ios?

added 247 characters in body
Source Link
NSNoob
  • 5.6k
  • 6
  • 44
  • 58
Loading
Source Link
NSNoob
  • 5.6k
  • 6
  • 44
  • 58
Loading