2011-12-19 203 views
0
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

回答

2

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