【发布时间】:2013-11-16 13:15:08
【问题描述】:
在成功 (:D) 与我的服务器通信后,我正在尝试解析它返回给我的 xml 文件。根据我正在打印的内容,我假设解析进行得相当顺利。问题是我是新手,对 NSXMLParser 非常非常非常陌生,并且无法在模拟器上的设备屏幕的小行部分中全部打印出来。我显示行但它们是空的,其中没有显示任何内容。如果习惯 NSXMLParser 或其他任何东西的人可以给我建议或告诉我它是否变得混乱,请:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [stories count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
// Set up the cell
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
[cell setText:[[stories objectAtIndex: storyIndex] objectForKey: @"sizing"]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
NSString * storyLink = [[stories objectAtIndex: storyIndex] objectForKey: @"module"];
storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
storyLink = [storyLink stringByReplacingOccurrencesOfString:@"\n" withString:@""];
storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"link: %@", storyLink);
//open in safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:storyLink]];
}
【问题讨论】:
-
当你说“把[ting]一切都放在屏幕上不起作用”时,它在什么方面不起作用?它不显示所有内容吗?它是否显示,但顺序错误?格式错了吗?我们需要更多关于问题所在的详细信息。
-
对不起,我没有很好地提出我的问题,除了需要的 18 行之外,它不会在屏幕上显示任何内容,但它们是空的(我将重新编辑我的问题)。
-
一般来说,如果是不同的主题(例如优化而不是同一段代码的更多问题),您应该发布新问题而不是添加到现有问题中。
标签: objective-c xml cocoa nsxmlparser nsxml