tags:

views:

44

answers:

3

Here is my code:

PtyView *v = [[PtyView alloc] init];
[v sendData([charlieImputText stringValue])];

in the PtyView.m file I have this:

void sendData(NSString *data) {
NSRunAlertPanel(@"",data,@"",@"",@""); //used for testing
}

But for some reason, the code errors: saying that PtyView may not respond to sendData, and I know that the code is incorrect. How would I accomplish this?

Thanks!

A: 

make sure you are importing "PtyView.h" into the file you are using it in.

Jesse Naugher
+3  A: 

sendData is not written in objective-C; it is a C primitive function. You should write a method in Obj-C like:

- (void) sendData: (NSString *)data {
  NSRunAlertPanel(@"",data,@"",@"",@"");
}
Anders
I get this error with the first code snippet as well, I'm not accessing it correctly: expected ']' before '(' token.
Elijah W.
Correct it to [v sendData:[charlieImputText stringValue]]; and read an introduction to the objective-c language.
FRotthowe
+1  A: 

To add to what Anders has said, even if sendData were properly implemented as a method, it is not being called correctly. The correct invocation syntax would be

[v sendData: [charlieImputText stringValue]];

More information about Objective-C methods can be found in Apple's documentation.

Ray