问题
When i tried to upload image using Alamofire I'm getting error in .POST
Im attaching an image along with this to show the error
(http://www.awesomescreenshot.com/image/422237/0d5fe4a4b486b14fdf52f8ca26d22bea)
回答1:
I had the same problem , as Michal said it's an installation issue if you are using cocoapods go to your project files/pods/Alamofires/Source and make sure you have 9 files there just like this image and make sure that the MultipartFormData.swift file is there
if you are not using cocoapods just open the Alamofire folder and go to source folder and make sure you have the same files there too
if you didn't find MultipartFormData.swift that means that your Alamofire version does not support MultipartFormData then you will need to get the latest version from here Alamofire or if you use cocoapods you will have to update the line of Alamofire pod on podfile to be like this
platform :ios, '8.0'
use_frameworks!
target 'ProjectName' do
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'master'
end
target 'ProjectNameTests' do
end
after updating your pod file you need to run this command to update the cocoapods project
pod install --verbose
回答2:
There could be an installation issue with Alamofire. Check that you have imported it properly.
Changing .POST for Alamofire.Method.POST or Method.POST (if you're also targeting iOS 7 and you didn't import Alamofire as dynamic framework) will reveal the real issue or fix your problem.
Check out this thread. Also don't forget that again, when supporting iOS 7, you do not call Alamofire methods with the Alamofire. keyword.
来源:https://stackoverflow.com/questions/31534211/alamofire-multipart-upload-post-error-in-swift