Posts

Post not yet marked as solved
2 Replies
952 Views
Hello:Any help will be appreciated on this issue with App Store Connect.App store rejection notice says: "Specifically, we found that when the user closes the main application window there is no menu item to re-open it."I have requested clarification but have not got a response.Is there ever a way to have a menu available after a MAC OSx application is closed to re-open the app?Thanks for help!
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
1 Replies
331 Views
Hello:I have a status bar extra menu Item in my MAC OS app. Currently when I close the app the status bar menu disappears. Is there a way to have the status bar item remain in the same way the MAC items persists regardles of what application is running?
Posted
by wlionel.
Last updated
.
Post marked as solved
1 Replies
1.8k Views
HelloI have seen "UIApplication.shared.open (url)" used for iOS apps but I can't find the corresponding Swift rendering for MAC OSX app.This doesn't work:NSApplication.shared.open (url). I get error // NSApplication.shared has no member open.Any help will be appreciated.
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
3 Replies
462 Views
Hello:I have been trying to respond to Appstore Connect rejection notice:"It would be appropriate for the app to implement a Window menu that lists the main window so it can be reopened, or provide similar functionality in another menu item. macOS Human Interface Guidelines state that "The menu bar [a]lways contains [a] Window menu"."Currently I have an item on the status bar to Quit the application (When all windows are closed).What I can't figure out after have read tons of tutorials is How to have a menu when the applocation is close. Do I have to use Safari?Furthermore, there is the app icon on the desktop that is used to open the application.I can't figure out what they are asking for.Please Help!!!
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
3 Replies
1.2k Views
Hello:My default NSMenu has items which are not applicable to my app. How can I remove the unwanted items?func applicationDidFinishLaunching(_ aNotification: Notification) { item = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) func removeItem(at: Int){ }What is the code for line 4?The Default menu has the following:App name, File, Edit, Format, Window, View, Help. I want to remove 4 of these.
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
1 Replies
27k Views
Hello:I am using Xcode 11.3.1.I have searched far and wide on the internet and on the forums to find a way to create an .ipa file from my mac OS project. The reason is that i want to use Apple transporter to upload my build to app store connect.I have resorted to using the apple transpotrer because following the Xcode Product --> Archive --> Organizer --> Upload process ends up with a .app file on my desktopAll the suggestions I follow only create an .app file which the transporter rejects.Can anyone point me to a reference that gives a clear explanation? Most of the ones I found and tried ends up with the same .app file.Thanks.
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
3 Replies
3.9k Views
HelloNeed so help here! None of the examples I've found work:Here's my code: I have two predicates "2" and "ELA" to open a specific plist file. I have it working with one but need to use both.When I try the construction below i get error : "Variable binding in a condition requires an initializer"if case "2", case "ELA" = passedFromA { //Variable binding in a condition requires an initializer let filePath = Bundle.main.path(forResource: "Grade2ELA", ofType: "plist")// passedFromA is optional, need to test for nil print("filePath", filePath!) figures = Figure.figuresList(filePath!) print("figures count", figures.count) print ("FProcess G") let getdata = "\(String(describing: appDelegate?.nameGrade))" print("Check data : \(getdata)") }
Posted
by wlionel.
Last updated
.
Post marked as solved
2 Replies
404 Views
Hello:I am having some difficulty unstanding why my variable doesn't work outside a function:Here is my code:let fetchRequest = NSFetchRequest(entityName: "SCQ") fetchRequest.returnsObjectsAsFaults = false let nameGrade = gradeValue.stringValue print ("Name Grade From Declaration is \(nameGrade)") let subjectSelected = subjectValue.stringValue func gradeToFetch() { if nameGrade == "2" || nameGrade == "3" { let nameGrade = "2" print ("Name Grade First Try is \(nameGrade)") } gradeToFetch() let predicate1 = NSPredicate(format: "grade = %@",nameGrade) let predicate2 = NSPredicate(format: "subject = %@",subjectSelected) fetchRequest.predicate = NSCompoundPredicate(andPredicateWithSubpredicates: [predicate1, predicate2]) do { items = try managedContext.fetch(fetchRequest) as! [NSManagedObject] print ("selected grade is \(nameGrade)") print ("selected subject is \(subjectSelected)") print ("Group Name is \(nameGroup)") print ("Records Selected = \(items.count)") } catch let error as NSError { print("Could not fetch. \(error), \(error.userInfo)") }I want the value entered (line 4) to be the value converted by the function (lines 8 - 13) in the predicate (line 21) but i am getting the value entered in the predicate. (the output below shows 2 as the converted value but the predicate uses 3)This is the log:Name Grade From Declaration is 3 // line 5Name Grade First Try is 2 // line 10
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
6 Replies
792 Views
let date = Date() let dateFormatter = DateFormatter() dateFormatter.dateFormat = "dd/MM/yyyy" let fetchRequest: NSFetchRequest = GroupRecord.fetchRequest() fetchRequest.predicate = NSPredicate(format: "groupName == %@ ", groupNameItem) do { let items = try managedObjectContext.fetch(fetchRequest) for item in items { if let dateItem = (item.value(forKey: "date")) { print(dateItem) } } }I have a date attribute with dates. Record was saved, but I cannot get that date displayed in a textView. All I am getting is the current system date.Any help will be appreciated.
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
0 Replies
595 Views
in my code line 6 is returning the save date butline 7 is printing the current dateI want the save date instead for attribute "date" (line 6)func getFormattedDate(date: Date, format: String) -> String { let dateformat = DateFormatter() dateformat.dateFormat = format return dateformat.string(from: date) } _ = item.value(forKey: "date") as? NSDate let formatingDate = getFormattedDate(date: Date(), format: "dd-MMM-yyyy")
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
9 Replies
568 Views
Hello I have the following Code:I want to display in the textView lines 53 and 54 below. If I don't include the Date (lines 49 - 51), the information displays. But if I include the display of the date nothing displays. I would like some help in understanding why and what to do to get the date information displayed.@IBActionfunc showPerformance(_ sender: NSButton) { studentsText.string = "" groupNameItem = "" // var event: String = "" var convertedString: String = "" var covertedTime: String = "" let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd" let newDateFormatter = DateFormatter() newDateFormatter.dateFormat = "MM d" let timeFormatter = DateFormatter() timeFormatter.dateFormat = "HH-mm-ss" let newTimeFormatter = DateFormatter() newTimeFormatter.dateFormat = "h:mm a" var groupNameItem = groupNameField.stringValue guard (NSApplication.shared.delegate as? AppDelegate) != nil else { return } _ = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext _ = NSFetchRequest(entityName: "GroupRecord") _ = NSSortDescriptor(key: "groupName", ascending: true) let fetchRequest: NSFetchRequest = GroupRecord.fetchRequest() fetchRequest.predicate = NSPredicate(format: "groupName == %@ ", groupNameItem) do { let items = try managedObjectContext.fetch(fetchRequest) groupNameItem = "" for item in items { if let record0Item = item.value(forKey: "grade") as? String { print ("Record 0 Item is \(record0Item)") gradeItem.append(record0Item) print ("Grade is \(gradeItem)") if let record1Item = item.value(forKey: "groupName") as? String { print ("Record 1 Item is \(record1Item)") groupNameItem.append(record1Item) print ("Group Name is \(groupNameItem)") if let record2Item = item.value(forKey: "score") as? String { print ("Record 2 Item is \(record2Item)") groupScoreItem.append(record2Item) print ("Group Score is \(groupScoreItem)") if let record3Item = item.value(forKey: "date") as? String { dateItem.append(record3Item) print ("Record 3 Item is \(record3Item)") let newLine = ((dateItem) + (" ") + ("Grade") + (" ") + (gradeItem) + (" ") + (groupNameItem) + (" ") + ("Group Score") + (" ") + (groupScoreItem)) studentsText?.string = studentsText!.string + newLine + "\n" groupNameItem = "" groupScoreItem = "" gradeItem = "" } } } } } print("\(items)") print ("There are \(items.count) items") print("Records are \(items)") return() } catch { fatalError("Failed to fetch records: \(error)") } }
Posted
by wlionel.
Last updated
.
Post marked as solved
2 Replies
2k Views
Hello:I am using Swift 5.1.3. I can't get a simple Int variable to concatenate with String variables.Any help will be appreciated. I want to include a percentage from two numbers with a string of Strings. Belowis my code:I am getting an error on line 12: Binary operator '+' cannot be applied to operands of type 'String' and 'Int' --referencing "groupPercent"func getPercent(){ let groupPercent: Double = Double(qmSum) / Double(qaSum) * 100 print ("Percent is \(groupPercent)") } getPercent() let firstPart = (groupNameItem) + (" ") let secondPart = ("Group Score") + (" ") let newLine = (firstPart + secondPart + groupPercent) studentsText?.string = studentsText!.string + newLine + "\n"Thanks.
Posted
by wlionel.
Last updated
.
Post marked as solved
2 Replies
3.7k Views
Hello I have the following piece of code to display data in NSTextView. I want to have a new line after each record. Need help to set the new line character so Swift will not concatenate each time a new record is inserted into the TextView, on line 28.Any help will be appreciated.{By the way, I've spent weeks trying to use the NSTableView without success. This method is simple and it gives me what I need).@IBActionfunc showStudents(_ sender: NSButton) { guard (NSApplication.shared.delegate as? AppDelegate) != nil else { return } _ = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext _ = NSFetchRequest(entityName: "Registration") _ = NSSortDescriptor(key: "lastName", ascending: true) let fetchRequest: NSFetchRequest = Registration.fetchRequest() do { let items = try managedObjectContext.fetch(fetchRequest) for item in items { if let record0Item = item.value(forKey: "lastName") as? String { print ("Record Item is \(record0Item)") lastNameItem.append(record0Item) print ("Last Name Item is \(lastNameItem)") if let record1Item = item.value(forKey: "firstName") as? String { print ("Record Item is \(record1Item)") firstNameItem.append(record1Item) print ("First Name Item is \(firstNameItem)") if let record2Item = item.value(forKey: "middleName") as? String { print ("Record Item is \(record2Item)") middleNameItem.append(record2Item) studentsText?.string = ((lastNameItem) + (" ") + (firstNameItem) + (" ") + (middleNameItem)) print ("Middle Name Item is \(middleNameItem)") } } } } } }
Posted
by wlionel.
Last updated
.
Post marked as solved
29 Replies
3.9k Views
Hello:I am getting the following error:Illegal NSTableView data source: Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:My tableView implementation is as follows:import Cocoa import CoreData class RegistrationReportsViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() showRegisteredStudents() tableView.dataSource = self tableView.delegate = self tableView.reloadData() } private lazy var fetchedResultsController: NSFetchedResultsController = { let fetchRequest: NSFetchRequest = Registration.fetchRequest() let frc = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil) frc.delegate = (self as! NSFetchedResultsControllerDelegate) return frc }() var items: [NSManagedObject] = [] var managedObjectContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext let persistentContainer: NSPersistentContainer = { let container = NSPersistentContainer(name: "ScorcentMasterReview") container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error { fatalError("Unresolved error \(error)") } }) return container }() @IBOutlet weak var tableView: NSTableView! var firstNameItem = "LAST" var middleNameItem = "MIDDLE" var lastNameItem = "FIRST" func showRegisteredStudents() { guard (NSApplication.shared.delegate as? AppDelegate) != nil else { return } let managedContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext let fetchRequest = NSFetchRequest(entityName: "Registration") fetchRequest.returnsObjectsAsFaults = false fetchRequest.sortDescriptors = [NSSortDescriptor(key: "lastName", ascending: true)] do { let items = try managedContext.fetch(fetchRequest) as! [NSManagedObject] print ("There are \(items.count) items") _ = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil) // Configure Fetched Results Controller print("Records are \(items)") self.tableView.reloadData() return() } catch { fatalError("Failed to fetch employees: \(error)") } } } extension RegistrationReportsViewController: NSTableViewDataSource{ func numberOfRowsInTableView(tableView: NSTableView) -> Int { let numberOfRows:Int = items.count return numberOfRows } } //NSTableViewDelegate extension RegistrationReportsViewController: NSTableViewDelegate{ func configureCell(cell: NSTableCellView, row: Int, column: Int){ let registration = fetchedResultsController.fetchedObjects! [row] switch column { case 0: cell.textField?.stringValue = registration.lastName ?? "" case 1: cell.textField?.stringValue = registration.firstName ?? "" case 2: cell.textField?.stringValue = registration.middleName ?? "" default: break } func tableView(tableView: NSTableView!, objectValueForTableColumn tableColumn: NSTableColumn!, row: Int) -> AnyObject!{ _ = fetchedResultsController.fetchedObjects! [row] let cell = tableView.makeView(withIdentifier: (tableColumn!.identifier), owner: self) as? NSTableCellView let column = tableView.tableColumns.firstIndex(of: tableColumn!)! // cell?.textField?.stringValue = registration[(tableColumn?.identifier.rawValue)!]! configureCell(cell: cell!, row: row, column: column) return cell } }I would appreciate any help that points me in the right direction. Thanks.
Posted
by wlionel.
Last updated
.
Post not yet marked as solved
0 Replies
937 Views
Hello:I've been studying up on How to populate an NSTableView with data from CoreData using a fetchRequest. A lot of the information I found is for Swift 3 and 4. I am using the latest Xcode Version with Swift 5.1. I've looked at the Apple Documentation, lots of tutorials, some responses in Apple CoreData Forum, and my implementation of tableViews with CoreData in my iOS app.Using what I've found, I constructed the code below to be able to display data from my CoreData store in an NSTableView (MAC OSx app).I set up the NSTableView inside of a ViewController, added the delegates, set the cell identifiers in interface builder, and setup for three columns.I think that what I've done below is too much (It absolutely can't be "not enough"). In any case , no data is displayed in the table View.I'd really appreciate some help with this.Thanks in advance. Please let me know what I don't need.import Cocoa import CoreData class RegistrationReportsViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() showRegisteredStudents() tableView.dataSource = self as? NSTableViewDataSource tableView.delegate = self as? NSTableViewDelegate } private lazy var fetchedResultsController: NSFetchedResultsController = { let fetchRequest: NSFetchRequest = Registration.fetchRequest() let frc = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil) frc.delegate = self return frc }() var managedObjectContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext let persistentContainer: NSPersistentContainer = { let container = NSPersistentContainer(name: "ScorcentMasterReview") container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error { fatalError("Unresolved error \(error)") } }) return container }() @IBOutlet weak var tableView: NSTableView! func showRegisteredStudents() { guard (NSApplication.shared.delegate as? AppDelegate) != nil else { return } let managedContext = (NSApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext let fetchRequest = NSFetchRequest(entityName: "Registration") fetchRequest.sortDescriptors = [NSSortDescriptor(key: "lastName", ascending: true)] do { let records = try managedContext.fetch(fetchRequest) as! [NSManagedObject] print ("There are \(records.count) records") let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: self.persistentContainer.viewContext, sectionNameKeyPath: nil, cacheName: nil) // Configure Fetched Results Controller fetchedResultsController.delegate = self print("First Name is \(records)") self.tableView.reloadData() return() } catch { fatalError("Failed to fetch employees: \(error)") } func controllerWillChangeContent(_ controller: NSFetchedResultsController) { tableView.beginUpdates() } func controllerDidChangeContent(_ controller: NSFetchedResultsController) { tableView.endUpdates() } } } var records: [NSManagedObject] = [] extension RegistrationReportsViewController : NSTableViewDataSource{ func numberOfRows(in tableView: NSTableView) -> Int{ return records.count } } extension RegistrationReportsViewController : NSTableViewDelegate{ fileprivate enum CellIdentifiers { static let lastNameCell = "LNCellID" static let firstNameCell = "FNCellID" static let middleNameCell = "MNCellID" } //NSTableViewDelegate func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { let cell: NSTableCellView! let column = tableView.tableColumns.firstIndex(of: tableColumn!)! switch column { case 0: cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "lastName"), owner: nil) as? NSTableCellView case 1: cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "firstName"), owner: nil) as? NSTableCellView case 2: cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "middleName"), owner: nil) as? NSTableCellView default: return nil } configureCell(cell: cell, row: row, column: column) return cell } fileprivate func configureCell(cell: NSTableCellView, row: Int, column: Int){ let registration = fetchedResultsController.fetchedObjects! [row] switch column { case 0: cell.textField?.stringValue = registration.lastName ?? "" case 1: cell.textField?.stringValue = registration.firstName ?? "" case 2: cell.textField?.stringValue = registration.middleName ?? "" default: break } } } extension RegistrationReportsViewController : NSFetchedResultsControllerDelegate{ func controller(_ controller: NSFetchedResultsController, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?){ switch type { case .insert: if let newIndexPath = newIndexPath { tableView.insertRows(at: [newIndexPath.item], withAnimation: .effectFade) } case .delete: if let indexPath = indexPath { tableView.removeRows(at: [indexPath.item], withAnimation: .effectFade) } case .update: if let indexPath = indexPath { let row = indexPath.item for column in 0.. if let cell = tableView.view(atColumn: column, row: row, makeIfNecessary: true) as? NSTableCellView { configureCell(cell: cell, row: row, column: column) } } } case .move: if let indexPath = indexPath, let newIndexPath = newIndexPath { tableView.removeRows(at: [indexPath.item], withAnimation: .effectFade) tableView.insertRows(at: [newIndexPath.item], withAnimation: .effectFade) } @unknown default: fatalError() } } func controllerWillChangeContent(_ controller: NSFetchedResultsController) { tableView.beginUpdates() } func controllerDidChangeContent(_ controller: NSFetchedResultsController) { tableView.endUpdates() } }
Posted
by wlionel.
Last updated
.