麻烦大家看看下面的 还有 看书上说 BNItem *item =[[ BNItem alloc] init]; 创建对象要 item=nil
假设忘记怎么办?
假设忘记怎么办?
#import <Foundation/Foundation.h>
@interface BNItem : NSObject
{
NSString *_itemName;
NSString *_serialNumber;
int _valueInDollars;
NSDate *_dateCreated;
}
-(void)setItemName:(NSString *)str;
-(NSString *)itemName;
-(void)setSerialNumber:(NSString *)str;
-(NSString *)serialNumber;
-(void)setvalueInDollars:(int)v;
-(int)valueInDollars;
-(NSDate *)dateCreated;
@implementation BNItem
-(void)setItemName:(NSString *)str
{_itemName = str; }
-(NSString *)itemName{ return _itemName;}
-(void)setSerialNumber:(NSString *)str
{_serialNumber = str; }
-(NSString *)serialNumber
{ return _serialNumber; }
-(void)setvalueInDollars:(int)v
{_valueInDollars = v;}
-(int)valueInDollars
{ return _valueInDollars;}
-(NSDate *)dateCreated
{ return _dateCreated; }
@end
int main(int argc, const char * argv[])
{
BNItem *item =[[ BNItem alloc] init];
item.itemName = @"正常编译"; item.valueInDollars = 100; //编译不过去
小弟刚开始学ios,编译环境xcode 7.02 应该是最新版本的 系统虚拟机里安装的,不知道那里出错 }
解决方案
20
setvalueInDollars 的 V 是不是要大写呢