nskeyedarchiver

How to implement the unarchiver delegate for overwriting the classname?

一笑奈何 提交于 2019-12-12 03:07:22
问题 I have 2 Targets of my IOS-App : MYAPPTARGET_1 & MYAPPTARGET_2 MYAPPTARGET_1 is writing a Stream to a BLOB using NSKeyedArchiver MYAPPTARGET_2 is reading a Stream from a BLOB using NSKeyedUnarchiver When unarchiving the Stream from the BLOB in my MYAPPTARGET_2, I get the Error: 016-01-18 15:01:38.541 WorldHistoryAtlasTest[598:9405] * Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: '* -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of

NsUserDefualts not functioning right

穿精又带淫゛_ 提交于 2019-12-12 00:37:31
问题 Basically I have some sort of bug with tableView, i noticed that my tableView is not always getting updated correctly, and i tried debugging it and what i noticed is that tableView class is not always getting called to update the table. What am i doing wrong ? When i add new entry to my table, count 4 + 1, I go to history tab, and nothing happens and it shows as the count is still 4 but if I switch tabs 1 more time it will show count as 5 and tableView will be updated.. so there is a delay in

NSKeyedArchiver returning nil for UIView's subviews

冷暖自知 提交于 2019-12-11 13:48:58
问题 I have one ViewController, in this i have added one Custom UIView named as DrawingView. I want to add dynamic number of UITextView in this DrawingView so i subclassed UITextView with class name as CustomTextView. In ViewController i have following code to add textview to DrawingView. - (void)viewDidLoad { [super viewDidLoad]; DrawingView * newDrawingView = [[DrawingView alloc]init]; self.drawingView = newDrawingView ; } -(void)setDrawingView:(DrawingView *)_drawingView { if (drawingView !=

NSKeyedArchiver and sharing a custom class between targets

可紊 提交于 2019-12-11 08:55:19
问题 My app uses a custom class as its data model: class Drug: NSObject, NSCoding { // Properties, methods etc... } I have just created a Today extension and need to access the user’s data from it, so I use NSCoding to persist my data in both the app container and the shared container. These are the save and load functions in the main app: func saveDrugs() { // Save to app container let isSuccessfulSave = NSKeyedArchiver.archiveRootObject(drugs, toFile: Drug.ArchiveURL.path) if isSuccessfulSave {

How to append data to NSKeyedArchive?

风流意气都作罢 提交于 2019-12-11 08:39:15
问题 I'm reading a file like so: NSData *data = [NSData dataWithContentsOfFile:myPath]; NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; NSData *imgData = [unarchiver decodeObjectForKey:@"myimage"]; if (imgData != nil) { self.image = [[NSImage alloc]initWithData:imgData]; }else{ self.image = nil; } [unarchiver finishDecoding]; [unarchiver release]; What I'd like to do is to append image data for key @"myimage" to the same file if it doesn't exist. How to go

Swift: Error in NSKeyedArchiver

穿精又带淫゛_ 提交于 2019-12-11 05:48:01
问题 Swift 3 iOS 10, Trying to save array with custom objects in NSKeyedArchiver, basically trying to save the table view after the user uses the buttons to switch between sections. I've tried several post to solve the issue but no luck, now I'm trying to do it myself NSCoding and NSKeyedArchiver. Error: Cannot convert value of type '[Blog]' to expected argument type 'NSCoder' Error is in code in Blog.swift, Code that handles NSCoding and my Blog Objects import UIKit class BlogsCoding: NSObject,

NSKeyedUnarchiver crashes swift 3 on the second run

 ̄綄美尐妖づ 提交于 2019-12-11 04:14:01
问题 I am trying to save custom object to UserDefaults and I'm using this as a source code. It crashes immediately on the get part. This is my code: class Settings { static let defaults:UserDefaults = UserDefaults.standard ///VIP object: class VIP: NSObject, NSCoding { let email: String let name: String let relation: String init(email: String, name: String, relation: String) { self.email = email self.name = name self.relation = relation } required init(coder decoder: NSCoder) { self.email =

encodeWithCoder is not called in derived class of the NSMutableDictionary

杀马特。学长 韩版系。学妹 提交于 2019-12-11 00:50:00
问题 Basically I am using some open source code called OrderedDictionary that is derived from NSMutableDictionary. Then I want to save the ordered dictionary data to NSUserDefaults by adding encode and decode method to the OrderedDictionary class. However, I realized the encode and decode methods are not being called, as a result, the decoded dictionary is no longer ordered. Below is my code: @interface OrderedDictionary : NSMutableDictionary <NSCopying, NSCoding> { NSMutableDictionary *dictionary

MKPolyline -> NSKeyedArchiver -> NSData SIGABRT

梦想的初衷 提交于 2019-12-10 15:19:29
问题 In my app I am trying to store an array of MKPolylines into NSUserDefaults . NSData *data = [NSKeyedArchiver archivedDataWithRootObject:overlays]; [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"theKey"]; Gives: [MKPolyline encodeWithCoder:]: unrecognized selector sent to instance 0x169c20` Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [MKPolyline encodeWithCoder:]: unrecognized selector sent to instance 0x1c57e0' Edit: I made some progress.

NSCoding : How to create required init in inherited classes

余生长醉 提交于 2019-12-08 08:26:34
问题 I have the same question as vince (NSCoding required initializer in inherited classes in Swift) I've a class 'Source' and a subclass 'RSSSource'. Theses classes conforms to NSObject and NSCoding which I want to be able to persist with NSKeyedArchiver . I don't know how to create the required convenience init?(coder aDecoder: NSCoder) in the subclass. I would like to call the convenience init of the superclass. PS: I know that I should post a comment on his thread but I can't. (reputation too