CPTableView and KVO

37 views
Skip to first unread message

timeimp

unread,
Feb 1, 2016, 1:54:04 AM2/1/16
to Cappuccino & Objective-J
Hi everyone,

I have a basic ArrayController that is to manage some JSON objects returned from the server.

The JSON returned has objects made up of a structure like so:

{type:"A Type",time:"2016-01-01 00:00:00T+1100"}


Currently, as per the Cup tutorial, I have hooked everything up, however I am running into this error when rendering the CPTableCellView items:

Exception TypeError: undefined is not an object (evaluating 'value.isa.objj_msgSend1') in [<$KVO_TView 0x00face> valueForKeyPath:]


This happens with both a subclassed and non-subclassed CPTableCellView setup; the binded value in Interface Builder is:

objectValue.time

If I simply have objectValue as the value for the CPTextField to use, I get [object Object] printed in the view. Attempting to access the property I want to use, triggers the above object.

The below stack trace appears on every attempt a cell attempts to load some data:

[Warning] 2016-02-01 17:45:17.637 Cappuccino [warn]: Exception TypeError: undefined is not an object (evaluating 'value.isa.objj_msgSend1') in [<$KVO_TView 0x00face> valueForKeyPath:] 
[Warning] 2016-02-01 17:45:17.637 Cappuccino [warn]: [<CPURLConnection 0x00fa17> _readyStateDidChange] 
[Warning] 2016-02-01 17:45:17.638 Cappuccino [warn]: [<MassTimesController 0x00ea92> connection:didReceiveData:] 
[Warning] 2016-02-01 17:45:17.638 Cappuccino [warn]: [<$KVO_CPArrayController 0x00bc17> addObjects:] 
[Warning] 2016-02-01 17:45:17.639 Cappuccino [warn]: [<$KVO_CPArrayController 0x00bc17> setContent:] 
[Warning] 2016-02-01 17:45:17.639 Cappuccino [warn]: [<$KVO_CPArrayController 0x00bc17> didChangeValueForKey:] 
[Warning] 2016-02-01 17:45:17.639 Cappuccino [warn]: [<_CPKVOProxy 0x00ee55> _sendNotificationsForKey:changeOptions:isBefore:] 
[Warning] 2016-02-01 17:45:17.640 Cappuccino [warn]: [<_CPKVOProxy 0x00ee55> _sendNotificationsForKey:changeOptions:isBefore:] 
[Warning] 2016-02-01 17:45:17.641 Cappuccino [warn]: [<_CPKVOProxy 0x00ee55> _sendNotificationsForKey:changeOptions:isBefore:] 
[Warning] 2016-02-01 17:45:17.641 Cappuccino [warn]: [<CPBinder 0x00f3bb> observeValueForKeyPath:ofObject:change:context:] 
[Warning] 2016-02-01 17:45:17.641 Cappuccino [warn]: [<CPBinder 0x00f3bb> setValueFor:] 
[Warning] 2016-02-01 17:45:17.642 Cappuccino [warn]: [<CPBinder 0x00f3bb> setValue:forBinding:] 
[Warning] 2016-02-01 17:45:17.642 Cappuccino [warn]: [<CPTableView 0x00ba32> setValue:forKey:] 
[Warning] 2016-02-01 17:45:17.643 Cappuccino [warn]: [<CPTableView 0x00ba32> _setSelectedRowIndexes:] 
[Warning] 2016-02-01 17:45:17.643 Cappuccino [warn]: [<CPTableView 0x00ba32> _updateHighlightWithOldRows:newRows:] 
[Warning] 2016-02-01 17:45:17.643 Cappuccino [warn]: [<CPTableView 0x00ba32> _enumerateViewsInRows:columns:usingBlock:] 
[Warning] 2016-02-01 17:45:17.644 Cappuccino [warn]: [<CPRunLoop 0x000850> limitDateForMode:] 
[Warning] 2016-02-01 17:45:17.644 Cappuccino [warn]: [<_CPRunLoopPerform 0x00f361> fireInMode:] 
[Warning] 2016-02-01 17:45:17.645 Cappuccino [warn]: [<_CPDisplayServer 0x0008a2> performSelector:withObject:] 
[Warning] 2016-02-01 17:45:17.645 Cappuccino [warn]: [<_CPDisplayServer 0x0008a2> run] 
[Warning] 2016-02-01 17:45:17.645 Cappuccino [warn]: [<CPTableView 0x00ba32> layoutIfNeeded] 
[Warning] 2016-02-01 17:45:17.646 Cappuccino [warn]: [<CPTableView 0x00ba32> layoutSubviews] 
[Warning] 2016-02-01 17:45:17.646 Cappuccino [warn]: [<CPTableView 0x00ba32> load] 
[Warning] 2016-02-01 17:45:17.647 Cappuccino [warn]: [<CPTableView 0x00ba32> _loadDataViewsInRows:columns:] 
[Warning] 2016-02-01 17:45:17.647 Cappuccino [warn]: [<CPIndexSet 0x00fa30> enumerateIndexesUsingBlock:] 
[Warning] 2016-02-01 17:45:17.647 Cappuccino [warn]: [<CPIndexSet 0x00fa30> enumerateIndexesWithOptions:usingBlock:] 
[Warning] 2016-02-01 17:45:17.648 Cappuccino [warn]: [<CPIndexSet 0x00fa30> enumerateIndexesInRange:options:usingBlock:] 
[Warning] 2016-02-01 17:45:17.648 Cappuccino [warn]: [<CPIndexSet 0x00fa31> enumerateIndexesUsingBlock:] 
[Warning] 2016-02-01 17:45:17.649 Cappuccino [warn]: [<CPIndexSet 0x00fa31> enumerateIndexesWithOptions:usingBlock:] 
[Warning] 2016-02-01 17:45:17.649 Cappuccino [warn]: [<CPIndexSet 0x00fa31> enumerateIndexesInRange:options:usingBlock:] 
[Warning] 2016-02-01 17:45:17.649 Cappuccino [warn]: [<CPTableView 0x00ba32> _preparedViewAtColumn:row:isRowSelected:] 
[Warning] 2016-02-01 17:45:17.650 Cappuccino [warn]: [<CPTableView 0x00ba32> _setObjectValueForTableColumn:row:forView:] 
[Warning] 2016-02-01 17:45:17.650 Cappuccino [warn]: [<CPTableView 0x00ba32> _setObjectValueForTableColumn:row:forView:useCache:] 
[Warning] 2016-02-01 17:45:17.651 Cappuccino [warn]: [<CPTableColumn 0x00ba93> _prepareDataView:forRow:] 
[Warning] 2016-02-01 17:45:17.652 Cappuccino [warn]: [<$KVO_TView 0x00face> setValue:forKey:] 
[Warning] 2016-02-01 17:45:17.652 Cappuccino [warn]: [<$KVO_TView 0x00face> setObjectValue:] 
[Warning] 2016-02-01 17:45:17.653 Cappuccino [warn]: [<$KVO_TView 0x00face> didChangeValueForKey:] 
[Warning] 2016-02-01 17:45:17.653 Cappuccino [warn]: [<_CPKVOProxy 0x00fb0b> _sendNotificationsForKey:changeOptions:isBefore:] 
[Warning] 2016-02-01 17:45:17.654 Cappuccino [warn]: [<_CPKVOForwardingObserver 0x00fb0c> observeValueForKeyPath:ofObject:change:context:] 
[Warning] 2016-02-01 17:45:17.654 Cappuccino [warn]: [<_CPTextFieldValueBinder 0x00fb09> observeValueForKeyPath:ofObject:change:context:] 
[Warning] 2016-02-01 17:45:17.654 Cappuccino [warn]: [<_CPTextFieldValueBinder 0x00fb09> setValueFor:] 
[Warning] 2016-02-01 17:45:17.655 Cappuccino [warn]: [<$KVO_TView 0x00face> valueForKeyPath:] (Objective-J.js, line 739, x2)
[Warning] 2016-02-01 17:45:17.656 Cappuccino [warn]: Exception TypeError: undefined is not an object (evaluating 'value.isa.objj_msgSend1') in [<$KVO_TView 0x00face> valueForKeyPath:] 
[Warning] 2016-02-01 17:45:17.657 Cappuccino [warn]: Exception TypeError: undefined is not an object (evaluating '___r1.isa.objj_msgSend') in [<_CPKVOForwardingObserver 0x00fb0c> observeValueForKeyPath:ofObject:change:context:] 


If I log the TableView, I can see _objectValue property has the values I am attempting access.

If anyone could please point me in the right direction, I would really appreciate it.

Cheers,
timeimp

Martin Carlberg

unread,
Feb 1, 2016, 3:56:33 AM2/1/16
to objec...@googlegroups.com
Hi!

I don’t know if this is the problem but you say you use JSON objects. They are not Key Value Coding compliant and if you try to send [{type:"A Type",time:"2016-01-01 00:00:00T+1100”} valueForKey:@”time”] then you will get exactly the same exception as you got below.

If this is the problem then you could convert your JSON objects to CPDictionary with [CPDictionary dictionaryWithJSObject:jsObject];


Happy coding,

- Martin


--
You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
To post to this group, send email to objec...@googlegroups.com.
Visit this group at https://groups.google.com/group/objectivej.
For more options, visit https://groups.google.com/d/optout.

timeimp

unread,
Feb 1, 2016, 7:12:33 PM2/1/16
to Cappuccino & Objective-J
Thank you Martin for getting back to me!

I ended up looping over the results, created a dictionary from each object, and adding said dictionary to a CPArrayController.

I don't think this is 100% efficient, but it works!

-timeimp
Reply all
Reply to author
Forward
0 new messages