这可能是因为缺少支持库的原因。请确保您已正确添加所需的AFNetworking库和其依赖项。如果您已添加库但仍然存在此问题,请尝试在项目设置中'Other Linker Flags”设置为“-ObjC”和“-all_load”。以下是示例代码:
Podfile文件:
platform :ios, '9.0' use_frameworks!
target 'YourProjectName' do pod 'AFNetworking', '~> 3.0' end
AppDelegate.m文件:
import "AppDelegate.h" import "AFNetworking.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
return YES; }
@end