How can I put my NSInteger into my NSString stringWithFormat:
my code:
-(IBAction)main:(id)sender
{
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"return the clipboard"];
NSAppleEventDescriptor *clipboardTXT = [[script executeAndReturnError:nil]stringValue];
NSInteger *length = [clipboardTXT.stringValue length];
NSString *mystring = [NSString stringWithFormat:@"%", length];
[mybutton setTitle:mystring];
}
p.s. I’ve tried this but it didn’t work for me.
Use the
%dspecifier.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
stringValuecalls. If you had googled it you certainly would’ve found that this error message means the object you’re sendingstringValueto, doesn’t have such a method.executeAndReturnErrorreturns anNSAppleEventDescriptorinstance. You then callstringValuewhich will return anNSString, not anNSAppleEventDescriptor. After that you’re sending astringValuemessage to anNSString(it doesn’t have such a method). See my edited code.