Eddy
Eddy

Reputation: 3713

App blows up due to calling PFUser enableAutomaticUser

I need to restrict user data so that nobody, other than the app user, can read his / her data. Looking at the docs I thought that putting these two lines:

[PFUser enableAutomaticUser];
[PFACL setDefaultACL:[PFACL ACL] withAccessForCurrentUser:YES];

in didFinishLaunchingWithOptions would do it. But when there is no current user and it's a new installation, the app crushes on

[self.window makeKeyAndVisible];

Between the enableAutomaticUser and the makeKeyAndVisible all I'm doing is loading static data and initializing UIViewControllers - with the user object untouched.

What am I missing?

Upvotes: 0

Views: 229

Answers (1)

Eddy
Eddy

Reputation: 3713

The reason this happens is that once I called [PFUser enableAutomaticUser] there is a user in the system, so a check of

if([PFUser currentUser]) 

returns TRUE. But the objectId does not exist until the user is saved to the datastore.

So when I attempted to add the [[PFUser currentUser] objectId] the system crushed.

Upvotes: 3

Related Questions