困惑如何在iphone上使用componentsSeparatedByString

时间:2010-10-05 02:23:49

标签: iphone

在我的NSMutable数组AB的nsXml pasring值之后

=\n\n\n\thttp://xyz.com/uploads/resto_6298__20091209@1621_250.JPG\n\thttp://xyz.com/uploads/resto_6298__200912099_2_250.JPG\n"

现在我这样做是为了让这个网址正常工作

NSString *sw=AB;


NSArray *strings = [sw componentsSeparatedByString: @"\n\t"];
NSLog(@"what I have %@",strings);

但我的应用程序总是崩溃,我收到此错误

[NSCFArray componentsSeparatedByString:]: unrecognized selector sent to instance 0x1b28b0
2010-10-05 10:17:31.382 Wat2Eat[2311:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFArray componentsSeparatedByString:]: unrecognized selector sent to instance 0x1b28b0'

如何解析此AB以便我可以提取确切的URL

1 个答案:

答案 0 :(得分:1)

  

NSString *sw=AB;

AB是NSMutableArray? 如果您尝试这样做,编译器应该打印警告。您试图将NSArray分配给NSString。这不行。

您的意思是NSString *sw = [AB objectAtIndex:foo];吗?