Post

Replies

Boosts

Views

Activity

Duplicate entries in Core Data
I have a problem, my objects every time I save them are reflected in uitableview in a duplicate way, does anyone know how to solve it or if I have a problem in my code? &#9; import CoreData &#9; import Foundation &#9;class ViewController: UIViewController { //MARK:= Outles @IBOutlet var tableView: UITableView! //MARK:= variables var context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext var items: [Entity]? var duplicateName:String = "" //MARK:= Overrides override func viewDidLoad() { &#9;&#9;super.viewDidLoad() &#9;&#9;tableView.delegate = self &#9;&#9;tableView.dataSource = self &#9;&#9; &#9;&#9; &#9;&#9;fetchPeople() &#9;&#9;addPeople(context) &#9;&#9;print(" nombres: \(items?.count)") &#9;&#9; } override func viewWillAppear(_ animated: Bool) { } //MARK:= Core Data funcs func fetchPeople(){ &#9;&#9;do{ &#9;&#9;&#9;&#9;self.items = try! context.fetch(Entity.fetchRequest()) &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;DispatchQueue.main.async { &#9;&#9;&#9;&#9;&#9;&#9;self.tableView.reloadData() &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9; &#9;&#9;}catch let error as NSError{ &#9;&#9;&#9;&#9;print("Tenemos este error \(error.debugDescription)") &#9;&#9;} &#9;&#9; } func addPeople(_ contexto: NSManagedObjectContext) { &#9;&#9; &#9;&#9;let usuario = Entity(context: contexto); &#9;&#9;usuario.nombre = "Valeria"; &#9;&#9;usuario.edad = 25; &#9;&#9;usuario.eresHombre = false; &#9;&#9;usuario.origen = "Ensenada,B.C" &#9;&#9;usuario.dia = Date(); &#9;&#9;do{ &#9;&#9;&#9;&#9;try! contexto.save(); &#9;&#9;&#9;&#9; &#9;&#9;}catch let error as NSError{ &#9;&#9;&#9;&#9;print("tenemos este error en el guardado \(error.debugDescription)"); &#9;&#9;} &#9;&#9;fetchPeople() &#9;&#9; &#9;&#9; } func deletDuplicates(_ contexto: NSManagedObjectContext){ &#9;&#9; &#9;&#9;let fetchDuplicates = NSFetchRequest<NSFetchRequestResult>(entityName: "Persona") &#9; // &#9;&#9;&#9; //&#9;&#9;&#9;&#9;do { &#9;&#9;&#9;//&#9;&#9;&#9;&#9;&#9;&#9;items = try! (contexto.fetch(fetchDuplicates) as! [Entity]) &#9;&#9;&#9;//&#9;&#9;&#9;&#9;} catch let error as NSError { &#9;//&#9;&#9;&#9;&#9;&#9;&#9;print("Tenemos este error en los duplicados\(error.code)") &#9;&#9;&#9; //&#9;&#9;&#9;&#9;} &#9;&#9; &#9; let rediciendArray = items!.reduce(into: [:], { $0[$1,default:0] += 1}) &#9;&#9;print("reduce \(rediciendArray)") &#9;&#9;let sorteandolos = rediciendArray.sorted(by: {$0.value > $1.value }) &#9;&#9;print("sorted \(sorteandolos)") &#9;&#9;let map = sorteandolos.map({$0.key}) &#9;&#9; &#9;&#9;print(" map : \(map)") &#9;} } // End of class I have tried to solve the error and I have investigated what it is for my array but the truth is that I have not had the solution no matter how much I look for it, if someone could help me it would be of great help.
2
0
2.9k
Sep ’20
set individual information to each custom marker
Hi community, I have a problem with an array of MKAnnotationViews that are customized, in which I want to display the information for each marker individually, such as its title or its description that contains that marker, I don't know if it opens any way to do it. I leave my code below:   func setUpAllThePins(allLogos:[String],allLongitudesAndLatitudes:[CLLocationCoordinate2D],kmDouble:[Double],streets:[String],alcaldia:[String],calificacion:[Int],titulos:[String]){                                   imagenes = allLogos.compactMap{ link->UIImage? in             guard let url = URL(string: link) else {return nil}         guard let imageData = try? Data(contentsOf: url) else {return nil}             return UIImage(data: imageData)                    }             let annotations = zip(allLongitudesAndLatitudes, imagenes)         .map { (coordinate, allLogos) -> myAnnotation in             let annotation = myAnnotation(title: "", subtitle: "", coordinate: coordinate, localImage: allLogos)             return annotation                 }            if let oldArray = annotations as? [MKAnnotation]{             for i in oldArray{                 mapView.addAnnotation(i)             }                     }          }
2
0
540
Dec ’20
Core Bluetooth CBAdvertisementDataServiceDataKey could have some custom data?
Hi community, Im trying to send some data between and android and iOS device with BLE, but I need to send some custom information on the side of iOS to android , I already try almost all the keys that the CBCentralManager provides , but I try to send some string with the key CBAdvertisementDataServiceDataKey but nothing happens,anyone to know how to send information in that key? in advance I try to have that information without connection. this is the function that I use to try to make that part that I explain before. func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { if peripheral.state == .poweredOn{ let data = CBMutableCharacteristic(type: hardCodeUUID, properties: [.read], value: userName.data(using: .utf8), permissions: [.readable]) peripherialManager.startAdvertising([ CBAdvertisementDataLocalNameKey:"Jael2522",CBAdvertisementDataServiceDataKey:userName.data(using: .utf8),CBAdvertisementDataServiceDataKey:[CBUUID(string: "Jose")]]) let serialService = CBMutableService(type: hardCodeUUID, primary: true) serialService.characteristics = [data] peripherialManager.add(serialService) } }
0
0
628
Apr ’21
Assets throws me a error in SwiftUI Xcode 13.0
Hi good morning community, I have a really weird error , my project for some reason don't find my assets and told me that is an error in my bundle Resources. if I delete my assets in the copy Bundle Resources the errors goes away, but my images don't look in my project. the error that Xcode throws me is this : CompileAssetCatalog /Users/jxr0721/Library/Developer/Xcode/DerivedData/ZabulonApp-cwdueaevkgvjznbmjsxbvmqosobm/Build/Products/Debug-iphonesimulator/ZabulonApp.app /Users/jxr0721/Desktop/Personal/ZabulonApp/ZabulonApp/Assets\ .xcassets /Users/jxr0721/Desktop/Personal/ZabulonApp/ZabulonApp/Preview\ Content/Preview\ Assets.xcassets (in target 'ZabulonApp' from project 'ZabulonApp')     cd /Users/jxr0721/Desktop/Personal/ZabulonApp     /Applications/Xcode.app/Contents/Developer/usr/bin/actool --output-format human-readable-text --notices --warnings --export-dependency-info /Users/jxr0721/Library/Developer/Xcode/DerivedData/ZabulonApp-cwdueaevkgvjznbmjsxbvmqosobm/Build/Intermediates.noindex/ZabulonApp.build/Debug-iphonesimulator/ZabulonApp.build/assetcatalog_dependencies --output-partial-info-plist /Users/jxr0721/Library/Developer/Xcode/DerivedData/ZabulonApp-cwdueaevkgvjznbmjsxbvmqosobm/Build/Intermediates.noindex/ZabulonApp.build/Debug-iphonesimulator/ZabulonApp.build/assetcatalog_generated_info.plist --app-icon AppIcon --accent-color AccentColor --compress-pngs --enable-on-demand-resources YES --filter-for-device-model iPod9,1 --filter-for-device-os-version 15.0 --development-region en --target-device iphone --target-device ipad --minimum-deployment-target 14.0 --platform iphonesimulator --compile /Users/jxr0721/Library/Developer/Xcode/DerivedData/ZabulonApp-cwdueaevkgvjznbmjsxbvmqosobm/Build/Products/Debug-iphonesimulator/ZabulonApp.app /Users/jxr0721/Desktop/Personal/ZabulonApp/ZabulonApp/Assets\ .xcassets /Users/jxr0721/Desktop/Personal/ZabulonApp/ZabulonApp/Preview\ Content/Preview\ Assets.xcassets 2021-10-14 09:48:10.268 ibtoold[19324:122384] DEBUG: Added to environment: {     TMPDIR = "/var/folders/2x/4w3vtvq56v78kn9cr9hwrvg0p2yb9m/T/1B31541F-8ECD-4FA8-9EAF-861E8005F12C"; } Command CompileAssetCatalog failed with a nonzero exit code. I don't know what's going on , if anyone knows how to delete this erro I appreciate a lot !
2
0
734
Oct ’21
Error 159 - Sandbox restriction when connecting to XPC service
Hello Apple Developer Community, I'm encountering an issue with my macOS application where I'm receiving the following error message: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.FxPlugTestXPC was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.FxPlugTestXPC was invalidated: failed at lookup with error 159 - Sandbox restriction.} This error occurs when my application tries to establish a connection to an XPC service named com.FxPlugTestXPC. It appears to be related to a sandbox restriction, but I'm unsure how to resolve it. I've checked the sandboxing entitlements and ensured that the necessary permissions are in place. However, the issue persists. Has anyone encountered a similar error before? If so, could you please provide guidance on how to troubleshoot and resolve this issue? Any help or insights would be greatly appreciated. Thank you. this is some photos about my entitlements :
16
0
2.7k
Apr ’24
Xcode do not pause at breakpoints
In the latest version of Xcode, breakpoints are not displaying correctly, making it difficult to track code behavior. Previously, Xcode allowed you to step through each function, showing clear execution steps and allowing interaction to debug effectively. However, now it only shows memory addresses without providing meaningful insights, limiting the ability to interact with or test the code as it's being developed. Is anyone else experiencing this issue, or does anyone know of a workaround?
1
1
250
Sep ’24