AFNetworking pod安装使用未解析的标识符方法

时间:2016-08-25 15:22:19

标签: objective-c swift cocoapods afnetworking

我将private void ScrollItems() { ScrollToPositionTop(0,0); // It does not scroll to top } private void ScrollToPositionTop(double x, double y) { DoubleAnimation vertAnim = new DoubleAnimation(); vertAnim.From = mainViewer.VerticalOffset; vertAnim.To = y; vertAnim.DecelerationRatio = .2; vertAnim.Duration = new Duration(TimeSpan.FromMilliseconds(0)); DoubleAnimation horzAnim = new DoubleAnimation(); horzAnim.From = mainViewer.HorizontalOffset; horzAnim.To = x; horzAnim.DecelerationRatio = .2; horzAnim.Duration = new Duration(TimeSpan.FromMilliseconds(0)); sb.Children.Add(vertAnim); sb.Children.Add(horzAnim); Storyboard.SetTarget(vertAnim, mainViewer); Storyboard.SetTargetProperty(vertAnim, new PropertyPath(AniScrollViewer.CurrentVerticalOffsetProperty)); Storyboard.SetTarget(horzAnim, mainViewer); Storyboard.SetTargetProperty(horzAnim, new PropertyPath(AniScrollViewer.CurrentHorizontalOffsetProperty)); sb.Begin(this); } 安装到我的项目中,Mixpanel不再有效,并且在所有方法中都显示此错误:

  

使用未解析的标识符' AFHTTPRequestOperationManager'

但是Xcode已经链接到方法中的类,我尝试了AFNetworkingpod install,清理了项目,但它没有工作

在PodFile中:

pod update

在Bridging-Header中:

target 'My Project' do
    pod 'AFNetworking'
    pod 'Mixpanel'
end

target 'Mi ProjectTests' do
end

enter image description here

,最后一个错误显示是:

#import <AFNetworking.h>
#import <Mixpanel/Mixpanel.h>

3 个答案:

答案 0 :(得分:3)

到AFNetworking 3.0版本:

let manager = AFHTTPSessionManager()

要解决上一个错误,请转到Build SettingsOther Linker Flags并删除除$(inherited)以外的所有错误

答案 1 :(得分:2)

我将pod更新到最新版本的AFNetworking后,我遇到了同样的问题。再也没有AFHTTPRequestOperationManager,所以请尝试调用它:

let manager = AFHTTPSessionManager()

带有进度的上传任务,在 swift 3.0 中如下:

let request = URLRequest(url: URL(string: "http://example.com/your/url")!)
manager.uploadTask(with: request, from: userData, progress: { (progress: Progress) in

       // progress catching

    }) { (response: URLResponse, object: Any?, error: Error?) in

       // work with response 
    }

答案 2 :(得分:-1)

如果您已正确安装了pod,只需导入AFNetworking:

import UIKit
import AFNetworking