Post not yet marked as solved
I am trying to get a picked image and put it into my core data record...
something like
.sheet(isPresented: $isShowPicker,content:
imagePickerSave(image: $image)
projectVM.projectImage = image!
but something like this seems better but doesnt compile
imagePickerSave(image: $projectVM.projectImage)
where projectVM is my coredata record
So how do I assign the imagepicker value in the view to a projectimage field in the coredata record?
I am using MVVM, what approach should i using please?
Mark
Post not yet marked as solved
I get this a runtime error
runtime error: Thread 1: "-[Attribute setImageD:]: unrecognized selector sent to instance 0x6000034aabc0"
when running my code. When assigning the field see * * *
Some background, this started in my project so I striped my code to the minimum but still get this error,
CORE DATA DEFINITION
______________________________
extension Attribute {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Attribute> {
return NSFetchRequest<Attribute>(entityName: "Attribute")
}
@NSManaged public var name: String
@NSManaged public var order: Int32
@NSManaged public var item: Item
@NSManaged public var imageD: Data?
}
_____________________________
IN THE CALLING CODE I GET THE IMAGE ND CONVERT TO DATA, PASSING IN TO THE SAVING ROUTINE
let image = UIImage(named: "BartSimpson");
let imagedata = image?.jpegData(compressionQuality: 1)
= Attribute.createPhotoAttributeFor(item: item,
imageData: imagedata!)
CoreData.stack.save()
_________________________
HERE THE SAVING METHOD GETS A RUNTUME ERROR WHEN TYPING TO SET THE IMAGED FIELD USINNG THE IMAGEDATE... SEE ***
class func createPhotoAttributeFor(item: Item, imageData: Data) -> Attribute {
let attribute = Attribute.newAttribute()
attribute.name = "image"
attribute.imageD = imageData // attribute value
* * runtime error: Thread 1: "-[Attribute setImageD:]: unrecognized selector sent to instance 0x6000034aabc0"
attribute.order = 3 // 3 = image
attribute.item = item // parent record
return attribute
}
WHAT AM I DOING WRONG?
THANKS
MARK
Post not yet marked as solved
Hi
What do I define in the OnDelete to set what to delete.
code:
Environment(\.managedObjectContext) var moc
@FetchRequest(entity: Faces.entity(), sortDescriptors: [
NSSortDescriptor(keyPath: \Faces.facename, ascending: true),
NSSortDescriptor(keyPath: \Faces.relationship, ascending: true),
NSSortDescriptor(keyPath: \Faces.birthday, ascending: true),
]
) var DBFaces: FetchedResults<Faces>
var body: some View {
NavigationView {
List {
ForEach(DBFaces, id: \.self) { face in
Text("\(face.facename ?? “-“)”)
.font(.title)
.foregroundColor(.secondary)
}
} // foreach
.ondelete ( ???? )
.padding()
}//List
} // NavView
} // View
Post not yet marked as solved
I saw a guy on youtube debugging camera functionality with a connected iphone. This I can do.
But he had a mirror of the iphone screen on his monitor screen. This looks really useful, so how do I do this...