• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problems with objects getting crossed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with objects getting crossed


  • Subject: Re: Problems with objects getting crossed
  • From: j o a r <email@hidden>
  • Date: Thu, 6 Oct 2005 07:59:32 +0200


On 6 okt 2005, at 02.59, Mark Williams wrote:

-(void)downloadFile:(NSDictionary*)file
{
NSDictionary * server = [NSDictionary dictionaryWithObjectsAndKeys:[serverInfo address],@"Server Address", [serverInfo port],@"Port",nil];


    Downloader * downloader = [[Downloader alloc]init];
    BOOL result = [downloader downloadFile:file fromServer:server];
    NSLog(@"%i",result)
    downloader = NULL:
    [downloader release];
}

You need to do the last two things in reverse order - otherwise your call to "release" will never have any effect.


Are you sure that you should release the new downloader object here? I assume that it downloads asynchronously, so in that case you would have to retain it elsewhere, or there will be problems. Is it being retained by your "StreamObject"?

Also note that in every case where you use "NULL" in the provided code, you should have used "nil". I don't think it makes any difference in functionality, but it looks weird - at least in the eyes of this ObjC programmer.

in the downloader class the init routine is pretty standard:
-(id)init
{
    if(self=[super init]){
        if([NSBundle loadNibNamed:@"Downloader" owner:self]){
            return self;
            }
        else{
            NSLog(@"NIB load failed, bailing out.");
            return NULL;
            }
    return NULL;
}

You need to do a "[self release]" after your error log statement.

and the download routine inits the stream object thusly:
-(BOOL)downloadFile:(NSDictionary*)file fromServer:(NSDictionary*) server
{
StreamObj = streamObject = [[StreamObject alloc] initWithServer:server delegate:self];
}

This seems like a pretty weird assignment - not illegal, but still weird. What is "StreamObj" in this context? Variables should have a leading lowercase character.


Also - where is the return statement? If this is your "real code", and not a copy-paste mistake from when you prepared the code to be emailed to the list, I would expect you to have warnings when you compile? If so, I really suggest that you clean up your code to remove all warnings before trying anything else.

j o a r



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >Problems with objects getting crossed (From: Mark Williams <email@hidden>)
 >Re: Problems with objects getting crossed (From: Pete Yandell <email@hidden>)
 >Re: Problems with objects getting crossed (From: Mark Williams <email@hidden>)

  • Prev by Date: awakeFromNib not called
  • Next by Date: Re: awakeFromNib not called
  • Previous by thread: Re: Problems with objects getting crossed
  • Next by thread: theme files
  • Index(es):
    • Date
    • Thread