开发者

initWithDictionary

开发者 https://www.devze.com 2023-03-27 22:53 出处:网络
I have the problem that I can\'t get the Data from one of my classes to the other... To do this I created this method in the class I am initializing (angebotPage):

I have the problem that I can't get the Data from one of my classes to the other...

To do this I created this method in the class I am initializing (angebotPage):

- (id) initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];

if (self) {
    dict = [dictionary retain];
}

    return self;
}

The call from the other class looks like this:

angebotPage *page;
angebotPDF = [[PDFDocument alloc] init];
page = [[angebotPag开发者_运维技巧e alloc] initWithDictionary:dictionary];

The Error I get is EXC_BAD_ACCESS in the line where I do:

dict = [dictionary retain];

But why? I need to retain it cause I will use it for the next program steps.. But without retaining I can't use it (EXC_BAD_ACCESS comes elsewhere...)


I recommend that you use a property for dict instead.

@property (retain) NSDictionary *dict;

And then assign the dictionary with self.dict = dictionary. This is assuming all the objects in dictionary are correctly retained in the first place. Try with an empty dictionary if in doubt.

0

精彩评论

暂无评论...
验证码 换一张
取 消