3

I have this array:

NSArray *currentPath;

and it gets populated here:

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

I need to repopulate this array again

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

    currentPath = [newPreviousPath];

but I keep getting this error:

Expected identifier

How do I fix this and accomplish this ?

ScottMcGready
  • 1,612
  • 2
  • 24
  • 33
user979331
  • 11,039
  • 73
  • 223
  • 418

2 Answers2

5

Unlike swift, in objective c you should do it like:

currentPath = @[newPreviousPath];

See what magic @ symbol does in Objective C, detailed answer here: Is there some literal dictionary or array syntax in Objective-C?

Community
  • 1
  • 1
Adil Soomro
  • 37,609
  • 9
  • 103
  • 153
0

currentPath = [newPreviousPath]; As in here you are using Literals syntax,it is not the right way to assign a array. You need to do following currentPath = @[newPreviousPath];