越来越sigarbt错误

问题描述:

PlistReader *pList = [[PlistReader alloc] init]; 
    [pList initWithFileName:@"CountryDetails"]; 
    CountryClass *objcountry =(CountryClass*) [pList getCountryInfoById:countryId]; 
    CCSprite *flag = [CCSprite spriteWithFile:objcountry.ImageUrl]; 
    flag.position = ccp(200, 265); 
    flag.scale = .255; 
    NSString *tempdata = objcountry.ShortDetail;//error line sigabrt 
    TextViewTopFlagData = [[UITextView alloc]init]; 
    TextViewTopFlagData.text = [NSString stringWithFormat:@"this is pakistan"];//countryInfo.ShortDetail; 
    TextViewTopFlagData.frame = CGRectMake(260,17, 105, 75); 
    TextViewTopFlagData.backgroundColor = [UIColor clearColor]; 
    [TextViewTopFlagData setEditable:NO]; 

你好我过得好行错误SIGABRT我提到它objcountry.ShortDetail也在这里NSString的类型,以便它为什么得到错误SIGABRT任何一个可以帮助越来越sigarbt错误

时我把NSString * tempdata = objcountry.ShortDetail;//错误线sigabrt之前的精灵线它没有错误,但当我放回精灵线后,它又得到了那个错误,所以任何人可以解释我,

这里是国家班结构

//CountryClass.h

// 
// CountryClass.h 
// NationalAntemsAndFlags 
// 
// Created by mac on 12/17/11. 
// Copyright (c) 2011 __MyCompanyName__. All rights reserved. 
// 

#import <Foundation/Foundation.h> 

@interface CountryClass : NSObject 
{ 
    NSString *Name ; 
    NSString *ImageUrl; 
    NSString *AnthemUrl; 
    NSString *ShortDetail; 
    NSString *completeDetails; 
    int LocationX ; 
    int LocationY ; 


} 
@property (nonatomic,retain) IBOutlet NSString *Name; 
@property (nonatomic,retain) IBOutlet NSString *ImageUrl; 
@property (nonatomic,retain) IBOutlet NSString *AnthemUrl; 
@property (nonatomic,retain) IBOutlet NSString *ShortDetail; 
@property (nonatomic,retain) IBOutlet NSString *completeDetails; 
@property (nonatomic) IBOutlet int LocationY; 
@property (nonatomic) IBOutlet int LocationX; 




@end 

//countryClass.m

// 
// CountryClass.m 
// NationalAntemsAndFlags 
// 
// Created by mac on 12/17/11. 
// Copyright (c) 2011 __MyCompanyName__. All rights reserved. 
// 

#import "CountryClass.h" 

@implementation CountryClass 

@synthesize Name,ImageUrl,AnthemUrl,ShortDetail,completeDetails,LocationX,LocationY; 

@end 

这是countryClass结构,我也试图[countryInfo保留],但没有happend

+0

你能告诉我们 - (CountryClass *)getCountryInfoById:和CountryClass.h吗? – 2011-12-19 06:11:21

+0

也许加载的精灵导致您的autorelease池清空。尝试[objcountry retain];在NCString * tempdata之后的CCSprite * flag ...和[objcountry release]之前...如果这不起作用,您将需要在崩溃时显示更多代码和调试器输出 – 2011-12-19 06:44:30

+0

我提供类现在检查它 – 2011-12-19 08:12:08

objcountry不是CountryClass的实际实例,它是某种其他类型的对象(不管[pList getCountryInfoById:country]返回)。如果代码不明显,请尝试使用NSLog(@"objcountry is a %@", [objcountry class]);将其打印出来。

表达式objcountry.ShortDetail是属性存取方法[objcountry ShortDetail]的语法糖。当运行时试图将消息ShortDetail发送到obejct,但对象不响应该消息时,将引发可怕的NSInvalidArgumentException消息“无法识别的选择器发送到类”(这应该打印到调试控制台)。如果没有人捕获到该异常(通常情况下),则运行时通过调用abort(3)方法进行响应,该方法使用SIGABRT信号终止应用程序。

+0

谢谢你的回复,但是当我把NSString * tempdata = objcountry.ShortDetail; //错误线sigabrt 之前的精灵线它没有错误,但是当我放回精灵线后它再次得到该错误,所以你能解释我 – 2011-12-19 06:28:50