• 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: Casting Object to NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Casting Object to NSArray


  • Subject: Re: Casting Object to NSArray
  • From: Hsu <email@hidden>
  • Date: Sat, 28 Jun 2003 01:03:17 -0700

Art is correct. There are several classes that have serializers but no deserializers - NSArray is one of them. In goes an NSArray, out comes an Object[].

Karl

On Friday, June 27, 2003, at 08:18  PM, Art Isbell wrote:

On Friday, June 27, 2003, at 04:35  PM, Goodbye Bill wrote:

Thanks for all of the replies, however I left out one small detail that will
probably change all of your answers: this is via a web service.


The code on the SERVER (the WebService) looks like this...

    private NSArray myObjects;

    public NSArray GetObjects()
    {
        return myObjects;
    }

The code on the CLIENT (the consumer app) looks like this...

    public NSArray myReceivedObjects()
    {
        Object tmpArray = serviceClient().invoke(serviceName(),
                          "GetObjects", null);
        return (NSArray)tmpArray;
    }

Here's a little more info on this:

1. The "serviceClient" is a "WOWebServiceClient" object;
2. According to the API Reference, the "invoke" method on this object
returns an "Object" regardless of what method it invokes on the server.


The client example above will compile but generates a "ClassCastException"
exception at runtime.


Any ideas? I'm going on two full days working with this. The bottom line
is that I need to get an array of objects from a web service.

The documentation for invoke() states, "This method may return either an object, or a language array of objects." I read "language array of objects" to mean an Object[] (i.e., a primitive Java array) rather than an NSArray. Apparently you didn't do what I suggested: print tmpArray.getClass().getClassName() to see what class of object is returned.


Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.



--

If I want to hear the pitter patter of little feet, I'll put shoes on my cat.

Homepage:
     http://homepage.mac.com/khsu/index.html
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Casting Object to NSArray
      • From: Goodbye Bill <email@hidden>
References: 
 >Re: Casting Object to NSArray (From: Art Isbell <email@hidden>)

  • Prev by Date: Re: Casting Object to NSArray
  • Next by Date: Re: Casting Object to NSArray
  • Previous by thread: Re: Casting Object to NSArray
  • Next by thread: Re: Casting Object to NSArray
  • Index(es):
    • Date
    • Thread