nskeyedarchiver

Compressing an NSKeyedArchiver file that included UIImageView with loaded image

血红的双手。 提交于 2019-12-24 11:37:11
问题 I have a view with an UIImageView. It was loaded with either jpg or png image format. Says the jpg image version has a data size of 100k. I then used NSKeyedArchiver to save my view to a file. The size of the file is getting about 3MB. If I used the png version of the image, the archived file is still around 3MB. I then used zlib to compress the archived file. But it does not seem to have much effect. Anything I can do to get it back to close as much as possible the 100k area? BTW: If I used

What happens with unarchived objects?

 ̄綄美尐妖づ 提交于 2019-12-24 08:22:03
问题 After I've unarchived an object with NSKeyedUnarchiver, I am able to use it like usual, but I am unable to re-archive it. When I try, it crashes. [NSKeyedArchiver archiveRootObject:unarchivedObject toFile:fileName]; I tried looking in the developer resources in apple but I haven't seen a thorough explination of proper usage of NSKeyedArchiver. Please Help. Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000023 Crashed Thread: 0 Dispatch queue:

Archiving UIImageView with NSCoding

半世苍凉 提交于 2019-12-24 06:38:47
问题 I've never used NSCoding before and I'm very confused about how it should be implemented. My current iPad app has a UIImageView (called "background") which is a property of my main view controller. "background" has a UIImage "image" property (obviously) and various subviews which are added by the user. The added subviews are my own custom subclasses of UIImageView. I need to be able to save the state of the "background" UIImageView so it can be restored with the same image and all the

How to Retrive and Store NSArray from sqlite DB in iOS

怎甘沉沦 提交于 2019-12-23 06:03:02
问题 I have an array itemQtyArray which i am storing in SQLITE table As: NSData *toData = [NSKeyedArchiver archivedDataWithRootObject:self.itemQtyArray]; NSString *insertSQL = [NSString stringWithFormat: @"INSERT INTO ORDERTABLE(ITEMDESC,ITEMQTY)VALUES( \"%@\",\"%@\");",dataString2,toData]; and then i am retrieving as : const void *itemQty = sqlite3_column_text(statement, 2); NSInteger qtyBytes = sqlite3_column_bytes(statement, 2); NSData *data2 = [NSData dataWithBytes:itemQty length:qtyBytes];

UserDefaults/KeyedArchiver Frustrations

佐手、 提交于 2019-12-22 09:30:00
问题 I'm working on a homework app that uses custom Assignment objects for each assignment. I am trying to store an NSMutableArray (casted to an NSArray via initWithArray:) in standardUserDefaults but I'm having trouble with saving and reloading the array. I have a table view from which you can choose to add a new assignment (which loads NewAssignmentViewController). When you save the assignment, it is pushed back to an array in AssigmentsViewController. And then you call it every time you load

Storing NSObject using NSKeyedArchiver/ NSKeyedUnarchiver

Deadly 提交于 2019-12-22 01:11:42
问题 I have a class object like; BookEntity.h import <Cocoa/Cocoa.h> @interface BookEntity : NSObject<NSCoding> { NSString *name; NSString *surname; NSString *email; } @property(copy) NSString *name,*surname,*email; @end BookEntity.m #import "BookEntity.h" @implementation BookEntity @synthesize name,surname,email; - (void) encodeWithCoder: (NSCoder *)coder { [coder encodeObject: self forKey:@"appEntity"]; } - (id) initWithCoder: (NSCoder *)coder { if (self = [super init]) { self = [coder

NSKeyedUnarchiver fails to decode a custom object in swift

只愿长相守 提交于 2019-12-21 12:42:40
问题 I'm trying a basic implementation of the NSCoding protocol in swift, but it seems I can't success to unarchive an object after it has been correctly archived. Here's my attempt import Cocoa class User: NSObject, NSCoding { var name: String init(name: String) { self.name = name } init(coder aDecoder: NSCoder!) { self.name = aDecoder.decodeObjectForKey("name") as String } func encodeWithCoder(aCoder: NSCoder!) { aCoder.encodeObject(name, forKey: "name") } } let user = User(name: "Gabriele") let

What format does NSKeyedArchiver save?

穿精又带淫゛_ 提交于 2019-12-21 10:16:23
问题 When I use NSKeyedArchiver is the data that is written a *.plist, I have seen some examples where people have the output file down as *.txt or even without an extension at all? -(void)saveCore { NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data]; [archiver encodeObject:reactorCore forKey:@"CORE"]; [archiver finishEncoding]; [data writeToFile:[self dataFilePath] atomically:YES]; [data release]; [archiver

How to write Dictionary to a file?

不打扰是莪最后的温柔 提交于 2019-12-21 03:15:41
问题 I have a FileHelper class where I've implemented 3 methods whose job is to write a Dictionary contents to a file. Those methods are: func storeDictionary(_ dictionary: Dictionary<String, String>, inFile fileName: String, atDirectory directory: String) -> Bool { let ext = "txt" let filePath = createFile(fileName, withExtension: ext, atDirectory: directory) /**** //If I use this method, file is created and dictionary is saved guard (dictionary as NSDictionary).write(to: filePath!, atomically:

streaming images over bonjour between two iOS device

三世轮回 提交于 2019-12-21 02:41:39
问题 My goal is to stream images captured by AVCpatureInput from one iOS device to another via bonjour. Here is my current method: 1) Capture frame from video input - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { /*code to convert sampleBuffer into UIImage */ NSData * imageData = UIImageJPEGRepresentation(image,1.0); [connection sendImage:image]; } 2) Send over TCP connection (from http: