• 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: strange enum error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange enum error


  • Subject: Re: strange enum error
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 22 Feb 2005 13:49:31 -0800

Check the docs for objectEnumerator:
" When this method is used with mutable subclasses of NSArray, your code shouldn't modify the array during enumeration."


You are doing what you should not be. Make a copy of the relationship and enumerate that.

Chuck

On Feb 22, 2005, at 1:36 PM, Stephen Todd wrote:

We have a method that removes all objects from a many-to-many relationship then adds in new values. It uses the code that follows the message. When we try and empty the array it only ends up removing half the items. When investigating what happens, I discovered that the enumeration returns values for the first half in the list containing the even items, and then null values for the second half.

I get the following output from the System.outs below when newAdminAreas is empty (code below the output:

//1
newAdminAreas:0

//2
user.ACLs: [an array showing all the items previously set. None are null]


//3
if there are four items, I get two acls and then null twice. It appears like these are the 2nd and 4th. With more items, it just removes the even ones.


//4
This is half the original user.ACLs().count()


public void setAdminAreas(NSArray newAdminAreas) { System.out.println("newAdminAreas:"+newAdminAreas.count()); //1 //remove all rights System.out.println("user.ACLs:"+user.ACLs()); //2 Enumeration aclEnum = user.ACLs().objectEnumerator(); while(aclEnum.hasMoreElements()) { ACL acl = (ACL)aclEnum.nextElement(); System.out.println("remove:"+acl); //3 user.removeObjectFromBothSidesOfRelationshipWithKey(acl, "ACLs"); } System.out.println("user.ACLs(): "+user.ACLs().count()); //4

....<snip>


-Stephen

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
village.net


This email sent to email@hidden

--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >strange enum error (From: Stephen Todd <email@hidden>)

  • Prev by Date: Re: strange enum error
  • Next by Date: Re: why ec.refreshAllObjects() required?
  • Previous by thread: Re: strange enum error
  • Next by thread: You don't have permission to access /cgi-bin/WebObjects/<any app> on this server
  • Index(es):
    • Date
    • Thread