objective-c - 从数组中删除所有项目并重新填充它

标签 objective-c arrays

我有这个数组:

NSArray *currentPath;

它在这里被填充:

currentPath = [[[self.tableData objectAtIndex:indexPath.row] objectForKey:@"Name"] componentsSeparatedByString:@"FTP\\"];

我需要重新填充这个数组

NSString *newPreviousPath = [previousPath stringByReplacingOccurrencesOfString:nextItemToRemoveString withString:@""];

    currentPath = [newPreviousPath];

但我一直收到这个错误:

Expected identifier

我该如何解决这个问题并完成这个任务?

最佳答案

与 swift 不同,在 objective c 中你应该这样做:

currentPath = @[newPreviousPath];

看看魔术 @ 符号在 Objective C 中的作用,详细答案在这里:Is there some literal dictionary or array syntax in Objective-C?

关于objective-c - 从数组中删除所有项目并重新填充它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32385242/

相关文章:

python - 将两个数组按元素相乘,其中一个数组将数组作为元素

javascript - 使用 highchart 设置符号标记

PHP Foreach 循环效率

ios - iPhone 5S 特定错误 : No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=arm64, VALID_ARCHS=armv7 armv7s)

ios - 屏幕旋转时的多个 NSNotifications

ios - Realm 检索特定数据

java - 如何在循环中使用此设置方法

c - 使用指针对数组进行排序,不使用任何索引变量

ios - 结束更新后的 UITableView 部分页脚 View 位置

iphone - 如何将系统毫秒转换为 objective-c 中的日期