container retain/release problem
container retain/release problem
- Subject: container retain/release problem
- From: Paul Forgey <email@hidden>
- Date: Wed, 9 Feb 2005 23:24:48 -0800
I've got an NSDictionary which I've built as per the quoted code below.
dict will autorelease, however I've got an NSArray element in there
which I've retained. So therefore, it should stick around, shouldn't
it? Problem is after the autorelease pool gets run, my instance
variable 'updates' has either been released or completely trashed.
Copying the array doesn't make things act any differently. What
exactly am I doing wrong?
-(void)connectionDidFinishLoading:(NSURLConnection *)conn
{
NSMutableDictionary *dict;
NSString *errorString;
NSPropertyListFormat format;
dict = [NSPropertyListSerialization propertyListFromData:recvBuffer
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&format
errorDescription:&errorString];
[connection release];
connection = nil;
[recvBuffer release];
recvBuffer = nil;
if (dict != nil)
{
if (updates != nil)
[updates release];
updates = [dict objectForKey:@"Updates"];
if (updates != nil && ![updates isKindOfClass:[NSMutableArray
class]])
updates = nil;
else
[updates retain];
if (delegate != nil)
[delegate dataSourceReloaded:self];
}
else
if (delegate != nil)
{
[delegate dataSource:self didFail:errorString];
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden