2

を作成しvar userImages = [PFFile]()、ユーザー クエリを介して Parse からそれぞれのユーザー イメージを追加しましたself.userImages.append(user["imageFile"] as! PFFile)。これはうまくいきます。ただし、ユーザーの画像を設定しようとすると

userImages.getDataInBackGroundWithBlock{ (data, error) -> Void in ...

次のエラーが表示されます。**'[(PFFile)]' does not have a member named 'getDataInBackGroundWithBlock'**

これが機能しないのはなぜですか? また、この問題の解決策は何ですか?

お手伝いありがとう!!

ここに画像の説明を入力

ここに画像の説明を入力

4

1 に答える 1

1

getDataInBackGroundWithBlock使用しようとしている配列を呼び出そうとしています」

userImages.last?.getDataInBackGroundWithBlock{...}

または、変数に保存し、新しいPFFIleを使用して画像を取得できます

let userImage = user["imageFile"] as! PFFile
userImage.getDataInBackGroundWithBlock{...}

または、次を使用して直接アクセスします。

(user["imageFile"] as! PFFile).getDataInBackGroundWithBlock{...}

役割プロセスは次のとおりです。

self.userImages.append(user["imageFile"] as! PFFile) //This is just a reference to download the image

userImages.last?.getDataInBackgroundWithBlock {
  (imageData: NSData?, error: NSError?) -> Void in
  if error == nil {
    if let imageData = imageData {
        let image = UIImage(data:imageData) // this is the final image
    }
  }
}
于 2015-06-08T05:37:50.140 に答える