【问题标题】:Errors: "Expected selector for Objective-C method" and "Expected method body" on #import <Foundation/Foundation.h>错误:#import <Foundation/Foundation.h> 上的“Objective-C 方法的预期选择器”和“预期方法主体”
【发布时间】:2015-05-07 11:56:45
【问题描述】:

尝试在模拟器上运行项目时出现以下两个错误:

  1. Objective-C 方法的预期选择器
  2. 预期的方法体

在 AppDelegate.h 文件中的 #import &lt;Foundation/Foundation.h&gt;

我尝试清理项目,关闭并打开 Xcode,重新启动 PC,尝试找到 type-o,但我找不到,我必须补充一点,我没有对应用程序委托文件进行任何更改,当我从在我的设备上测试更改为在模拟器上测试时,一切都发生了。

这是我没有修改的确切代码:

//
//  AppDelegate.h
//  ChannerApp
//
//  Created by Laurentiu on 20/02/15.
//  Copyright (c) 2015 Laurentiu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GroupsViewController.h"
#import <FacebookSDK/FacebookSDK.h>
#import <UIKit/UIKit.h>
#import "XMPP.h"
#import <CoreData/CoreData.h>
#import "XMPPStream.h"
#import "XMPPReconnect.h"
#import "XMPPRoster.h"
#import "XMPPRosterCoreDataStorage.h"
#import "XMPPvCardCoreDataStorage.h"
#import "XMPPvCardAvatarModule.h"
#import "XMPPCapabilities.h"
#import "XMPPCapabilitiesCoreDataStorage.h"
#import "ConractsViewController.h"
#import "StartViewController.h"
#import "DDLog.h"
#import "Reachability.h"
#import "XMPPvCardTemp.h"


@class StartViewController, GroupsViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate, XMPPStreamDelegate, XMPPRosterDelegate, XMPPvCardTempModuleDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, strong) StartViewController *notSignedInView;
@property (nonatomic, strong) GroupsViewController *signedInView;
///////////////////////////////////////////////
@property (nonatomic, strong, readonly) XMPPStream *xmppStream;
@property (nonatomic, strong, readonly) XMPPReconnect *xmppReconnect;
@property (nonatomic, strong, readonly) XMPPRoster *xmppRoster;
@property (nonatomic, strong, readonly) XMPPRosterCoreDataStorage *xmppRosterStorage;
@property (nonatomic, strong, readonly) XMPPvCardTempModule *xmppvCardTempModule;
@property (nonatomic, strong, readonly) XMPPvCardAvatarModule *xmppvCardAvatarModule;
@property (nonatomic, strong, readonly) XMPPCapabilities *xmppCapabilities;
@property (nonatomic, strong, readonly) XMPPvCardCoreDataStorage *xmppvCardStorage;
@property (nonatomic, strong, readonly) XMPPvCardTemp *storedvCard;
///////////////////////////////////////////////
//all user values that should be saved
@property (nonatomic, strong) NSString *userName;
@property (nonatomic, strong) NSString *nickName;
@property (strong, nonatomic) NSString *passwordText;
@property (nonatomic, strong) NSString *firstName;
@property (strong, nonatomic) NSString *lastName;
@property (nonatomic, strong) NSString *emailAddress;
@property (strong, nonatomic) NSString *avatarImage;
@property (strong, nonatomic) NSString *gender;
@property (nonatomic, strong) NSString *facebookInfo;
@property (strong, nonatomic) NSString *linkedInInfo;
@property (strong, nonatomic) NSString *birthdate;

- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
- (void)signInWith: (NSString *)username andPassword: (NSString *) password;
- (void)teardownStream;
- (BOOL)checkForNetwork;
- (void)savevCardWithUsername:(NSString *)username andNickname:(NSString *)andNickname andPassword:(NSString *)andPassword andLastName:(NSString *)andLastName andBirthdate:(NSString *)andBirthdate andFirstName:(NSString *)andFirstName andEmailAddress:(NSString *)andEmailAddress andAvatarImage:(NSString *)andAvatarImage andGender:(NSString *)andGender andFBInfo:(NSString *)FBInfo andLinkedInInfo:(NSString *)LinkedInInfo;

- (void)uploadvCard;

@end

【问题讨论】:

  • 编译时可能会出现此错误。在哪一行?
  • @AminNegm-Awad 正如我在标题中提到的那样,我在#import &lt;Foundation/Foundation.h&gt; 行上收到错误
  • 在导入文件本身?
  • 上面的代码是我的 AppDelegate.h 中包含的代码,我在#import &lt;Foundation/Foundation.h&gt; 行上得到了双重错误
  • 能否请您提供您的前缀文件的内容?

标签: ios objective-c xcode


【解决方案1】:

我在我的代码中发现了同样的错误。检查每个文件。其他文件顶部有额外的 + 号。删除它,它工作正常。检查任何文件上是否有任何多余的字符。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-15
    • 1970-01-01
    相关资源
    最近更新 更多