我一直在创建RSS Feed,但我收到了错误。
当我输入此代码时>
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
我收到错误线程1:信号SIGARBT 我输入了这个错误来解决这个错误。
static NSString *CellIdentifier = @"Cell";
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier];
但这更加复杂了问题因为当它工作时我无法点击单元格它将无法工作并为segue做准备所以当我点击单元格时它不会进入下一个View Controller。那更糟,所以我摆脱了。
static NSString *CellIdentifier = @"Cell";
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier];
^^^^
以上代码位于viewDidLoad
中一旦我摆脱了那段代码
当我打开我的应用时,我会在Thread 1: Signal SIGARBT
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
我已经尝试过这个错误没有得到修复的一切请修复Signal SIGARBT。
这是我的完整代码。
//
// AppMain.m
// fcffv
//
// Created by Ajay Venkat on 6/09/2014.
// Copyright (c) 2014 AJTech. All rights reserved.
//
#import "AppMain.h"
#import "AppDetail.h"
@interface AppMain () {
NSXMLParser *parser;
NSMutableArray *feeds;
NSMutableDictionary *item;
NSMutableString *title;
NSMutableString *link;
NSString *element;
}
@end
@implementation AppMain
- (void)awakeFromNib
{
[super awakeFromNib];
}
- (void)viewDidLoad {
[super viewDidLoad];
static NSString *CellIdentifier = @"Cell";
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CellIdentifier];
feeds = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:@"http://bountyboulevardss.eq.edu.au/?cat=3&feed=rss2"];
parser = [[NSXMLParser alloc] initWithContentsOfURL:url];
[parser setDelegate:self];
[parser setShouldResolveExternalEntities:NO];
[parser parse];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table View
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return feeds.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = [[feeds objectAtIndex:indexPath.row] objectForKey: @"title"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.tableView.delegate = self;
self.tableView.dataSource = self;
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
element = elementName;
if ([element isEqualToString:@"item"]) {
item = [[NSMutableDictionary alloc] init];
title = [[NSMutableString alloc] init];
link = [[NSMutableString alloc] init];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if ([elementName isEqualToString:@"item"]) {
[item setObject:title forKey:@"title"];
[item setObject:link forKey:@"link"];
[feeds addObject:[item copy]];
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
if ([element isEqualToString:@"title"]) {
[title appendString:string];
} else if ([element isEqualToString:@"link"]) {
[link appendString:string];
}
}
- (void)parserDidEndDocument:(NSXMLParser *)parser {
[self.tableView reloadData];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSString *string = [feeds[indexPath.row] objectForKey: @"link"];
[[segue destinationViewController] setUrl:string];
}
}
@end
图片:
这是图片^^^
伙计们请帮忙。
答案 0 :(得分:0)
确保您将StoryBoard中单元格的cellIdentifier设为 @" Cell" ,因为我可以看到您已写入static NSString *CellIdentifier = @"Cell";