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可以任何一个帮助
当我在精灵行之前放置NSString * tempdata = objcountry.ShortDetail; //错误行sigabrt它没有错误但是当我在精灵行后放回它再次得到那个错误所以任何人都可以解释我< / p>
这里是countryClass structer
// 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保留]但没有发生任何事情
答案 0 :(得分:2)
objcountry
不是CountryClass
的实际实例,它是其他类型的对象(无论[pList getCountryInfoById:country]
返回什么)。如果从代码中看不出它是什么类型的对象,请尝试使用NSLog(@"objcountry is a %@", [objcountry class]);
打印出来。
表达式objcountry.ShortDetail
是属性访问器方法[objcountry ShortDetail]
的语法糖。当运行时尝试将消息ShortDetail
发送到obejct但对象没有响应该消息时,可怕的NSInvalidArgumentException
会被抛出,并显示消息“无法识别的选择器被发送到类”(这应该得到)打印到调试控制台)。如果没有人捕获该异常(通常是这种情况),则运行时通过调用abort(3)
方法进行响应,该方法使用SIGABRT
信号终止应用程序。