Objective c 从数组中删除所有项并重新填充
我有这个阵列:Objective c 从数组中删除所有项并重新填充,objective-c,arrays,Objective C,Arrays,我有这个阵列: NSArray *currentPath; 它在这里被填充: currentPath = [[[self.tableData objectAtIndex:indexPath.row] objectForKey:@"Name"] componentsSeparatedByString:@"FTP\\"]; 我需要重新填充这个数组 NSString *newPreviousPath = [previousPath stringByReplacingOccurrencesOfStr
NSArray *currentPath;
它在这里被填充:
currentPath = [[[self.tableData objectAtIndex:indexPath.row] objectForKey:@"Name"] componentsSeparatedByString:@"FTP\\"];
我需要重新填充这个数组
NSString *newPreviousPath = [previousPath stringByReplacingOccurrencesOfString:nextItemToRemoveString withString:@""];
currentPath = [newPreviousPath];
但我一直在犯这样的错误:
Expected identifier
如何解决此问题并完成此任务?与swift不同,在目标c中,您应该像这样做:
currentPath = @[newPreviousPath];
查看magic
@
符号在目标C中的作用,详细答案如下:currentPath=[newPreviousPath];
在这里,您使用的是文本语法,这不是分配数组的正确方法。您需要执行以下操作
currentPath=@[newPreviousPath] 整个错误是什么?粘贴所有代码?