Thanks John!

I let eclipse add the annotation to suppress the warning and I changed the setRecords() to take an NSArray<Record>. So now the accessors look as shown below:

 1:    public void setRecords(NSArray<Record> value) {
 2:       takeStoredValueForKey(value, "records");
 3:    }
 4:
 5:    @SuppressWarnings("unchecked")
 6:
 7:    public NSArray<Record> records() {
 8:        return ((NSArray<Record>)storedValueForKey("records"));
 9:    }
10:
11:    public void addToRecords(Record value) {
12:        includeObjectIntoPropertyWithKey(value, "records");
13:    }
14:
15:    public void removeFromRecords(Record value) {
16:        excludeObjectFromPropertyWithKey(value, "records");
17:    }

Now, when I create my EO programmatically and insert into the editing context and then initialize some of its properties I had this code:

        myEO.setRecords(NSArray.EmptyArray);

It looks like now I have to change that line to the following:

        myEO.setRecords(new NSArray<Record>());

Or is there a better way to create an empty NSArray<Record> without really creating new instances every single time?

Thanks




On Nov 1, 2007, at 1:32 PM, John Huss wrote:

The getter looks good. Yes, it will generate a warning. You can set the SuppressAllWarnings annotation to hide them - I can't remember the exact syntax.

The setter should take an NSArray, which will also allow an NSMutableArray to be passed since it is a subclass.

John

On 11/1/07, Ricardo Parada <[EMAIL PROTECTED]> wrote:
Hi All,

Just wondering how people are writing their accessor methods inside their EOs now that NSArray and NSMutableArray have been parameterized (did I say that right? :-) ). For example consider the following accessors for a to-many relationship called "records". Is this the right way to do it because line #7 is still generating a warning in eclipse. And what is the correct type for the setRecords() method? Should it take an NSMutableArray<Record> or an NSArray<Record> argument?


 1:    public void setRecords(NSMutableArray<Record> value) {
 2:       takeStoredValueForKey(value, "records");
 3:    }
 4:
 5:
 6:    public NSArray<Record> records() {
 7:        return ((NSArray<Record>)storedValueForKey("records"));
 8:    }
 9:
10:
11:    public void addToRecords(Record value) {
12:        includeObjectIntoPropertyWithKey(value, "records");
13:    }
14:
15:
16:    public void removeFromRecords(Record value) {
17:        excludeObjectFromPropertyWithKey(value, "records");
18:    }


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/johnthuss%40gmail.com

This email sent to [EMAIL PROTECTED]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to