Use the %d
specifier.
- (IBAction)main:(id)sender
{
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"return the clipboard"];
NSAppleEventDescriptor *clipboardTXT = [script executeAndReturnError:nil];
NSInteger length = [[clipboardTXT stringValue] length];
NSString *mystring = [NSString stringWithFormat:@"%d", length];
[mybutton setTitle:mystring];
}
EDIT:
Your problem is a totally different one then what you're asking. Why didn't you include the error message the first time? Time waster...
It obviously points out that the problem has to be somewhere around your stringValue
calls. If you had googled it you certainly would've found that this error message means the object you're sending stringValue
to, doesn't have such a method. executeAndReturnError
returns an NSAppleEventDescriptor
instance. You then call stringValue
which will return an NSString
, not an NSAppleEventDescriptor
. After that you're sending a stringValue
message to an NSString
(it doesn't have such a method). See my edited code.