Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Introduction to Objective-C From Structs to Objects

Shaun Kelly
Shaun Kelly
5,648 Points

No visible @interface for 'Sphere' declares the selector 'setRadius:'

In my main call is says No visible @interface for 'Sphere' declares the selector 'setRadius:' No visible @'interface for 'Sphere' declares the selector 'radius'

This is my code for each class

Main :

import "Sphere.h"

int main() { Sphere *ball = [[Sphere alloc] init];

[ball setRadius:25];
NSLog(@"ball radius %f", [ball radius]);

return 0;

}

Sphere.h:

@interface Sphere : NSObject {

NSArray *_center;
float _radius;

} -(void)setradius:(float)radius; -(float)_radius;

-(void)setcenter:(NSArray *)center; -(NSArray *)_center; @end

Sphere.m

@implementation Sphere

-(void)setradius:(float)radius { _radius = radius; } -(float)_radius { return _radius; }

-(void)setcenter:(NSArray *)center { _center = center; } -(NSArray *)_center { return _center; } @end

3 Answers

Rami Ammoun
Rami Ammoun
7,468 Points

your Sphere.h code had 3 errors:

please copy paste this code and compare with your existing code:

@interface Sphere : NSObject {

    NSArray *_center;
    float _radius;
}
-(void)setRadius:(float)radius;
-(float)radius;

-(void)setCenter:(NSArray *)center;
-(NSArray *)_center;

@end

This should work. Let me know if u need further help

Shaun Kelly
Shaun Kelly
5,648 Points

How do you get all the code in the black box ?

Rami Ammoun
Rami Ammoun
7,468 Points

Click on the Markdown Cheatsheet. It will show you tips to format your discussion. For wrapping the code in blackbox it says the following:

Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.

        ```html
        <p>This is code!</p>
        ```

I hope his helps.

Shaun Kelly
Shaun Kelly
5,648 Points

How will I type that in a mac computer ?

Rami Ammoun
Rami Ammoun
7,468 Points

To the right of this screen, there is a video under the title: Tips for asking questions. Click on it, it will explain how.