0

I am trying to do very simple operation.

in "TestFile.h" file i've declare property:

@property (nonatomic) NSDictionary *justTest;    

and in implementation file "TestFile.m":

-(NSDictionary *)justTest:(NSString *) mystring {

NSLog(@"Here is my string: %@", mystring);
return nil;

}

Now i am trying to call "justTest" from another file. What i am doing:

 #import "TestFile.h"


- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.

  NSDictionary *testFile = [[TestFile alloc] init];

  [testFile justTest:@"Hello World!"]

}     

This works fine until i'm trying to pass parameter.

if i just execute

[testFile justTest];    

it works, but when i try to pass parameter

[testFile justTest:@"Hello World!"];    

does not work and the debug message is:

no visible @interface for 'TestFile' declares the selector 'justTest':    

What is wrong with me?

Oleg Popov
  • 2,464
  • 1
  • 17
  • 15

2 Answers2

1

You need to make this method public by adding method name to TestFile.h file before @end:

-(NSDictionary *)justTest:(NSString *) mystring;

Just to let you know when you add @property compiler synthesise it (create) two method getter, exactly the same name as your property and setter compiler add 'set' prefix, for example, you declare:

@property (nonatomic) NSDictionary *justTest;

compiler will create two methods:

-(NSDictionary *)justTest {...}
-(void)setJustTest {...}

You need to know that in your code you override the getter method.

Greg
  • 25,317
  • 6
  • 53
  • 62
1

Declare your method in TestFile.h file before calling from an external class.

-(NSDictionary *)justTest:(NSString *) mystring;
QUserS
  • 512
  • 5
  • 13