2017-04-14 2 views
1

사용자 이름이 usernameSelected 인 행을 Heroku/Parse 서버에서 삭제하려고합니다. 선택한 사용자 이름이 nil이 아니며 서버에 존재합니다. 아무것도 잘못된 것처럼 보이지 않고 전체 행을 삭제하는 대신 "개체를 찾을 수 없습니다"만 나타납니다.왜 Heroku/Parse의 "Object not found"오류가 신속하게 반환됩니까?

let query = PFQuery(className: "Requests") 

query.whereKey("username", equalTo: usernameSelected) 
query.limit = 1 
query.findObjectsInBackgroundWithBlock({ (objects, error) in 
    if error != nil { 
    }else { 
     if let objects = objects { 
      for obj in objects { 
       obj.deleteInBackgroundWithBlock({ (success, error) in 
        activityIndicator.stopAnimating() 

        UIApplication.sharedApplication().endIgnoringInteractionEvents() 

        if error != nil { 
         self.alertDisplay("Error", message: error?.userInfo["error"] as! String) 
        }else { 
         self.alertDisplay("", message: "Styles Submitted..! Please wait for your next Style") 
        } 
       }) 
      } 
     } 
    } 
}) 
+0

어떤 블록에서 오류가 발생합니까? findObjects ... 또는 deleteInBackground ...? 둘째, 삭제하는 모든 개체에 대해 가져 오는 중입니까? –

+0

그냥 생각 :이 클래스/개체에 대한 ACL을 어떻게 설정 했습니까? – toddg

+0

+ Lou Franco : deleteInBackground 블록은 객체가 존재하는 동안 오류 (Object not found)를 반환합니다. – aijayy

답변

0
  1. 는 클래스에서 생성 된 행에 대한 ACL 만 읽기 권한을 가지고 있기 때문에 삭제가 실패 할 수

  2. 당신이 당신의 클래스에 대한 읽기 및 쓰기 권한이 있는지 확인하십시오. 읽기 및 방법을 아래 AppDelegate에에 쓰기 권한을 "didFinishLaunchingWithOptions"를 허용하려면 선

    을 볼 수

) (defaultACL = PFACL하자;

// 모든 개체를 기본적으로 개인 개체로 만들려면이 줄을 제거하십시오. defaultACL.getPublicReadAccess = 사실

--- 줄을 추가 defaultACL.getPublicWriteAccess = 미래에 당신이 클라이언트 측에서 개체를 삭제할 수 있도록이 사용자가 쓰기 권한을 가진 모든 행을 만드는 데 도움이됩니다

사실.