• 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: NSSocketPort question: retainCount
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSocketPort question: retainCount


  • Subject: Re: NSSocketPort question: retainCount
  • From: Nicko van Someren <email@hidden>
  • Date: Mon, 16 May 2005 16:48:22 +0100

On 16 May 2005, at 16:04, Fabio Ribeiro wrote:

Any idea on why the code below (at least on Tiger - I didn't tested on Panther) reports '2' for the retainCount after I've called only once 'init?'?

Could it be that some asynchronous process is being used to resolve address and port name bindings, and that the code doing that is retaining the object since otherwise "bad things" would happen if the resolution completed after you had released the object? If this is the case you'd be able to tell by not releasing the object and looking again a little while later to see if the retain count had dropped back to the expected value of 1.


NSSocketPort *sendPort = nil;
NSLog(@"No object on created: retain count = %d", [sendPort retainCount]);
sendPort = [[NSSocketPort alloc] initRemoteWithTCPPort: @"aServer" host:@"127.0.0.1"];
NSLog(@"init called once: retain count = %d", [sendPort retainCount]);

Incidentally, what you probably really wanted to know was:

NSSocketPort *sendPort = [NSSocketPort alloc];
NSLog(@"No object on created: retain count = %d", [sendPort retainCount]);
[sendPort initRemoteWithTCPPort: @"aServer" host:@"127.0.0.1"];
NSLog(@"init called once: retain count = %d", [sendPort retainCount]);


In your code the first call to retainCount was bound to return zero as all messages to the nil object return nil. The later code will show if the strangeness is in the allocation or the initialisation of the NSSocketPort (I'm sure you'll find it is in the initialisation).

	Cheers,
		Nicko

_______________________________________________
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: 
 >NSSocketPort question: retainCount (From: Fabio Ribeiro <email@hidden>)

  • Prev by Date: Re: From Panther to Tiger
  • Next by Date: Re: OpenGL and Tiger
  • Previous by thread: NSSocketPort question: retainCount
  • Next by thread: Re: NSSocketPort question: retainCount
  • Index(es):
    • Date
    • Thread