Post

Replies

Boosts

Views

Activity

How to Resolve App Store Connect Issue
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!
2
0
1.1k
Mar ’20
How to Open an App after it is closed with menu
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!!!
3
0
551
Mar ’20
My Menu Bar Extra Item does not display. Why?
Hello:I am creating a Menu Bar Extra Item for my MAC os App. I have the following code but nothing displays on the menu bar. W ould appreciate some advice on where in the code I need to make changes:import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { //@IBOutlet weak var window: NSWindow! let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength) // var item: NSStatusItem? = nil @objc func QuitScorCentMasterReview(_ sender: Any?) { NSApplication.shared.terminate(self) } func applicationDidFinishLaunching(_ aNotification: Notification) { if let button = statusItem.button { button.image = NSImage(named:NSImage.Name("SMR_icon.png")) button.action = #selector(QuitScorCentMasterReview(_:)) } func constructMenu() { let menu = NSMenu() menu.addItem(NSMenuItem(title: "End the Application", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "")) statusItem.menu = menu } constructMenu() }
7
0
2.7k
Mar ’20
How to remove items from default NSMenu
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.
3
0
1.3k
Mar ’20
How to create .ipa file from Xcode project file
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.
1
0
28k
Mar ’20
Variable binding in a condition requires an initializer: Need help to solve
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)") }
3
0
4.4k
Feb ’20
How to solve problem using a variable outside a function
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
2
0
472
Feb ’20
How to fetch date
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.
6
0
883
Feb ’20
How to fetch a saved date from CoreData
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")
0
0
672
Feb ’20
Date Cannot be Printed. Why?
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)") } }
9
0
650
Jan ’20
How to concatenate an integer variable with string variables
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.
2
0
2.3k
Jan ’20
How to set new line character programmatically for NSTableView
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)") } } } } } }
2
0
4.1k
Jan ’20
Illegal NSTableViewDataSource
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.
29
0
4.2k
Jan ’20