2012-03-17 12 views
15

मैं एक साधारण आरएसएस एप्लीकेशन बना रहा हूं और मैं उद्देश्य-सी में अच्छा नहीं हूं। एप्लिकेशन हमेशा सफल बनायेगा और UITableView में कोई त्रुटि या चेतावनी नहीं है, जो आरएसएस पढ़ता है, जब भी मैं कोशिकाओं को दबाता हूं तो यह समाप्त हो जाएगा और मुख्य में। यह धागा इस पंक्ति में "थ्रेड 1: सिग्नल सिगैबर्ट" आएगा :एक्सकोड त्रुटि - थ्रेड 1: सिग्नल SIGABRT

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 

मेरे ऐप की जानकारी:

एप्लिकेशन Xcode संस्करण द्वारा बनाई गई है: 4.3.1 एप्लिकेशन iPhone के लिए और एक मैकबुक पर "मास्टर-विस्तार से आवेदन" टेम्पलेट से बनाया गया था। डिबगर मैं उपयोग कर रहा हूँ LLDB है और मेरे iPhone सिम्युलेटर 5.1 मैं स्टोरीबोर्ड

यहाँ का उपयोग कर रहा है main.m है:

#import <UIKit/UIKit.h> 

#import "AppDelegate.h" 

int main(int argc, char *argv[]) 
{ 

    @autoreleasepool { 
     return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 
    } 
} 

AppDelegate.h है:

#import <UIKit/UIKit.h> 

@interface AppDelegate : NSObject <UIApplicationDelegate> { 

    UIWindow *window; 
    UINavigationController *navigationController; 
} 

@property (nonatomic, retain) IBOutlet UIWindow *window; 
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController; 

@end 

मेरा AppDelegate.m है:

#import "AppDelegate.h" 




#import "AppDelegate.h" 
#import "MasterViewController.h" 


@implementation AppDelegate 

@synthesize window; 
@synthesize navigationController; 


#pragma mark - 
#pragma mark Application lifecycle 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
    // Override point for customization after app launch  

    [window addSubview:[navigationController view]]; 
    [window makeKeyAndVisible]; 
    return YES; 
} 


- (void)applicationWillTerminate:(UIApplication *)application { 
    // Save data if appropriate 
} 


#pragma mark - 
#pragma mark Memory management 

- (void)dealloc { 
    [navigationController release]; 
    [window release]; 
    [super dealloc]; 
} 


@end 

यह कॉन है एकमात्र संदेश:

-(void)fetchRss 
{ 
    NSLog(@"fetch rss"); 
    NSData* xmlData = [[NSMutableData alloc] initWithContentsOfURL:[NSURL URLWithString: kRSSUrl] ]; 
    NSError *error; 

    GDataXMLDocument* doc = [[GDataXMLDocument alloc] initWithData:xmlData options:0 error:&error]; 

    if (doc != nil) { 
     self.loaded = YES; 

     GDataXMLNode* title = [[[doc rootElement] nodesForXPath:@"channel/title" error:&error] objectAtIndex:0]; 
     [self.delegate updatedFeedTitle: [title stringValue] ]; 

     NSArray* items = [[doc rootElement] nodesForXPath:@"channel/item" error:&error]; 
     NSMutableArray* rssItems = [NSMutableArray arrayWithCapacity:[items count] ]; 

     for (GDataXMLElement* xmlItem in items) { 
      [rssItems addObject: [self getItemFromXmlElement:xmlItem] ]; 
     } 

     [self.delegate performSelectorOnMainThread:@selector(updatedFeedWithRSS:) withObject:rssItems waitUntilDone:YES]; 
    } else { 
     [self.delegate performSelectorOnMainThread:@selector(failedFeedUpdateWithError:) withObject:error waitUntilDone:YES]; 
    } 

    [doc autorelease]; 
    [xmlData release]; 
} 

MasterViewController.h:

#import <UIKit/UIKit.h> 
#import "RSSLoader.h" 
#import "DetailViewController.h" 


@interface MasterViewController : UITableViewController<RSSLoaderDelegate> { 

    RSSLoader* rss; 
    NSMutableArray* rssItems; 

} 



@end 

MasterViewController.m:

#import "MasterViewController.h" 

#import "DetailViewController.h" 




@implementation MasterViewController 

#pragma mark - 
#pragma mark View lifecycle 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.navigationItem.title = @"RAHNAVARD"; 
    self.navigationItem.prompt = @"LATEST NEWS"; 
    rssItems = nil; 
    rss = nil; 

    self.tableView.backgroundColor = [UIColor whiteColor]; 
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone]; 
    [self.tableView setIndicatorStyle:UIScrollViewIndicatorStyleWhite]; 

    //self.tableView.tableHeaderView = [[TableHeaderView alloc] initWithText:@"fetching rss feed"]; 

} 

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 

} 

- (void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 

    if (rss==nil) { 
     rss = [[RSSLoader alloc] init]; 
     rss.delegate = self; 
     [rss load]; 
    } 
} 

/* 
- (void)viewWillDisappear:(BOOL)animated { 
[super viewWillDisappear:animated]; 
} 
*/ 
/* 
- (void)viewDidDisappear:(BOOL)animated { 
[super viewDidDisappear:animated]; 
} 
*/ 

/* 
// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
// Return YES for supported orientations. 
return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 
*/ 


#pragma mark - 
#pragma mark Table view data source 

// Customize the number of sections in the table view. 
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 


// Customize the number of rows in the table view. 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    if (rss.loaded == YES) { 
     return [rssItems count]*2; 
    } else { 
     return 1; 
    } 
} 

- (UITableViewCell *)getLoadingTableCellWithTableView:(UITableView *)tableView 
{ 
    static NSString *LoadingCellIdentifier = @"LoadingCell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LoadingCellIdentifier]; 

    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:LoadingCellIdentifier] autorelease]; 
    } 

    cell.textLabel.text = @"Loading..."; 

    UIActivityIndicatorView* activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; 
    [activity startAnimating]; 
    [cell setAccessoryView: activity]; 
    [activity release]; 

    return cell; 
} 

- (UITableViewCell *)getTextCellWithTableView:(UITableView *)tableView atIndexPath:(NSIndexPath *)indexPath { 
    static NSString *TextCellIdentifier = @"TextCell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TextCellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:TextCellIdentifier] autorelease]; 
    } 

    NSDictionary* item = [rssItems objectAtIndex: (indexPath.row-1)/2]; 

    //article preview 
    cell.textLabel.font = [UIFont systemFontOfSize:11]; 
    cell.textLabel.numberOfLines = 3; 
    cell.textLabel.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7]; 
    cell.backgroundColor = [UIColor clearColor]; 
    cell.textLabel.backgroundColor = [UIColor clearColor]; 

    UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; 
    backView.backgroundColor = [UIColor clearColor]; 
    cell.backgroundView = backView; 

    CGRect f = cell.textLabel.frame; 
    [cell.textLabel setFrame: CGRectMake(f.origin.x+15, f.origin.y, f.size.width-15, f.size.height)]; 
    cell.textLabel.text = [item objectForKey:@"description"]; 

    return cell; 
} 

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    if (rss.loaded == NO) { 
     return [self getLoadingTableCellWithTableView:tableView]; 
    } 

    if (indexPath.row % 2 == 1) { 
     return [self getTextCellWithTableView:tableView atIndexPath:indexPath]; 
    } 

    static NSString *CellIdentifier = @"TitleCell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; 
    backView.backgroundColor = [UIColor clearColor]; 
    cell.backgroundView = backView; 

    NSDictionary* item = [rssItems objectAtIndex: indexPath.row/2]; 

    cell.textLabel.text = [item objectForKey:@"title"]; 

    return cell; 
} 



/* 
// Override to support conditional editing of the table view. 
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
// Return NO if you do not want the specified item to be editable. 
return YES; 
} 
*/ 


/* 
// Override to support editing the table view. 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 

if (editingStyle == UITableViewCellEditingStyleDelete) { 
// Delete the row from the data source. 
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
} 
else if (editingStyle == UITableViewCellEditingStyleInsert) { 
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. 
} 
} 
*/ 


/* 
// Override to support rearranging the table view. 
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 
} 
*/ 


/* 
// Override to support conditional rearranging of the table view. 
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 
// Return NO if you do not want the item to be re-orderable. 
return YES; 
} 
*/ 


#pragma mark - 
#pragma mark Table view delegate 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    [tableView deselectRowAtIndexPath:indexPath animated:NO]; 

    //DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 
    DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 
    detailViewController.item = [rssItems objectAtIndex:floor(indexPath.row/2)]; 
    [self.navigationController pushViewController:detailViewController animated:YES]; 
    [detailViewController release]; 
} 


#pragma mark - 
#pragma mark Memory management 

- (void)didReceiveMemoryWarning { 
    // Releases the view if it doesn't have a superview. 
    [super didReceiveMemoryWarning]; 

    // Relinquish ownership any cached data, images, etc that aren't in use. 
} 

- (void)viewDidUnload { 
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. 
    // For example: self.myOutlet = nil; 
} 


- (void)dealloc { 
    [rssItems release]; 
    rssItems = nil; 

    [rss release]; 
    rss = nil; 

    [super dealloc]; 
} 

#pragma mark - 
#pragma mark RSSLoaderDelegate 
-(void)updatedFeedWithRSS:(NSMutableArray*)items 
{ 
    rssItems = [items retain]; 
    [self.tableView reloadData]; 
} 

-(void)failedFeedUpdateWithError:(NSError *)error 
{ 
    // 
} 

@end 

आप और अधिक जानना चाहते हैं

2012-03-17 17:32:29.498 Rahnavard[1862:12e03] fetch rss 
2012-03-17 17:33:01.212 Rahnavard[1862:f803] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/hassantavari/Library/Application Support/iPhone Simulator/5.1/Applications/48090189-E17C-40CF-9BF1-ACA18FC0B02B/Rahnavard.app> (loaded)' with name 'DetailViewController'' 
*** First throw call stack: 
(0x16e4022 0x1875cd6 0x168ca48 0x168c9b9 0x366638 0x20c1fc 0x20c779 0x20c99b 0x20cd11 0x21e8fd 0x21eaef 0x21edbb 0x21f85f 0x21fe06 0x21fa24 0x393c 0x1d65c5 0x1d67fa 0xa6b85d 0x16b8936 0x16b83d7 0x161b790 0x161ad84 0x161ac9b 0x15cd7d8 0x15cd88a 0x145626 0x26a2 0x2615) 
terminate called throwing an exception(lldb) 

यहाँ है लाने आरएसएस थे जानकारी सिर्फ मुझे यह कहो उत्तर से और मैं अपना प्रश्न संपादित करूंगा और फिर आप अपना उत्तर संपादित कर देंगे।

मैं वास्तव में आपकी सहायता की सराहना करता हूं।

+6

SIGABRT का अर्थ है कि एक अपवाद ट्रिगर किया गया था। कंसोल लॉग सटीक अपवाद संदेश प्रिंट करेगा, और आपको इसे देखने की आवश्यकता है (इसे यहां पोस्ट करें)। – DarkDust

+1

अरे, आप अपनी एक्सकोड परियोजना फ़ाइलों और xib एक्सएमएल फाइलों को जोड़ना भूल गए हैं। – Abizern

उत्तर

9

आप DetailViewController नामक एक एक्सआईबी लोड करने की कोशिश कर रहे हैं, लेकिन ऐसा कोई XIB मौजूद नहीं है या यह आपके वर्तमान लक्ष्य का सदस्य नहीं है।

+1

इस उत्तर में जोड़ने के लिए - आप Ctrl-क्लिक कर सकते हैं और आउटलेट को हटा सकते हैं। यह मेरे कोड में कहीं भी नहीं था और यह एकमात्र तरीका है जिसे मैं इसे हटा सकता हूं। उत्पाद भी नहीं> स्वच्छ काम किया। – William

9

SIGABRT का अर्थ सामान्य रूप से एक अपवाद अपवाद है। कंसोल पर और जानकारी होनी चाहिए।

0

एसआईजीएबीआरटी, जैसा कि अन्य उत्तरों में बताया गया है, एक सामान्य बेजोड़ अपवाद है। आपको निश्चित रूप से उद्देश्य-सी के बारे में कुछ और सीखना चाहिए। समस्या शायद आपके UITableViewDelegate विधि में किया गया है SlectRowAtIndexPath।

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

मैं तुम्हें बहुत अधिक नहीं बता सकता जब तक आप हमें कोड जहां तालिका डेटा स्रोत और प्रतिनिधि तरीकों को संभालने के कुछ दिखाना।

+0

आपको लगता है कि यह एक टेबल व्यू है जो समस्या उत्पन्न कर रहा है जब अपवाद एनआईबी लोड करने में सक्षम नहीं होने के बारे में बात करता है? – DarkDust

+1

क्योंकि, यह तब होता है जब आप तालिका दृश्य कक्ष टैप करते हैं।लेकिन मैंने एक और बात देखी - आप नए व्यू कंट्रोलर को वास्तव में कैसे पेश कर रहे हैं? यदि बंडल निर्दिष्ट करने की आवश्यकता है, तो सुनिश्चित करें कि आपके पास [NSBundle mainBundle] है। और यह संकलन और निर्माण में भी एक त्रुटि हो सकती है। अपने एक्सआईबी की जांच करें यदि उसके पास सही लक्ष्य है और सफाई (कमांड + शिफ्ट + के) की सफाई करने की कोशिश करें और सफाई (कमांड + शिफ्ट + Alt + K) बनाएं। यह बहुत अच्छा होगा अगर हम उस कोड का हिस्सा देख सकें जहां आप आरएसएस प्राप्त करते हैं और स्पर्श को संभालते हैं। (कम से कम इसका कुछ हिस्सा) –

संबंधित मुद्दे