ARC Semantic Issue


#1

Hi,

Using XCode 4.4 on OSX Mountain Lion. I keep getting ARC Semantic Issue "No visible @interface for ‘BNRItem’ declares the selector ‘initWithItemName:valueInDollars:serialNumber:’ pointing at the following line of code in main.m file:

BNRItem *p = [[BNRItem alloc] initWithItemName:@"Red Sofa"
valueInDollars:100
serialNumber:@“A1B2C”];

I have looked over the code several times and I believe I typed it verbatim. Is this an XCode 4.4 problem? Any work arounds? Below is my code. Thanks.

//
//  main.m
//  RandomPossessions
//

#import <Foundation/Foundation.h>
#import "BNRItem.h"

int main(int argc, const char * argv[])
{

    @autoreleasepool {
       
        NSMutableArray *items = [[NSMutableArray alloc] init];
    
        BNRItem *p = [[BNRItem alloc] initWithItemName:@"Red Sofa"
                                        valueInDollars:100
                                          serialNumber:@"A1B2C"];
      
        NSLog (@"%@", p);  
        items = nil;
    }
    return 0;
}
    
//
//  BNRItem.m
//  RandomPossessions

#import "BNRItem.h"

@implementation BNRItem

- (id)init
{
    return [self initWithItemName:@"Item"
                   valueInDollars:0
                     serialNumber:@""];
}

- (id)initWithItemName:(NSString *)name valueInDollars:(int)value serialNumber:(NSString *)sNumber
{
    self = [super init];
    
    if (self)
    {
        [self setItemName:name];
        [self setSerialNumber:sNumber];
        [self setValueInDollars:value];
        dateCreated = [[NSDate alloc]init];
    }
    return self;
}

- (void)setItemName:(NSString *)str
{
    itemName = str;
}

- (NSString *)itemName
{
    return itemName;
}

- (void)setSerialNumber:(NSString *)str
{
    serialNumber = str;
}

- (NSString *)serialNumber
{
    return serialNumber;
}

- (void)setValueInDollars:(int)i
{
    valueInDollars = i;
}

- (int)valueInDollars
{
    return valueInDollars;
}

- (NSDate *)dateCreated
{
    return dateCreated;
}


-(NSString *)description
{
    NSString *descriptionString = [[NSString alloc] initWithFormat:@"%@ (%@)]: worth $%d, recorded on %@",
                                                                                            itemName,
                                                                                        serialNumber,
                                                                                        valueInDollars,
                                                                                            dateCreated];
    return descriptionString; 
}

@end

#2

Have you declared that method in the header file?

Make sure that it is declared in the header file; also make sure that there is no case mismatch.


#3

That worked! Thank you.