Error: no visible @interface for 'Employee' declares the sel



i’m currently learning objective-c by the “big nerd ranch”-book. I’ve repeated the code from chapter 18, but I’m getting errors. using 64bit macos 10.6 witch actual version of xcode.

I’ve posted this question already in … nheritance. I hope this forum is a better place for asking. Maybe I can help with my question further readers of this book. It’s exceptional that I post my problem in 2 platforms, since this is my first posting here.

compiler says:

[quote]Build target BMITime

CompileC /Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ BMITime/main.m normal x86_64 objective-c cd /Users/pm/Dropbox/objective-c/BMITime setenv LANG en_US.US-ASCII /Applications/ -x objective-c -arch x86_64 -fmessage-length=0 -std=gnu99 -fobjc-arc -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-implicit-atomic-properties -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wno-undeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -isysroot /Applications/ -fasm-blocks -Wprotocol -Wdeprecated-declarations -mmacosx-version-min=10.7 -g -Wno-conversion -Wno-sign-conversion “-DIBOutlet=attribute((iboutlet))” “-DIBOutletCollection(ClassName)=attribute((iboutletcollection(ClassName)))” “-DIBAction=void)attribute((ibaction)” -iquote /Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ -I/Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ -I/Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ -iquote /Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ -I/Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Products/Debug/include -I/Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ -I/Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ -F/Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Products/Debug -include /Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/PrecompiledHeaders/BMITime-Prefix-bbjacqhmgaerfrhblktcvkpzzntb/BMITime-Prefix.pch -MMD -MT dependencies -MF /Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ --serialize-diagnostics /Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/ -c /Users/pm/Dropbox/objective-c/BMITime/BMITime/main.m -o /Users/pm/Library/Developer/Xcode/DerivedData/BMITime-cjqpmtvlmdoeiecyxbofznzjgpij/Build/Intermediates/

/Users/pm/Dropbox/objective-c/BMITime/BMITime/main.m:21:10: error: no visible @interface for ‘Employee’ declares the selector ‘setWeightInKilos:’ [person setWeightInKilos:96]; ^ /Users/pm/Dropbox/objective-c/BMITime/BMITime/main.m:22:10: error: no visible @interface for ‘Employee’ declares the selector ‘setHeightInMeters:’ [person setHeightInMeters:1.8]; ^ /Users/pm/Dropbox/objective-c/BMITime/BMITime/main.m:26:22: error: no visible @interface for ‘Employee’ declares the selector ‘bodyMassIndex’ float bmi = [person bodyMassIndex]; ^ 3 errors generated.[/quote]

my code looks like this:


[code]#import <Foundation/Foundation.h>
#import “Employee.h”

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

@autoreleasepool {

    // Erstellt eine Instanz von Person
    Employee *person = [[Employee alloc] init];

    // Gibt den Instanzvariablen interessante Werte
    [person setWeightInKilos:96];
    [person setHeightInMeters:1.8];
    [person setEmployeeID:15];

    // Ruft die Methode bodyMassIndex auf
    float bmi = [person bodyMassIndex];
    NSLog(@"Employee %d has a BMI of %f", [person employeeID], bmi);

return 0;



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

// Die Klasse Person erbt alle Instanzvariablen
// und Methoden, die von der Klasse NSObject definiert wurden
@interface Person : NSObject
// Sie hat zwei Instanzvariablen
float heightInMeters;
int weightInKilos;
@property float heightInMeters;
@property int weightInKilos;

// Diese Methode berechnet den Body-Mass-Index

  • (float)bodyMassIndex;


[code]#import <Foundation/Foundation.h>
#import “Person.h”

@interface Employee : NSObject
int employeeID;
@property int employeeID;


[code]#import “Employee.h”

@implementation Employee

@synthesize employeeID;



[code]#import “Person.h”

@implementation Person

@synthesize heightInMeters, weightInKilos;

  • (float)bodyMassIndex
    //return weightInKilos / (heightInMeters * heightInMeters);
    float h = [self heightInMeters];
    return [self weightInKilos] / (h * h);


I’m looking forward to your answer. :slight_smile:


It took me a while to spot this simple error: You meant to type in Peson but instead typed in NSObject.

Turn off your AutoPilot :slight_smile:


I ran into a similar problem… except I didn’t see an error in my code (comparing with the text in the book and here). The compiler complains that the setter methods for Person are not seen by Employee, with “No visible interface declares the selector…”

I ran it down to using “setweightInKilos” and “setheightInMeters” when declaring explicitly rather than “setWeightInKilos” and “setHeightInMeters” since upon seeing no errors in Person.h and Person.m after running and then modifying the class to use @property and @synthesize, I did not compile and run before moving on to adding the Employee class.

This might also be a good place for other newbies to look if they run into the error, since the capitalization is very specific in the synthesized methods and it is very easy to miss the first cap when declaring explicitly.

The clue should have been that the text color for the accessors was still black.