Q:

Objective C error: Passing argument 1 of 'setStringValue:' from incompatible pointer type

Ok here is part of the code that is causing the error:
    char charlieReturn[10000];
charlieReturn[10000] = system("osascript /applications/jarvis/scripts/getTextCharlieResponce.scpt");

 self.charlieOutput.stringValue = charlieReturn;

The getTextCharlieResponce.scpt returns something like this: "Hi my name is charlie" and maybe sometimes it will be longer than that. The script returns it plain text. I need help FAST! 
Thanks in advance! :D
Elijah

A:

Unfortunately there are many problems in your code.

The C function system does not return the standard output of the script as char*.
Even with a function which returns char*, you can't assign it to a array of char as you did:
 char* str="aeiou";
 char foo[100];
 foo[100]=str;   /* doesn't work */
 foo=str;   /* doesn't work either */

Cocoa's string class, NSString*, is not a C string char*, although you can easily convert between the two:
 NSString* str=[NSString stringWithUTF8String:"aeiou"];

If you want a string out of a call to an Apple script, you need to do the following:

Prepare an  NSAppleScript:
NSDictionary* errorDict;
NSAppleScript* script=[[NSAppleScript alloc] 
                        initWithContentsOfURL:[NSURL fileURLWithPath:@"path/to/script" ]
                                        error:&errorDict];

Execute and get a reply:
NSAppleEventDescriptor* desc=[script executeAndReturnError:&errorDict];
NSString* result=[desc stringValue];

Release the script:
[script release];

Learn C & Objective-C and have fun!

