我想將下面的字符串轉換爲NSMuableArray。Swift:將字符串轉換爲NSMutableArray
var components: String = "library/book/science"
例如,我想在斯威夫特
NSArray *componentsArray = [@"library/book/science" componentsSeparatedByString:@"/"];
NSMutableArray *componentsMutableArray = [[NSMutableArray alloc] initWithArray:componentsArray];
[componentsMutableArray addObject:@"astronomy"];
將'String'更改爲'NSString',您可以繼續使用相同的功能。 –
堆棧溢出是一個問題和答案網站,而不是代碼翻譯服務。嘗試先自己翻譯代碼,然後在遇到困難時找到我們,確保向我們展示[您嘗試過的](http://stackoverflow.com/help/mcve)。 – SmokeDispenser