在子视图中访问对象时获取 EXC_BAD_ACCESS

发布于 2024-10-07 13:37:11 字数 1615 浏览 4 评论 0原文

也许是一个非常基本的问题,但我不明白......

我已经编写了自己的类,以便在我的 iPhone 应用程序中将数据作为对象。该类的类型为 NSObject。该类具有多个 NSString 属性以及其他类的三个对象。

@interface vcardItem : NSObject {
vCardNitem *PersonName;
NSString *Phone;
NSString *PhotoURL;
vCardTELitem *PhoneData;
NSString *URL;
NSString *eMail;
vCardADRItem *Address;
NSString *Company;
NSString *Role;
int initialised;
}

@property (nonatomic, retain) vCardNitem *PersonName;
@property (nonatomic, retain) NSString *Phone;
@property (nonatomic, retain) NSString *PhotoURL;
@property (nonatomic, retain) vCardTELitem *PhoneData;
@property (nonatomic, retain) NSString *URL;
@property (nonatomic, retain) NSString *eMail;
@property (nonatomic, retain) vCardADRItem *Address;
@property (nonatomic, retain) NSString *Company;
@property (nonatomic, retain) NSString *Role;
@property int initialised;

-(id)initEmpty;
-(id)initWithPayload:(NSString *)payload;
-(void)sendToAddressBook;
-(void)debugVCard;
-(NSString *)getFirstName;
@end

我正在视图控制器内的函数调用中创建 vcardItem 对象。数据已填充且可访问。调用函数 initWithPayload 并设置所有属性。

然后我打开另一个视图来显示详细信息,并使用我的 vcardItem 对象(仍然可以完全访问)调用函数 setVCard:

VCardViewController *aVCardViewController = [[VCardViewController alloc] init];
[self presentModalViewController:aVCardViewController animated:YES];
[aVCardViewController setVCard:aVCard];

然后,在 VCardViewController 中,只有 NSString 属性可以访问。一旦我尝试访问 VCardNItem、vCardADRitem 或 vCardTELitem 的属性,我就会收到 EXC_BAD_ACCESS 错误。

看起来 vcardItem 对象中的对象不可用!?

我已经设置了 NSZombie... 东西,我的 vcardItem 对象仍然存在(没有“Zombie”),但我无法访问数据。

有什么想法吗?我有点卡在这里......

Maybe a very basic problem, but i don't get it ...

I've written my own class for having Data as an Object in my iPhone app. The class is of Type NSObject. The Class has several NSString propertys and also three objects of other classes.

@interface vcardItem : NSObject {
vCardNitem *PersonName;
NSString *Phone;
NSString *PhotoURL;
vCardTELitem *PhoneData;
NSString *URL;
NSString *eMail;
vCardADRItem *Address;
NSString *Company;
NSString *Role;
int initialised;
}

@property (nonatomic, retain) vCardNitem *PersonName;
@property (nonatomic, retain) NSString *Phone;
@property (nonatomic, retain) NSString *PhotoURL;
@property (nonatomic, retain) vCardTELitem *PhoneData;
@property (nonatomic, retain) NSString *URL;
@property (nonatomic, retain) NSString *eMail;
@property (nonatomic, retain) vCardADRItem *Address;
@property (nonatomic, retain) NSString *Company;
@property (nonatomic, retain) NSString *Role;
@property int initialised;

-(id)initEmpty;
-(id)initWithPayload:(NSString *)payload;
-(void)sendToAddressBook;
-(void)debugVCard;
-(NSString *)getFirstName;
@end

I'm creating an object of vcardItem in a function call within my viewcontroller. The Data is filled and accessible. The function initWithPayload is called and all propertys are set.

Then i open another view for showing Details and call the function setVCard with my vcardItem Object (which is still completeley accessible):

VCardViewController *aVCardViewController = [[VCardViewController alloc] init];
[self presentModalViewController:aVCardViewController animated:YES];
[aVCardViewController setVCard:aVCard];

within the VCardViewController then, only the NSString propertys are accesible. As soon as i stry to access propertys of VCardNItem, vCardADRitem or vCardTELitem, i get an EXC_BAD_ACCESS Error.

Looks like the Objects within the vcardItem Object are not available !?

I've set the NSZombie... thing, my vcardItem Object is still living (No "Zombie"), but i cannot access the data.

any Idea? I'm a little bit stucked here....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

濫情▎り 2024-10-14 13:37:11

Code Review 完成了这项工作,在 Xcode 4 中针对 iOS 5 进行构建后,一切都很好!

Code Review did the job, after building in Xcode 4 against iOS 5 all is fine!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文