0

I am new to iOS, if you look at the following code, I would expect both x and y to be "hello"

- (void)viewDidLoad {
    [super viewDidLoad];

     NSString  *x,*y;

     y=    [x getstring];



}//viewDidLoad

-(NSString *)getstring{


    return @"hello";

}

Yet, I get this error: No visible @interface for NSString declares the selector 'getString'

I tried many things, I defined getstring in the .h file

2
  • 1
    You should explain why you expect that Commented Jul 22, 2015 at 13:42
  • Before explaining to @Wain question, please read more about Objective-C Commented Jul 22, 2015 at 14:09

1 Answer 1

3

Your x variable is type on NSString ant there is no method getString defined there.

I believe you want to call [self getstring] instead:

y =  [self getstring];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.