[英]How do i put an XML source into an NSString?
I've done this with HTML, like so: 我已经用HTML完成了,就像这样:
NSString *theweatherhtml = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"*URL STRING WOULD GO HERE*"]];
But when i do this with an XML file, it returns a 'Program received signal: “EXC_BAD_ACCESS”.' 但是,当我使用XML文件执行此操作时,它将返回“程序接收到的信号:“ EXC_BAD_ACCESS”。
Is there a different way to do this for XML files? 有没有其他方法可以对XML文件执行此操作?
That method is deprecated. 该方法已弃用。 You need to use: 您需要使用:
initWithContentsOfURL:encoding:error:
http://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSString_Class/Reference/NSString.html http://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSString_Class/Reference/NSString.html
You can use NSMutableDictionary using objectforkey Or NSArray and then convert each value into related varibles. 您可以使用objectforkey或NSArray使用NSMutableDictionary,然后将每个值转换为相关的变量。 Like - 喜欢 -
int value; 整数值 value = [[savedStock objectForKey:@"userID"] intValue]; 值= [[savedStock objectForKey:@“ userID”] intValue];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.