But when I perform the mapping, RestKit 0.10.3 is crashing on this line:
[self.destinationObject setValue:value forKeyPath:attributeMapping. destinationKeyPath]; in - (void)applyAttributeMapping:(RKObjectAttributeMapping*)attributeMapping withValue:( id)value
in RKObjectMappingOperation.m with the following error:
*2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key hideLocations.'* * * It seems quite odd to me that a mature framework like this doesn't handle this situation more gracefully, so I can't help but think I've configured something incorrectly. I would appreciate any insights you might have.* *
I would recommend trying this on the development branch. We have recently
merged type introspection support for non-object property types, which
should coerce the null into a false value. I will add a unit test for this
case to development to verify.
On Tue, Nov 13, 2012 at 11:38 AM, Levi Brown <levigro...@gmail.com> wrote:
> Hello all,
> I've got some JSON coming back from a service which at some times will
> have null instead of true/false for an attribute which is a boolean; Like
> this:
> in RKObjectMappingOperation.m with the following error:
> *2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due to
> uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass
> 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key
> hideLocations.'*
> *
> *
> It seems quite odd to me that a mature framework like this doesn't handle
> this situation more gracefully, so I can't help but think I've configured
> something incorrectly. I would appreciate any insights you might have.*
> *
Actually the Boolean type introspection interprets the backing type as a
NSNumber. I have a failing test for this case and will think on how to
handle...
On Tue, Nov 13, 2012 at 7:47 PM, Blake Watters <bl...@gateguruapp.com>wrote:
> I would recommend trying this on the development branch. We have recently
> merged type introspection support for non-object property types, which
> should coerce the null into a false value. I will add a unit test for this
> case to development to verify.
> On Tue, Nov 13, 2012 at 11:38 AM, Levi Brown <levigro...@gmail.com> wrote:
>> Hello all,
>> I've got some JSON coming back from a service which at some times will
>> have null instead of true/false for an attribute which is a boolean; Like
>> this:
>> "hide_locations" : null,
>> My object to receive this value has a property:
>> in RKObjectMappingOperation.m with the following error:
>> *2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due to
>> uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass
>> 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key
>> hideLocations.'*
>> *
>> *
>> It seems quite odd to me that a mature framework like this doesn't handle
>> this situation more gracefully, so I can't help but think I've configured
>> something incorrectly. I would appreciate any insights you might have.*
>> *
On Tuesday, November 13, 2012 6:43:46 PM UTC-7, Blake Watters wrote:
> Actually the Boolean type introspection interprets the backing type as a > NSNumber. I have a failing test for this case and will think on how to > handle...
> On Tue, Nov 13, 2012 at 7:47 PM, Blake Watters <bl...@gateguruapp.com<javascript:> > > wrote:
>> I would recommend trying this on the development branch. We have recently >> merged type introspection support for non-object property types, which >> should coerce the null into a false value. I will add a unit test for this >> case to development to verify.
>> On Tue, Nov 13, 2012 at 11:38 AM, Levi Brown <levig...@gmail.com<javascript:> >> > wrote:
>>> Hello all,
>>> I've got some JSON coming back from a service which at some times will >>> have null instead of true/false for an attribute which is a boolean; Like >>> this:
>>> "hide_locations" : null,
>>> My object to receive this value has a property:
>>> in RKObjectMappingOperation.m with the following error:
>>> *2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due to >>> uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass >>> 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key >>> hideLocations.'* >>> * >>> * >>> It seems quite odd to me that a mature framework like this doesn't >>> handle this situation more gracefully, so I can't help but think I've >>> configured something incorrectly. I would appreciate any insights you might >>> have.* >>> *
You should probably just implement `setNilValueForKey:` on your target
object and handle it appropriately. I don't know that RK can or should try
to predict how you would want to handle a nil value for scalar types in all
cases, so its probably better to keep the behavior uniform. Such a
mapping will always invoke setNilValueForKey: where you can handle it as
appropriate for that model.
On Wed, Nov 14, 2012 at 11:39 AM, Levi Brown <levigro...@gmail.com> wrote:
> Thanks Blake. I'll look forward to your solution.
> Cheers,
> Levi
> On Tuesday, November 13, 2012 6:43:46 PM UTC-7, Blake Watters wrote:
>> Actually the Boolean type introspection interprets the backing type as a
>> NSNumber. I have a failing test for this case and will think on how to
>> handle...
>> On Tue, Nov 13, 2012 at 7:47 PM, Blake Watters <bl...@gateguruapp.com>wrote:
>>> I would recommend trying this on the development branch. We have
>>> recently merged type introspection support for non-object property types,
>>> which should coerce the null into a false value. I will add a unit test for
>>> this case to development to verify.
>>> On Tue, Nov 13, 2012 at 11:38 AM, Levi Brown <levig...@gmail.com> wrote:
>>>> Hello all,
>>>> I've got some JSON coming back from a service which at some times will
>>>> have null instead of true/false for an attribute which is a boolean; Like
>>>> this:
>>>> "hide_locations" : null,
>>>> My object to receive this value has a property:
>>>> in RKObjectMappingOperation.m **with the following error:
>>>> *2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due to
>>>> uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass
>>>> 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key
>>>> hideLocations.'*
>>>> *
>>>> *
>>>> It seems quite odd to me that a mature framework like this doesn't
>>>> handle this situation more gracefully, so I can't help but think I've
>>>> configured something incorrectly. I would appreciate any insights you might
>>>> have.*
>>>> *
I respectfully disagree, however. To me it seems like RestKit should at least gracefully handle this kind of situation, and not crash. For scalars it seems pretty easy to have a set of default behaviors (that could be augmented?)... for all numbers, null is zero. For Strings, null is null. For booleans, null is false.
I think of this crash a bit like an SQL injection vulnerability. The framework should protect against, and sanitize, malformed (intentionally or not) input.
On Wednesday, November 14, 2012 1:47:17 PM UTC-7, Blake Watters wrote:
> You should probably just implement `setNilValueForKey:` on your target > object and handle it appropriately. I don't know that RK can or should try > to predict how you would want to handle a nil value for scalar types in all > cases, so its probably better to keep the behavior uniform. Such a > mapping will always invoke setNilValueForKey: where you can handle it as > appropriate for that model.
> On Wed, Nov 14, 2012 at 11:39 AM, Levi Brown <levig...@gmail.com<javascript:> > > wrote:
>> Thanks Blake. I'll look forward to your solution.
>> Cheers,
>> Levi
>> On Tuesday, November 13, 2012 6:43:46 PM UTC-7, Blake Watters wrote:
>>> Actually the Boolean type introspection interprets the backing type as a >>> NSNumber. I have a failing test for this case and will think on how to >>> handle...
>>> On Tue, Nov 13, 2012 at 7:47 PM, Blake Watters <bl...@gateguruapp.com>wrote:
>>>> I would recommend trying this on the development branch. We have >>>> recently merged type introspection support for non-object property types, >>>> which should coerce the null into a false value. I will add a unit test for >>>> this case to development to verify.
>>>> On Tue, Nov 13, 2012 at 11:38 AM, Levi Brown <levig...@gmail.com>wrote:
>>>>> Hello all,
>>>>> I've got some JSON coming back from a service which at some times will >>>>> have null instead of true/false for an attribute which is a boolean; Like >>>>> this:
>>>>> "hide_locations" : null,
>>>>> My object to receive this value has a property:
>>>>> in RKObjectMappingOperation.m **with the following error:
>>>>> *2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due to >>>>> uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass >>>>> 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key >>>>> hideLocations.'* >>>>> * >>>>> * >>>>> It seems quite odd to me that a mature framework like this doesn't >>>>> handle this situation more gracefully, so I can't help but think I've >>>>> configured something incorrectly. I would appreciate any insights you might >>>>> have.* >>>>> *
On Wed, Nov 14, 2012 at 4:44 PM, Levi Brown <levigro...@gmail.com> wrote:
> Blake,
> Thanks for the suggestion and reply.
> I respectfully disagree, however. To me it seems like RestKit should at
> least gracefully handle this kind of situation, and not crash. For scalars
> it seems pretty easy to have a set of default behaviors (that could be
> augmented?)... for all numbers, null is zero. For Strings, null is null.
> For booleans, null is false.
> I think of this crash a bit like an SQL injection vulnerability. The
> framework should protect against, and sanitize, malformed (intentionally or
> not) input.
> Levi
> On Wednesday, November 14, 2012 1:47:17 PM UTC-7, Blake Watters wrote:
>> You should probably just implement `setNilValueForKey:` on your target
>> object and handle it appropriately. I don't know that RK can or should try
>> to predict how you would want to handle a nil value for scalar types in all
>> cases, so its probably better to keep the behavior uniform. Such a
>> mapping will always invoke setNilValueForKey: where you can handle it as
>> appropriate for that model.
>> On Wed, Nov 14, 2012 at 11:39 AM, Levi Brown <levig...@gmail.com> wrote:
>>> Thanks Blake. I'll look forward to your solution.
>>> Cheers,
>>> Levi
>>> On Tuesday, November 13, 2012 6:43:46 PM UTC-7, Blake Watters wrote:
>>>> Actually the Boolean type introspection interprets the backing type as
>>>> a NSNumber. I have a failing test for this case and will think on how to
>>>> handle...
>>>> On Tue, Nov 13, 2012 at 7:47 PM, Blake Watters <bl...@gateguruapp.com>wrote:
>>>>> I would recommend trying this on the development branch. We have
>>>>> recently merged type introspection support for non-object property types,
>>>>> which should coerce the null into a false value. I will add a unit test for
>>>>> this case to development to verify.
>>>>> On Tue, Nov 13, 2012 at 11:38 AM, Levi Brown <levig...@gmail.com>wrote:
>>>>>> Hello all,
>>>>>> I've got some JSON coming back from a service which at some times
>>>>>> will have null instead of true/false for an attribute which is a boolean;
>>>>>> Like this:
>>>>>> "hide_locations" : null,
>>>>>> My object to receive this value has a property:
>>>>>> in RKObjectMappingOperation.m ****with the following error:
>>>>>> *2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due
>>>>>> to uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass
>>>>>> 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key
>>>>>> hideLocations.'*
>>>>>> *
>>>>>> *
>>>>>> It seems quite odd to me that a mature framework like this doesn't
>>>>>> handle this situation more gracefully, so I can't help but think I've
>>>>>> configured something incorrectly. I would appreciate any insights you might
>>>>>> have.*
>>>>>> *
On Sat, Dec 1, 2012 at 4:01 PM, Blake Watters <bl...@gateguruapp.com> wrote:
> Levi -
> I appreciate the feedback. I have the tests laying around from investing
> this in a work copy and I will reevaluate.
> Cheers,
> Blake
> On Wed, Nov 14, 2012 at 4:44 PM, Levi Brown <levigro...@gmail.com> wrote:
>> Blake,
>> Thanks for the suggestion and reply.
>> I respectfully disagree, however. To me it seems like RestKit should at
>> least gracefully handle this kind of situation, and not crash. For scalars
>> it seems pretty easy to have a set of default behaviors (that could be
>> augmented?)... for all numbers, null is zero. For Strings, null is null.
>> For booleans, null is false.
>> I think of this crash a bit like an SQL injection vulnerability. The
>> framework should protect against, and sanitize, malformed (intentionally or
>> not) input.
>> Levi
>> On Wednesday, November 14, 2012 1:47:17 PM UTC-7, Blake Watters wrote:
>>> You should probably just implement `setNilValueForKey:` on your target
>>> object and handle it appropriately. I don't know that RK can or should try
>>> to predict how you would want to handle a nil value for scalar types in all
>>> cases, so its probably better to keep the behavior uniform. Such a
>>> mapping will always invoke setNilValueForKey: where you can handle it as
>>> appropriate for that model.
>>> On Wed, Nov 14, 2012 at 11:39 AM, Levi Brown <levig...@gmail.com> wrote:
>>>> Thanks Blake. I'll look forward to your solution.
>>>> Cheers,
>>>> Levi
>>>> On Tuesday, November 13, 2012 6:43:46 PM UTC-7, Blake Watters wrote:
>>>>> Actually the Boolean type introspection interprets the backing type as
>>>>> a NSNumber. I have a failing test for this case and will think on how to
>>>>> handle...
>>>>> On Tue, Nov 13, 2012 at 7:47 PM, Blake Watters <bl...@gateguruapp.com>wrote:
>>>>>> I would recommend trying this on the development branch. We have
>>>>>> recently merged type introspection support for non-object property types,
>>>>>> which should coerce the null into a false value. I will add a unit test for
>>>>>> this case to development to verify.
>>>>>> On Tue, Nov 13, 2012 at 11:38 AM, Levi Brown <levig...@gmail.com>wrote:
>>>>>>> Hello all,
>>>>>>> I've got some JSON coming back from a service which at some times
>>>>>>> will have null instead of true/false for an attribute which is a boolean;
>>>>>>> Like this:
>>>>>>> "hide_locations" : null,
>>>>>>> My object to receive this value has a property:
>>>>>>> in RKObjectMappingOperation.m ****with the following error:
>>>>>>> *2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due
>>>>>>> to uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass
>>>>>>> 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key
>>>>>>> hideLocations.'*
>>>>>>> *
>>>>>>> *
>>>>>>> It seems quite odd to me that a mature framework like this doesn't
>>>>>>> handle this situation more gracefully, so I can't help but think I've
>>>>>>> configured something incorrectly. I would appreciate any insights you might
>>>>>>> have.*
>>>>>>> *
> On Sat, Dec 1, 2012 at 4:01 PM, Blake Watters <bl...@gateguruapp.com<javascript:> > > wrote:
>> Levi -
>> I appreciate the feedback. I have the tests laying around from investing >> this in a work copy and I will reevaluate.
>> Cheers, >> Blake
>> On Wed, Nov 14, 2012 at 4:44 PM, Levi Brown <levig...@gmail.com<javascript:> >> > wrote:
>>> Blake,
>>> Thanks for the suggestion and reply.
>>> I respectfully disagree, however. To me it seems like RestKit should at >>> least gracefully handle this kind of situation, and not crash. For scalars >>> it seems pretty easy to have a set of default behaviors (that could be >>> augmented?)... for all numbers, null is zero. For Strings, null is null. >>> For booleans, null is false.
>>> I think of this crash a bit like an SQL injection vulnerability. The >>> framework should protect against, and sanitize, malformed (intentionally or >>> not) input.
>>> Levi
>>> On Wednesday, November 14, 2012 1:47:17 PM UTC-7, Blake Watters wrote:
>>>> You should probably just implement `setNilValueForKey:` on your target >>>> object and handle it appropriately. I don't know that RK can or should try >>>> to predict how you would want to handle a nil value for scalar types in all >>>> cases, so its probably better to keep the behavior uniform. Such a >>>> mapping will always invoke setNilValueForKey: where you can handle it as >>>> appropriate for that model.
>>>> On Wed, Nov 14, 2012 at 11:39 AM, Levi Brown <levig...@gmail.com>wrote:
>>>>> Thanks Blake. I'll look forward to your solution.
>>>>> Cheers,
>>>>> Levi
>>>>> On Tuesday, November 13, 2012 6:43:46 PM UTC-7, Blake Watters wrote:
>>>>>> Actually the Boolean type introspection interprets the backing type >>>>>> as a NSNumber. I have a failing test for this case and will think on how to >>>>>> handle...
>>>>>> On Tue, Nov 13, 2012 at 7:47 PM, Blake Watters <bl...@gateguruapp.com >>>>>> > wrote:
>>>>>>> I would recommend trying this on the development branch. We have >>>>>>> recently merged type introspection support for non-object property types, >>>>>>> which should coerce the null into a false value. I will add a unit test for >>>>>>> this case to development to verify.
>>>>>>> On Tue, Nov 13, 2012 at 11:38 AM, Levi Brown <levig...@gmail.com>wrote:
>>>>>>>> Hello all,
>>>>>>>> I've got some JSON coming back from a service which at some times >>>>>>>> will have null instead of true/false for an attribute which is a boolean; >>>>>>>> Like this:
>>>>>>>> "hide_locations" : null,
>>>>>>>> My object to receive this value has a property:
>>>>>>>> in RKObjectMappingOperation.m ****with the following error:
>>>>>>>> *2012-11-13 09:33:04.352 Tests[73816:5f03] *** Terminating app due >>>>>>>> to uncaught exception 'NSInvalidArgumentException', reason: '[<MyClass >>>>>>>> 0x13ba9a10> setNilValueForKey]: could not set nil as the value for the key >>>>>>>> hideLocations.'* >>>>>>>> * >>>>>>>> * >>>>>>>> It seems quite odd to me that a mature framework like this doesn't >>>>>>>> handle this situation more gracefully, so I can't help but think I've >>>>>>>> configured something incorrectly. I would appreciate any insights you might >>>>>>>> have.* >>>>>>>> *