Iphone 将NSString复制到NSString时获取sigarbt错误

Iphone 将NSString复制到NSString时获取sigarbt错误,iphone,objective-c,cocos2d-iphone,Iphone,Objective C,Cocos2d Iphone,嗨,我在网上看到了错误sigabrt,我提到了objcountry.ShortDetail也是NSString类型,所以为什么它在这里出现错误sigabrt有人能帮忙吗 当我放置NSString*tempdata=objcountry.ShortDetail//错误行sigabrt在精灵行之前没有错误,但当我放回精灵行之后,它又出现了错误,所以有人能解释我吗 这是countryClass结构器 //乡村班 PlistReader *pList = [[PlistReader alloc] ini

嗨,我在网上看到了错误sigabrt,我提到了objcountry.ShortDetail也是NSString类型,所以为什么它在这里出现错误sigabrt有人能帮忙吗

当我放置NSString*tempdata=objcountry.ShortDetail//错误行sigabrt在精灵行之前没有错误,但当我放回精灵行之后,它又出现了错误,所以有人能解释我吗

这是countryClass结构器

//乡村班

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];

这是countryClass结构,我确实尝试过[countryInfo retain],但没有发生任何事情

objcountry
不是
countryClass的实际实例,它是其他类型的对象(无论
[pList getCountryInfoById:country]
返回什么)。如果从代码中看不出它是什么类型的对象,请尝试使用
NSLog(@“objcountry是%@,[objcountry class])打印出来


表达式
objcountry.ShortDetail
是属性访问器方法
[objcountry ShortDetail]
的语法糖。当运行时试图将消息
ShortDetail
发送到obejct,但对象没有响应该消息时,可怕的
NSInvalidArgumentException
会抛出消息“unrecognized selector sent to class”(这应该会打印到调试控制台)。如果没有人捕捉到该异常(通常情况下),运行时会通过调用方法进行响应,该方法会使用
SIGABRT
信号终止应用程序。

您能告诉我们-(CountryClass*)getCountryInfoById:和CountryClass.h吗?可能加载sprite会导致自动释放池变空。尝试[目标国家保留];在CCSprite*标志之前。。。以及NSString*tempdata之后的[objcountry release]。。。如果这不起作用,您将需要显示更多的代码,crashi上的调试器输出将提供类check it Now感谢您的回复,但当我放置NSString*tempdata=objcountry.ShortDetail//错误线sigabrt在精灵线之前没有错误,但是当我放回精灵线之后,它又出现了错误,所以你能解释一下吗
//
//  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
//  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