实体的模型定义:实体的class定义:@objc(ImageEntity)classImageEntity:NSManagedObject{@NSManagedvarimageData:NSData}存储:@IBAction func saveImageToCoreData() {letdelegate= UIApplication.sharedApplication().delegateasAppDelegateletcontext =delegate.managedObjectContextletimageData = UIImagePNGRepresentation(UIImage(named:"image"))letimageEntity = NSEntityDescription.entityForName("ImageEntity", inManagedObjectContext: context!)letimage = ImageEntity(entity: imageEntity!, insertIntoManagedObjectContext: context!)
image.imageData = imageDatavarerror: NSError?ifcontext!.save(&error;) ==false{
println("f
...
继续阅读
(67)