Closed proovek closed 6 years ago
And how I can get some values from dataCore which is selected?
Your data models must have one unique property. Here, In your Entity Licencja which property has uniqueValue? You need to set "String description of the property"
Every value in this entity is unique :P for example licenseNumber is unique
Can you help me with this? Im trying sooo many times :/
Then write selectionMenu.uniquePropertyName = "licenseNumber"
Maybe you can try something like this
let context = licenseSavingController.persistentContainer.viewContext
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "Licencja")
request.returnsObjectsAsFaults = false
guard let result = try? context.fetch(request) as? [Licencja] else {
return
}
let selectionMenu = RSSelectionMenu(selectionType: .Single, dataSource: result ?? [], cellType: .Basic) { (cell, object, indexPath) in
let licznik = object
cell.tintColor = .orange
cell.textLabel?.text = licznik.licenseDescript
}
I'll try later but thanks for some help :) Now im on outside
I try and it's doing the same :/ I have a problem with uniquePropertyName
Every marks are checked every time... it's weird
Can you please share your code?
All my code? For explain - Your library works good, but my problem is here - I need to set uniquePropertyName with my License entity for example for attribute with id = "licenseNumber" I need to recall to this id, but I couldn't get this id from dataCore
response from entity [<Licencja: 0x6000002843d0> (entity: Licencja; id: 0xd000000000040000 <x-coredata://197130E8-8765-4C43-A0E1-2628597E0693/Licencja/p1> ; data: { deviceID = "0C4BE11B-63F5-43C5-899F-DF80F319EFD4"; licenseDescript = "Serwer Api testowy"; licenseNumber = "DED-3139557474104099-API"; licenseURL = "https://someexampleAPI.com.pl/api/"; })]
what I should to use to get "id: 0xd000000..."??? I need this for a unique key and it should works
Your Entity must be subclass of NSObject.
that's how im sending someone to entity,
import Foundation
import CoreData
extension Licencja {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Licencja> {
return NSFetchRequest<Licencja>(entityName: "Licencja")
}
@NSManaged public var licenseURL: String?
@NSManaged public var deviceID: String?
@NSManaged public var licenseNumber: String?
@NSManaged public var licenseDescript: String?
}
What do you mean? Can you write some example or something?
My entity is a subclasss of NSManagedObject it's the same as nsobject
How can I delete those little "birds" on selected?
Only they works badly
You need to perform following steps:
func uniquePropertyName() -> String {
return "licenseNumber"
}
let result = <** Fetch call here **>
var selectedLicencja = []()
let selectionMenu = RSSelectionMenu(dataSource: result ?? []) { (cell, object, indexPath) in
cell.textLabel?.text = object. licenseDescript
}
selectionMenu.setSelectedItems(items: selectedLicencja) { (text, isSelected, selectedItems) in
// update your existing array with updated selected items, so when menu presents second time updated items will be default selected.
self.selectedLicencja = selectedItems
}
// show as popover
selectionMenu.show(style: .Popover(sourceView: sender as! UIView, size: nil), from: self)
I do all points, I implement unique...
@objc(Licencja)
public class Licencja: NSManagedObject{
func uniquePropertyName() -> String {
return "licenseNumber"
}
}
i have an selectedlicense declaration like that...
var wybranaLicencja = [Licencja]()
also I have fetch entity
guard let result = try? contextMark.fetch(requestMark) as? [Licencja] else {
return
}
let selectionMark = RSSelectionMenu(selectionType: .Single, dataSource: result ?? [], cellType: .Basic) { (cell, object, indexPath) in
let licznik = object
cell.tintColor = .orange
cell.textLabel?.text = licznik.licenseDescript ?? licznik.licenseURL
}
also I do selected item..
selectionMark.setSelectedItems(items: wybranaLicencja) { (text, isSelected, selectedItems) in
self.wybranaLicencja = selectedItems
And it's okay, it's works, but when im select some one cell everything is good - im printing this license and it's good, im using it as variable. nvm, my problem is here - when I choose a cell, the stamp appears with everyone like that: https://imgur.com/a/gaRnd8I
two marks... ;v
Can you tell me how to delete marks from your code?
It should work perfectly if you've configured all things properly. I'll get idea if you share your datamodels and other files where you're showing the menu.
I'll sent you my project on email, I don't want to share it public right now, okay?
/edit Look gmail, my god :)
Can you please try updating pod with version 4.0.2 and check if it works?
Yea I can try
Now it's work fine, thanks for helping me.
What is my problem? - It's works perfect but when I select one row, the App shows me "one row selected... etc" and it's okay, but when im looking into an App I have "checked" every rows.
there is my code:
like that: https://imgur.com/nveTKJ8 Im really confused with this :P