gpt4 book ai didi

iphone - NSString 变量不是 NSstring

转载 作者:行者123 更新时间:2023-12-01 19:12:02 28 4
gpt4 key购买 nike

我对 NSString 变量有疑问。

.h 文件

    NSString *strDeleteFilePath;
@property (nonatomic,retain) NSString* strDeleteFilePath;

.m 文件
    @synthesize strDeleteFilePath;

//之后当删除按钮点击
    -(IBAction)deleteButton:(id)sender {
UIButton *bt=(UIButton *)sender;
strDeleteFilePath=[FunctionManager getDocumentDirectoryPath:@"MyPhotos"];
strDeleteFilePath=[NSString stringWithFormat:@"%@/%@",strDeleteFilePath,[arrSaveImage objectAtIndex:bt.tag]];
NSLog(@"strDeletePath=%@",strDeleteFilePath);

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Are you sure you want to delete this photo" delegate:self cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel", nil];
[alert show];
[alert release];
}

nslog 在字符串中打印正确的路径,如下所示:

strDeletePath=/Users/Samir/Library/Application Support/iPhone Simulator/6.0/Applications/A72B7488-ABCB-48EC-91D0-CEE87FA121FE/Documents/MyPhotos/Dt20130411164806.png



当单击警报 View 中的删除按钮时...
   - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0){
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
if(![fileManager removeItemAtPath:strDeleteFilePath error:&error]) {
NSLog(@"Delete failed:%@", error);
} else {
NSLog(@"image removed: %@", strDeleteFilePath);
}
[self setScrollviewItem];
}
}

它在线崩溃 if(![fileManager removeItemAtPath:strDeleteFilePath error:&error]) 并给出以下错误 ExE_BAD..ACCESS...

error
ExE_Bad.....

先感谢您。

最佳答案

使用self. strDeleteFilePath而不是 strDeleteFilePath .

关于iphone - NSString 变量不是 NSstring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15963725/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com