user979331
user979331

Reputation: 11851

Remove all items from array and repopulate it

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 ?

Upvotes: 3

Views: 59

Answers (2)

Abhishek Bhardwaj
Abhishek Bhardwaj

Reputation: 98

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];

Upvotes: 0

Adil Soomro
Adil Soomro

Reputation: 37729

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?

Upvotes: 5

Related Questions