• 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: Extending NSKeyValueCoding?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extending NSKeyValueCoding?


  • Subject: Re: Extending NSKeyValueCoding?
  • From: Max Muller <email@hidden>
  • Date: Mon, 27 Oct 2003 21:53:42 -0800

Hi,
	You can add a file named KeyValueCodingProtectedAccessor within a
package if you want to provide your own hooks for accessing attributes.
Included an example.

Regards,
	Max
package com.webobjects.eoaccess;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import com.webobjects.foundation.NSKeyValueCoding;

public class KeyValueCodingProtectedAccessor
    extends NSKeyValueCoding.ValueAccessor
{
    public Object fieldValue(Object object, Field field)
	throws IllegalArgumentException, IllegalAccessException {
	return field.get(object);
    }

    public void setFieldValue(Object object, Field field, Object object0)
	throws IllegalArgumentException, IllegalAccessException {
	field.set(object, object0);
    }

    public Object methodValue(Object object, Method method)
	throws IllegalArgumentException, IllegalAccessException,
	       InvocationTargetException {
	return method.invoke(object, null);
    }

    public void setMethodValue
	(Object object, Method method, Object object1)
	throws IllegalArgumentException, IllegalAccessException,
	       InvocationTargetException {
	method.invoke(object, new Object[] { object1 });
    }

    public String toString() {
	return "KeyValueCodingProtectedAccessor";
    }
}
On Oct 24, 2003, at 7:18 AM, petite_abeille wrote:

Hi Michael,

On Friday, Oct 24, 2003, at 16:09 Europe/Amsterdam, Michael Henderson
wrote:

> 1. Implement NSKeyValueCoding use the static default methods to get
> standard behavior and
> 	 add my extended behaviour
> 2. If extending a class that implements NSKeyValueCoding I implement:
> 	handleTakeValueForUnboundKey()
> 	handleQueryWithUnboundKey()
>
>     to get extended key value coding behavior.

Thanks for the pointers, but this is not what I'm after as I cannot
extend the class involved (scenario #2) and the default behavior
doesn't handle what I need (scenario #1).

Any ideas on how to smoothly extend the default NSKeyValueCoding
implementation in the first place? For example, if I want to use KVC in
conjunction with java.util.Collection or such, what do a need to do
short of writing my own KVC scheme or blast my way through
NSKeyValueCoding internals?

Cheers,

PA.
_______________________________________________
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.
_______________________________________________
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: Extending NSKeyValueCoding?
      • From: petite_abeille <email@hidden>
References: 
 >Re: Extending NSKeyValueCoding? (From: petite_abeille <email@hidden>)

  • Prev by Date: Re: Referencing css and javascript files
  • Next by Date: Re: Extending NSKeyValueCoding?
  • Previous by thread: Re: Extending NSKeyValueCoding?
  • Next by thread: Re: Extending NSKeyValueCoding?
  • Index(es):
    • Date
    • Thread