如何使用ios swift中的图像选择器更新配置文件图像

时间:2015-02-02 13:27:35

标签: swift

这是我的代码,在这里我尝试通过登录Facebook或电子邮件来更新我的个人资料图片,但是无法更新它?

func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!) {
    self.dismissViewControllerAnimated(true, completion: { () -> Void in

    })

        self.profilepicoutlet.image = image
        println("hello")

    var imgdata:NSData = UIImageJPEGRepresentation(self.profilepicoutlet.image,90)
    println("\(imgdata)")

    request.HTTPMethod = "POST"

   var boundary = NSString(format: "---------------------------14737809831466499882746641449")
                     name=\"title\"\r\n\r\n").dataUsingEncoding(NSUTF8StringEncoding)!)
    body.appendData("Hello World".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!)                    
    NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) { (response: NSURLResponse!, data: NSData?, error: NSError!) -> Void in

        if (data != nil) {
            if let jsonArray: NSArray = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSArray? {



                    let image: NSString? = jsonObject?.objectForKey("image") as? NSString
                    println(image)

                    self.appDelegate.image_org = image
                    println("Appdelegate image :\(self.appDelegate.image_org)")

0 个答案:

没有答案