• 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
autorelease and distributed objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

autorelease and distributed objects


  • Subject: autorelease and distributed objects
  • From: Francisco Tolmasky <email@hidden>
  • Date: Thu, 27 May 2004 15:31:25 -0700

I'm using distributed objects over a network and I would like to know whether something I'm doing is "safe". My root object, or proxy, has the methid:

- (oneway void)updateWithDictionary(bycopy in NSDictionary *)aDictionary;

So you would do something like:

[theObject updateWithDictionary: someDictionary];

Now, is this safe to do:

NSEnumerator *allDistantObjects= [ ... ];
id theDistantObject;
[theDictionary autorelease];
while(theDistantObject= [allDistantObjects nextObject])
{
[theDistantObject updateWithDictionary: theDictionary];
}

In other word, is it safe to autorelease the dictionary before I send it out, it should be right since its a copy anyways. Would it also be safe to instead of autorelease it, release it after all the messages are sent? I would assume so but I wanted to make sure.

The reason I ask this is because I have a local object that works a lot like a dictionary (in fact it has an internal dictionary). What I would like to do however, is keep track of what keys get changed and then notify the distant objects, as so:

[myObject beginEditing];
[myObject setObject: someObject forKey: @"hello"];
[myObject setObject: someObject2 forKey: @"bye"];
[myObject endEditing];

[distantObject updateWithDictionary: [myObject editedProperties]];

My idea is that internall, myObject would have a editedProperties dictionary, and would set someObject to @"hello", etc. Then, when you call endEditing, I plan on sending that dictionary the autorelease message:

- (void)beginEditing
{
editedProperties= [[NSMutableDictionary alloc] init];
}

- (void)endEditing
{
[editedProperties autorelease];
}

Is this "safe"? Or is there a chance of the editedProperties being deallocated before I send it out.

Thank you very much in advance,

Francisco Tolmasky
email@hidden
http://www-scf.usc.edu/~tolmasky/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Notification from ABPeoplePickerView
  • Next by Date: Re: How far with accessors?
  • Previous by thread: Re: cocoa-dev digest, Vol 2 #4257 - 12 msgs
  • Next by thread: Subclassing an object's creation method (NSBezierPath's +bezierPath)
  • Index(es):
    • Date
    • Thread