简体   繁体   English

NSString未声明的错误

[英]NSString undeclared error

I have been playing with the code from the create pdf tutorial on the iphonesdk site and I am stumped. 我一直在使用iphonesdk网站上的create pdf教程中的代码,感到很困惑。 I can create a pdf when I pass a float to NSString*text but when I try to take the value from a UITextField it comes up with an "input" undeclared. 当我将浮点数传递给NSString * text时,我可以创建一个pdf,但是当我尝试从UITextField中获取值时,它会带有未声明的“输入”。 "input" is the name of the textfield which is properly declared and hooked up, it is working fine. “输入”是正确声明并连接的文本字段的名称,它工作正常。 This is the code 这是代码

enter code here     

UIGraphicsPushContext(pdfContext);
CGContextTranslateCTM(pdfContext, 0, 20);
CGContextScaleCTM(pdfContext, 1.0, -1.0);
NSString *text = [NSString stringWithFormat:@"%@", input.text];
[text drawInRect:CGRectMake(400, -410, 150, 300) withFont:[UIFont fontWithName:@"Helvetica" size:12]];
UIGraphicsPopContext();
[text release];

Make sure that you are have the following code at the top of your .h or .m file: 确保在.h或.m文件的顶部具有以下代码:

#import <UIKit/UIKit.h>

You can also put the code in your Prefix.pch file. 您也可以将代码放入Prefix.pch文件中。

Also, make sure that you have @synthesize input; 另外,请确保您具有@synthesize输入。 at the beginning of your @implementation and that you have not changed the name of "input" in the @synthesize statement. 在@implementation的开头,并且您没有在@synthesize语句中更改“输入”的名称。 ie @synthesize input = input_;, if you have done that, you should put input_.text instead of input.text. 即@synthesize input = input_ ;;如果这样做,则应放置input_.text而不是input.text。

You can also use self.input.text. 您也可以使用self.input.text。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM