[MacRuby] #917: NSKeyedArchiver fails to find a superclass's implementation of 'encodeWithCoder:'
MacRuby
ruby-noreply at macosforge.org
Fri Sep 24 08:36:19 PDT 2010
#917: NSKeyedArchiver fails to find a superclass's implementation of
'encodeWithCoder:'
---------------------------------+------------------------------------------
Reporter: mred@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: major | Milestone:
Component: MacRuby | Keywords:
---------------------------------+------------------------------------------
NSKeyedArchiver fails to find a superclass's implementation of
'encodeWithCoder:'
when its objects are encoded in a particular order. When the code
excerpted
below is run:
{{{
class ArchiverDelegate
def archiver archiver, willEncodeObject:object
puts "willEncode #{object.class}"
object
end
end
def test_archiver
graph = Graph.new
a = A.new
graph.addNode a
b = B.new
graph.addNode b
b.connect a
data = NSMutableData.alloc.init
archiver = NSKeyedArchiver.alloc.initForWritingWithMutableData data
delegate = ArchiverDelegate.alloc.init
archiver.setDelegate delegate
archiver.encodeObject graph, forKey:'root'
archiver.finishEncoding
end
10.times do |i|
puts i
test_archiver
end
}}}
I get results such as this:
{{{
$ macruby test-archiver.rb
0
willEncode Graph
willEncode NSCFSet
willEncode A
willEncode B
willEncode Connection
1
willEncode Graph
willEncode NSCFSet
willEncode B
willEncode Connection
willEncode A
/Users/ehynes/ClockSmith/current/Test/hgignore/test-archiver.rb:1:in
`<main>':
super: no superclass method `encodeWithCoder' for #<A:0x2000cc160>
(NoMethodError)
}}}
The NoMethodError occurs whenever B is encoded before A. Attached is the
complete code example.
--
Ticket URL: <http://www.macruby.org/trac/ticket/917>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list