Develop 2 simple apps or one app with 2 targets for a simple usecase. Lets name them APP_TARGET1 & APP_TARGET2.
APP_TARGET1 saves an object stream using NSKeyedArchiver.
let data = NSMutableData()
var keyedarchiver:NSKeyedArchiver=NSKeyedArchiver(forWritingWithMutableData: data);
[login to view URL](<myobject>, forKey: "rootobject"); // <myobject> can be simply a String like "content"
[login to view URL]();
let bytes = [login to view URL];
let len=[login to view URL];
[login to view URL](<yourpath>,...);
APP_TARGET2. reads the object stream using NSKeyedUnarchiver.
let data: NSData? = NSData(contentsOfFile: <yourpath>)
var mykeyedunarchiver:NSKeyedUnarchiver=NSKeyedUnarchiver(forReadingWithData: data!);
[login to view URL] = self;
let temp:AnyObject?=[login to view URL]("rootobject")
if temp==nil {
blobsexists=false;
}else{
let object = temp! as! <myobject_class>'; // Can be a String
print(object); // Can be print(String);
}
The Problem I was facing with it is, that when reading the object stream in APP_TARGET2, I got an error as follow:
"cannot decode object of class ([login to view URL])"
I guess the problem can be solved by using the following delegate method of the protocol NSKeyedUnarchiverDelegate:
func unarchiver(unarchiver: NSKeyedUnarchiver, cannotDecodeObjectOfClassName name: String, originalClasses classNames: [String]) -> AnyClass? {
print("I am in unarchiver, because the classname is wrong : " + name);
return ?????;
}
But I did not succeed, thats why I need a working sample for this usecase.
interested for this challenge ?
Testplan:
1. Step is trying to reproduce the error when reading back the stream. This is a must, otherwise I am not sure, if step 2 solves the issue.
2. Step solving the issue. Reading the Object
hello
i like bids on your project = )
i understand your problem and there're a couple of ways to do it.
in fact i don't really like swift, but can help you anyway
6 years of experience in iOS applications development
clear and compact code
best regards
Dmitriy