2014-12-22 3 views
3

나는 구문 분석과 신속한 문제가 있고 난 당신이 나를 :)다운로드 PFFile (이미지) 배열에 추가하고 해당 배열에있는 UIImageView를 채우기 (스위프트)

내가 다운로드있어 문자열을 도울 수있는 희망 Parse의 PFfiles를 배열에 추가하려고합니다 (제대로 작동 함).

다음 문자열 배열 (잘 작동합니다) 레이블 및 Image 또한 PFFile 배열로 UIImageView 채우기 싶습니다.

그러나 나는 항상 오류 얻을 :

PFFile is not convertible to "UIImage

을하지만 내가있는 UIImage보기로 사용할 수 있도록 내가이 PFFile을 변환 할 수있는 방법을 단서가 없다.

var titles = [String]() 

var fragenImages = [PFFile]() 

@IBOutlet weak var fragenIm: UIImageView! 


@IBOutlet weak var fragenFeld: UILabel! 



    override func viewDidAppear(animated: Bool) { 


    var query = PFQuery(className:"Post") 

    query.whereKey("user", notEqualTo: PFUser.currentUser().username) 
    query.limit = 5 

    query.findObjectsInBackgroundWithBlock{ 
     (objects: [AnyObject]!, error: NSError!) -> Void in 

     if error == nil { 



      for object in objects { 

     self.titles.append(object["title"] as String) 
     self.fragenImages.append(object["imageFile"] as PFFile) 


      } 



     self.fragenFeld.text = self.titles[0] 
     self.fragenIm.image = self.fragenImages[0] 





     } 

      else { 

      println(error) 
      } 

     } 



} 

답변

4

다니엘, 사진은 기술적으로는, 파일이 아닌,하지만 당신은 데이터하지 PFObjects 또는 PFFiles로를 참조합니다. 당신은 그냥 간단한 단계를 놓친 : 스위프트와 엑스 코드 그냥 새에 와우 감사합니다, 내게 정말 바보 이잖아

for object in objects { 
    let userPicture = object["imageFile"] as PFFile 
    userPicture.getDataInBackgroundWithBlock({ // This is the part your overlooking 
    (imageData: NSData!, error: NSError!) -> Void in 
    if (error == nil) { 
    let image = UIImage(data:imageData) 
    self.fragenImages.append(image) 
}) 
+0

:하지만 메신저^평소 그래서, 기본적으로 파일의 데이터를 얻을 적용 ^이 작업은 절대적으로 훌륭했습니다. –

+0

@DanielKeller 우리 모두는 거기에있었습니다 – soulshined

+0

@souldshined - 오디오 파일에도이 작업을 수행 했습니까? http://stackoverflow.com/questions/34754255/how-to-retrieve-audio-file-from-parse-swift – richc

관련 문제