No visible @interface for 'Person' declares the selector


When I’m trying to run the altered First Class exercise (with properties) I get the build-error: No visible @interface for ‘Person’ declares the selector ‘setWeightInKilos’.
I’ve added the code and have checked it for many times but I can’t find my error.

[color=#000080]Can someone help me with this one?[/color]
Here’s the code:


[code]#import <Foundation/Foundation.h>

@interface Person : NSObject
// It takes two instance variables
float heightInMeters;
int weightInKilos;
@property float heightInMeters;
@property int weightInKilos;

// This method calculates the Body Mass Index

  • (float)bodyMassIndex;



[code]#import “Person.h”

@implementation Person

@synthesize heightInMeters, weightInKilos;

  • (float)bodyMassIndex
    return weightInKilos / (heightInMeters * heightInMeters);


#import "Person.h"

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

    @autoreleasepool {
        // Create an instance of Person
        Person *person = [[Person alloc] init];
        // Give the instance variables interesting values
        [person setWeightinKilos:96];
        [person setHeightInMeters:1.8];
        // Call the bodyMassIndex method
        float bmi = [person bodyMassIndex];
        NSLog(@"Person (%d, %f) has a bmi of %f", [person weightInKilos], [person heightInMeters], bmi);
    return 0;


I think I’ve found the problem…
Under ‘Build settings / Apple LLVM Compiler 3.1 - language’ the item Objective-C Automatic Reference Counting was set to Yes. After setting it to No the application was built and I could run the application.

But for being correct: should this setting be set to ‘Yes’ of ‘No’ for future development?


[quote]I get the build-error: No visible @interface for ‘Person’ declares the selector ‘setWeightInKilos’[/quote].

The problem is caused by the [color=#FF0000]case error[/color], not by the ARC setting.

Change [person setWeight[color=#FF0000]in[/color]Kilos:96]; to [person setWeight[color=#40BF00]In[/color]Kilos:96];


Additionally, ARC is the future of development for Apple’s platforms. For new projects, (except where educational exercises explicitly state otherwise) I recommend leaving this setting ON.

Perhaps one of the reasons for the discrepency in whether or not you got the error, is that when ARC is enabled, there are certain rules that the compiler enforces more strictly.


I solved this error with out any change in Xcode setting, take a look at this article:
:smiley: :geek: :smiley: