Parse Weird Bug in Swift That Causes Acl Write Permissions to Change to an Objectid

Parse weird bug in Swift that causes ACL write permissions to change to an objectId

Look in your AppDelegate. There's most likely a default ACL and it will look something like this

// Enable public read access by default, with any newly created PFObjects belonging to the current user
let defaultACL: PFACL = PFACL()
defaultACL.publicReadAccess = true
PFACL.setDefaultACL(defaultACL, withAccessForCurrentUser: true)

Parse Cloud Code weird bug

Retrieve the username through the request.user object:

var User = request.user;
console.log(User.get("username"));

//or skip the first step:
console.log(request.user.get("username"));

Note you can also retrieve these values by calling the attributes property of the Parse.Object (typically bad practice):

console.log(request.user.attributes.username);

swift parse app crashes after logout when app resumes

On the following line

NSNotificationCenter.defaultCenter().addObserver(self, selector: "launchSync", name: UIApplicationDidBecomeActiveNotification, object: nil)

you say to call the launchSync function whenever the app becomes active.

As mentioned by Paulw11, inside that function you are force unwrapping (using !) on PFUser.currentUser() which will return nil when the user is logged out.

You can address this by ensuring that the current user isn't nil

func launchSync() {
if (PFUser.currentUser() != nil) {
var query = PFQuery(className:"ParseLighthouse")
query.whereKey("User", equalTo:PFUser.currentUser()!)
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in

if error == nil {
// The find succeeded.
println("Successfully retrieved \(objects!.count) lighthouses.")
// Do something with the found objects
if let light = objects as? [PFObject] {
for object in light {
println(object.objectId)
}
}
println(objects?.count)
self.syncToLighthouse(objects!)
} else {
// Log details of the failure
println("Error: \(error!) \(error!.userInfo!)")
}
}
}
}

Parse iOS SDK: strange cannot do a comparison query of type: (NULL)

One problem you have is that in order to access the value for an object's key, you must use objectForKey: In your code, you use bracket notation which doesn't work with Parse objects.

[[PFUser currentUser] objectForKey:@"mostCommon"];

Swift Dateformatting fails for just a specific day

I suppose you are living in Brasil.

On October 16, 2016 the daylight saving time changes and there is no 0:00.

very weird Xcode project bug?

Anything with the UI needs to be done on the main thread, and you're calling the Parse function on the background thread (via requestPasswordResetForEmailInBackground).

So to get your alerts to appear on the main thread, you need to add a little GCD magic:

@IBAction func resetPass(sender: AnyObject) {

actview.hidden = false
actview.startAnimating()

PFUser.requestPasswordResetForEmailInBackground(emailReset.text) {
(success:Bool, error:NSError?) ->Void in

if(success){
self.actview.stopAnimating()

let yesMessage = "Email was sent to you at \(self.emailReset.text)"
dispatch_async(dispatch_get_main_queue()) {
self.successMessage(yesMessage)
}
};

if(error != nil){

self.actview.stopAnimating()

let errorMessage:String = error!.userInfo!["error"] as! String
dispatch_async(dispatch_get_main_queue()) {
self.failureMessage(errorMessage)
}
}
}
}

See my addition of the "dispatch_async(dispatch_get_main_queue())" lines?

Bug in Swift array subscript indexing?

This is a known swift bug: long statements generate strange compilation errors.
Just split your line in 2 lines, such as:

c[i] = 0.5*(a[i+1] + a[i-1])
c[i] += 0.5*Deltat/Deltax * (b[i+1] - b[i-1])

I found out that happens with more than 4 or 5 arithmetic operations in the same line, but that's not a rule, just a number found with some expression types - it may be different in other cases.

Look for example at this Q&A: Xcode Beta 6.1 and Xcode 6 GM stuck indexing for weird reason and Xcode 6 with Swift super slow typing and autocompletion (this last one actually causes slowness, but solved in the same way, so the root is probably the same)



Related Topics



Leave a reply



Submit