mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-23 12:27:56 +08:00
26 lines
526 B
Ruby
26 lines
526 B
Ruby
class TestArchiver
|
|
attr_accessor :name
|
|
|
|
def encodeWithCoder(encoder)
|
|
encoder.encodeObject(self.name, forKey: "name")
|
|
end
|
|
|
|
def initWithCoder(decoder)
|
|
if self.init
|
|
self.name = decoder.decodeObjectForKey("name")
|
|
end
|
|
self
|
|
end
|
|
end
|
|
|
|
describe "NSKeyedArchiver" do
|
|
it "works" do
|
|
m = TestArchiver.new
|
|
m.name = "test"
|
|
|
|
m2 = NSKeyedUnarchiver.unarchiveObjectWithData(NSKeyedArchiver.archivedDataWithRootObject(m))
|
|
m2.class.should == TestArchiver
|
|
m2.name.should == m.name
|
|
end
|
|
end
|