2

I just updated:

xcodeVersion 6.3 (6D570)

Swift 1.2 has messed up my word last night and apparently they have made some changes in either Swift or Parse.

I am confused I just don't know how to fix this issue... Need help please. If someone else has experienced the same and has fixed it, please help me.

import UIKit
import Parse

class ProfileViewController: UIViewController, UITextFieldDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate {

    // MARK: Variables declaration
    @IBOutlet weak var uploadPhotoBtn: UIButton!
    @IBOutlet weak var profilePhotoImageView: UIImageView!
    @IBOutlet var welcomeMessageLabel: UIView!
    @IBOutlet weak var greetings: UILabel!

    var imagePicker = UIImagePickerController()
    var existingImage : UIImage?
    var user = PFUser.currentUser()




    // The view has loaded this is the function that will be run at first before anything else
    override func viewDidLoad() {
        super.viewDidLoad()

        // MARK: make a circle image
        profilePhotoImageView.layer.cornerRadius = profilePhotoImageView.frame.size.width/2
        profilePhotoImageView.clipsToBounds = true

        //show my status 
        var mood = self.user["status"] as! String //=> 'AnyObject' is not convertible to 'String'

        self.greetings.text? = ( "\(mood)" )

        //get image if existing
        self.user[ "avatar" ] as? PFFile //=> 'PFFile? is not convertible to 'StringLiteralConvertible'

        if let userImageFile = self.user["avatar"] as? PFFile {PFFile? is not convertible to 'StringLiteralConvertible'

            userImageFile.getDataInBackgroundWithBlock({ (imageData:NSData!, error: NSError!) -> Void in

                if error == nil {

                    self.existingImage = UIImage(data: imageData)
                    self.profilePhotoImageView.image = self.existingImage
                }else {

                    let alert = UIAlertView(title: "Oops!", message: "Unable to get your profile photo", delegate: self, cancelButtonTitle: "Ok!")
                    alert.show()

                }
            })
        }
4

2 回答 2

2

PFUser.CurrentUser returns optional value, if you sure, that your user is login and have created a PFSession then try this:

var user = PFUser.currentUser()!

let me know, if this doesn't solve the problem.

于 2015-04-21T03:37:54.410 回答
1

通过反复试验.. 这对我有用 Parse 1.7.1 和 Swift 1.2

覆盖 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell?

对象?[“bax”] 作为?字符串对象?["abc"] as!PF 文件?-> 但我的图像现在没有显示......仍在尝试解决它。

于 2015-04-14T03:49:08.853 回答