简体   繁体   English

iOS Xcode应用中的代码错误

[英]Code error in iOS Xcode app

In my Viewcontroller.m I have this code: 在我的Viewcontroller.m中,我有以下代码:

- (void)viewDidLoad {

    NSData *dataPdf = [NSData dataWithContentsOfURL:pdfOnline.url];

    //Get path directory
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    //Create PDF_Documents directory
    documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@"PDF_Documents"];
    [[NSFileManager defaultManager] documentsDirectory withIntermediateDirectories:YES attributes:nil error:nil];

    NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory, @"My PDF File"];

    [dataPdf writeToFile:filePath atomically:YES];

    [self refresh:self];

    [super viewDidLoad];

    [self.imageView setImage:[UIImage imageNamed:@"Picture.tiff"]];

    [self.scrollView setMaximumZoomScale:10.0f];
    [self.scrollView setClipsToBounds:YES];

    _myBotton.layer.borderWidth =2.0f;
    _myBotton.layer.borderColor = [[UIColor redColor]CGColor];
}

At: NSData *dataPdf = [NSData dataWithContentsOfURL:pdfOnline.url]; 在: NSData *dataPdf = [NSData dataWithContentsOfURL:pdfOnline.url]; I get this error: Use of undeclared identifier 'pdfOnline' 我收到此错误: Use of undeclared identifier 'pdfOnline'

At: [[NSFileManager defaultManager] documentsDirectory withIntermediateDirectories:YES attributes:nil error:nil]; 在: [[NSFileManager defaultManager] documentsDirectory withIntermediateDirectories:YES attributes:nil error:nil]; I get this error: Expected ':' 我收到此错误:预期为':'

How can I solve these errors? 我该如何解决这些错误? Please help me. 请帮我。

This is what errors means: 这就是错误的含义:

You are using pdfOnline but this variables is not defined on the current scope. 您正在使用pdfOnline,但是当前变量未定义此变量。 pdfOnline seems like a property in the class. pdfOnline似乎是该类中的一个属性。 try using "self.pdfOnline" and also double check the header files contains that property. 尝试使用“ self.pdfOnline”,并再次检查头文件是否包含该属性。

t: NSData *dataPdf = [NSData dataWithContentsOfURL:pdfOnline.url]; t:NSData * dataPdf = [NSData dataWithContentsOfURL:pdfOnline.url]; I get this error: Use of undeclared identifier 'pdfOnline' 我收到此错误:使用未声明的标识符'pdfOnline'

You are misspelling this(not sure what you want here) 您拼写错误(不确定在这里想要什么)

At: [[NSFileManager defaultManager] documentsDirectory withIntermediateDirectories:YES attributes:nil error:nil]; 在:[[NSFileManager defaultManager]带有中间目录的文档目录:是属性:无错误:无]; I get this error: Expected ':' 我收到此错误:预期为':'

Try: 尝试:

[[NSFileManager defaultManager] createDirectoryAtPath:documentsDirectory withIntermediateDirectories:YES attributes:nil error:nil];

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

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