• 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
Problems with NSArray and iterators
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems with NSArray and iterators


  • Subject: Problems with NSArray and iterators
  • From: Jarvis Cochrane <email@hidden>
  • Date: Sat, 20 Aug 2005 10:45:27 +0800

Hello!

This has been driving me nuts for a while, and I was wondering if anyone else had seen the same behaviour.

I'm finding that the java.util.Iterator and java.util.Enumerator returned from NSArray.iterator() and NSArray.objectEnumerator() contain "Null" values.

This code will fail:

   java.util.Iterator iterator = assignedClients().iterator();

while (iterator.hasNext()) {
Client child = (Client)iterator.next();
child.someMethod(); /* child is sometimes null and throws an exception */
}


But this works:

java.util.Iterator iterator = assignedClients().iterator();

        while (iterator.hasNext()) {
            Client child = (Client)iterator.next();
            if (child!=null)
                child.someMethod();
        }

And turning the NSArray into a Vector, and using Vector.iterator() also works - thus:

java.util.Iterator iterator = assignedClients().vector().iterator();
        while (iterator.hasNext()) {
            Client child = (Client)iterator.next();

            child.someMethod();
        }

AssignedClients(), btw is an EOGenerator generated getter for a one- to-many relationship in my EOModel:

    public NSArray assignedClients() {
        return (NSArray)storedValueForKey("assignedClients");
    }

Soooo.... assignedClients().iterator() contains some null values, but assignedClients().vector().iterator() doesn't?

I must be missing something!

Thanks in advance,

Jarvis


_______________________________________________ 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
  • Follow-Ups:
    • Re: Problems with NSArray and iterators
      • From: David Teran <email@hidden>
    • Re: Problems with NSArray and iterators
      • From: Florijan Stamenkovic <email@hidden>
  • Prev by Date: problem with pop-up display
  • Next by Date: New operators on NSArray
  • Previous by thread: Re: Webobjects-dev Digest, Vol 2, Issue 479
  • Next by thread: Re: Problems with NSArray and iterators
  • Index(es):
    • Date
    • Thread