iOS error: No visible @interface for 'xxxx' declares the selector 'alloc'
2013-10-14 23:30
633 查看
iOS
error: No visible @interface for 'Project' declares the selector 'alloc'
up vote4down votefavorite | I am initialising an object like so:Project *Project = [[Project alloc] init]; Here's the code for the project class: 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 I'm getting the error No visible @interface for 'Project' declares the selector 'alloc'when I try and initialise the object. How can I resolve this? iphone objective-c ios
| ||
2 Answers
activeoldestvotesup vote14down voteaccepted | You seem to be trying to call a variable the exact same name as the class: Project *Project. It's no wonder the compiler is getting confused! Switch the variable name to lower case, Project *project.
| ||||||||
|
up vote2down vote | Never use the class name as an instance reference name.GoddamnClass *GoddamnClass = [GoddamnClass new]; // will have problems GoddamnClass *anInstanceOfGoddamnClass = [GoddamnClass new]; // works like a magic
|
up vote4down votefavorite | I am initialising an object like so:Project *Project = [[Project alloc] init]; Here's the code for the project class: 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 I'm getting the error No visible @interface for 'Project' declares the selector 'alloc'when I try and initialise the object. How can I resolve this? iphone objective-c ios
| ||
2 Answers
activeoldestvotesup vote14down voteaccepted | You seem to be trying to call a variable the exact same name as the class: Project *Project. It's no wonder the compiler is getting confused! Switch the variable name to lower case, Project *project.
| ||||||||
|
up vote2down vote | Never use the class name as an instance reference name.GoddamnClass *GoddamnClass = [GoddamnClass new]; // will have problems GoddamnClass *anInstanceOfGoddamnClass = [GoddamnClass new]; // works like a magic
|
相关文章推荐
- iOS_ASI框架
- IOS动画Core Animation详解
- iOS中读取图片
- iOS7计算文本尺寸新方法
- iOS触摸事件处理
- iOS Framework: Introducing MKNetworkKit (MKNetworkKit介绍,入门,翻译)
- ios 优化 cpu缓存与程序内存分布
- ios开发-适配图片大小
- iOS的Animation及键盘的回收
- IOS之 OC 和 C类型转换
- ios开发-获取手机相关信息
- ios中为耗时动作添加indicatorview不可见问题及解决
- 【转】IOS开发之----LLDB和GDB的区别
- ios 如何移除全部subview和判断子视图是否加上
- Xcode5 + phoneGap2.9搭建ios开发环境-配置-测试-归档上传/phoneG...
- 如何发布IOS应用
- 使用CocoaPods来做iOS程序的包依赖管理
- iOS多线程编程指南(附录)
- iOS多线程编程指南(四)线程同步
- iOS多线程编程指南(三)Run Loop