2012-02-20 43 views
0

我想將一個字符串拆分成一個數組。這是我使用(另外,我使用ARC)的代碼:componentSeparatedByString不能與NSString一起工作

test = @"this$is$a$test"; 

myarray = [test componentSeparatedByString:@"$"]; 

testmyarray被合成的特性。

我得到一個錯誤:

receiver type 'nsstring' for instance message does not declare a method with selector 'componentseparatedbystring'

誰能幫助我這件事? 謝謝

回答

4

這是componentscomponent。當您收到警告說明方法不存在時,請確保您參考documentation

myarray = [test componentsSeparatedByString:@"$"]; 
+0

另外:你應該使用你的自動補全。在輸入方法名稱的第一部分(即「comp ...」)後,您會看到可用的方法。 – phlebotinum 2012-03-03 19:33:56