iphone - iOS 错误 : No visible @interface for 'Project' declares the selector 'alloc'

标签 iphone objective-c ios

我正在像这样初始化一个对象:

Project *Project = [[Project alloc] init];

这是项目类的代码:

Project.h

#import <Foundation/Foundation.h>

@interface Project : NSObject
{

}

    @property (nonatomic,assign) int projectID; 
    @property (nonatomic,strong) NSString *name; 

@end

Project.m

#import "Project.h"

@implementation Project

    @synthesize projectID, name;

@end

我遇到错误 No visible @interface for 'Project' declares the selector 'alloc' 当我尝试初始化对象时。我该如何解决这个问题?

最佳答案

您似乎试图调用一个与类名称完全相同的变量:Project *Project。难怪编译器会感到困惑!

将变量名改为小写,Project *project

关于iphone - iOS 错误 : No visible @interface for 'Project' declares the selector 'alloc' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11949297/

相关文章:

iphone - 使用 iAd 的应用程序是否与旧版 iOS 兼容

iphone - 如何将图像从 Collection View 传递到iphone中的详细 View

ios - AVPlayer 和 AVFoundationErrorDomain 代码=-11819

iphone - 如何在iPhone的UILocalNotification中更改自定义声音?

ios - 图片不适合 WebView

ios - 自定义 UIViewController 转换 - 就像 iOS 11 的应用商店应用程序的今天选项卡

iphone - 限制可用的本地化

ios - 使用 objective-c 通过 SMS 发送数据

ios - "The file couldn’ t被打开的解决办法是什么。"UserInfo={NSURL=ftp :/xxxx:xxx@2011@ftp. xxx.com :21/}?

ios - 发电机 "Serialized object is not a valid json Object"