File owner changed when showing NSPopover - macos

This looks really strange to me
Once i add a NSPopover and it's contentVC to the Nib (file owner is set right to myVC) and right AFTER triggering
[self.sliderPopover showRelativeToRect:rect ofView:sender preferredEdge:NSMinYEdge];
All mi bindings and action bound to FileOwner(myVC) are (re)bound to the Popovers content VC and i'am getting lot's of
Could not connect the action testValueChanged: to target of class SliderPopoverViewController
As the Popovers contentVC, doesn't have the corresponding path
Why is this happening?
UPDATE:
when i do
- (void)awakeFromNib {
[self.sliderPopover.contentViewController view];
}
the same problem occurs, so it's definitely related to loading of the contentVC
UPDATE:
Changing the name from
SliderPopoverViewController.xib to __SliderPopoverViewController.xib did helpe, but i still don't understand why (and in second place, i don't understand, why the __SliderPopoverViewController was loaded after name change (as it doesn't match the name of the class))
So is this all some weird bug?

Must have been some bug, renaming the
SliderPopoverViewController.xib to __SliderPopoverViewController.xib did helped

Related

Swift3 Cocoa Storyboard Storyboard doesn't contain a controller with identifier 'MainWindow'

In my project in cocoa have the same Problem as Can Poyrazoğlu in this Question:
Storyboard doesn't contain a controller with identifier 'MainWindow'
None of the advices help, included manually saving the project. It worked well - 3000 lines - until I began inserting code with NSTableView.
The behavior is odd:
I have some print statements in the TableView code for debugging.
After a change in the code, the app runs but nothing is shown in the TableView exept the above line appears, but the printing does not show up in the console. Running again mostly works. The error message now apears AFTER the print output.
Is this a timing issue?
Storyboard ID is set correctly, I think. In other projects I never had to set such an ID
Any help...
let mainViewController2 = self.storyboard?.instantiateViewController(withIdentifier: "mainview") as! mainview
in your case you forgot the class name so this error showing you.

What is causing NSNull length unrecognized selector keyCommand error

I have this class/storyboard scene in a project that up to last night worked fine for the past 4 weeks i worked on it.
I have managed to comment out practically everything and I still get the crash when tapping on the UITextField and typing a number. It only crashes when I type in a value, otherwise it doesn't crash.
Here is the class as I am running it now:
import Foundation
import UIKit
import HealthKit
import CoreData
class WorkoutViewController: UITableViewController {
//Properties
#IBOutlet var numberOfLapsTextField: UITextField?
#IBOutlet var metersPerLapTextField: UITextField?
#IBOutlet var workoutDurationTextField: UITextField?
#IBOutlet var paceTextField: UITextField?
var healthStore:HKHealthStore?
override func viewDidLoad() {
super.viewDidLoad()
}
Originally it had the IBOutlets as ! instead of ? And it has a CoreData stack property, some blurred background effects for the tableview background, fetches user's weight from health store on viewDidLoad, a predicate helper method for health store fetches and a cancel and done button. The done button captured data from the textfields, made some computations and saved data to the health store and to coredata. But ALL of this has been commented out leaving only what is seen above.
I did managed to get a weird stack trace in the console one time (can't seem to get it anymore) that read:
[UIPhysicalKeyboardEvent _matchesKeyCommand:]
and a few others like it just before it.
Im stumped, any ideas? Exception breakpoints is one but it just throws me to the AppDelegate class declaration line where UIResponder is adopted. Ive learned and rebuilt. I don't know what else to look for.
Im thinking its a corrupt storyboard file because Ive added and removed scenes with textfields and they all behave the same. Here is my storyboard.xml file:
http://www.santiapps.com/iOS/Main.storyboard.xml
I had a crash with the same cryptic NSNull length message. It cropped up occasionally on only one screen when testing in the simulator and by trial and error I discovered it only happened when I pressed the cmd key.
Looking in my storyboard source I found the following:
<keyCommands>
<keyCommand/>
</keyCommands>
Which I think lets you define keyboard shortcuts for anyone using a bluetooth keyboard. However - this is an empty definition, so it seems pressing cmd caused whatever this executes to fail because I don't have any valid shortcuts defined.
I have absolutely no idea how this happened, but if you use the graphical Interface Builder UI to look at your Storyboard, go to the view controller giving you the problem and click on the root view controller. Under the Attributes inspector there is a Key Commands section. I reckon I must have accidentally hit the + button here at some point. You can select the first 'item' and hit - to get rid of it and the problem should disappear.
Alternatively, delete the keyCommands section from the Storyboard source directly.
I see this question has already been marked as answered, but I include this in case the additional information on top of the original answer (and comment) is useful to someone else.
Ok I deleted the navigation controllers and tab bar controller and re-added them, and the problem is gone! There are no more crashes when I type in data. It was obviously a corrupted scene but the weird thing is that all of a sudden, all scenes with uitextfields got corrupted in the same way.
Click on view controller and in attributes inspector under Key commands remove "Enter action below" entry

Strange error with NSSecureTextField in NSOpenPanel's accessory view

in my app I use an NSOpenPanel with an accessory view. This view has, among other things, a NSSecureTextField. Every time I open the panel this notice shows up in the log:
NSSecureTextFieldCell detected a field editor ((null)) that is
not a NSTextView subclass designed to work with the cell. Ignoring...
Does anybody know what exactly this means and how to get rid of it?
For now it isn't causing any problems but I would like to remove this.
Thanks a lot!

My DetailViewController isn't recognizing the '-configureView'

I had a problem with the splitView so I decided to make my own version of it using a ViewBasedApplication. The view is set up to be like a splitView, but instead of having the static table when you flip it to landscape it will have the popover control like it normally does in the portrait mode.
I have everything set up, but I'm encountering an error when I select an item from the popover table. It isn't updating the view to go to the appropriate page that was selected in the table...the code for the setDetailItem in the ViewController.m file looks like this:
-(void)setDetailTime:(id)newDetailItem{
if(detailitem != newDetailItem) {
[detailitem release];
detailItem = [newDetailItem retain[;
[self configureView];
...
}
The problem is in the [sef configureView] line. it says that "PDFViewController" may not respond to '-configureView'. Im assuming this is because '-configureView' is specific to only the SplitView. Any ideas of a way to workaround this issue?
Thanks!
Your class PDFViewController does not have a configureView method, which is why you're getting the warning (and why you're not seeing anything happen).
You probably need to instead call [self.view setNeedsDisplay] which basically tells the view to redraw itself. I don't know if this will work for you, because I don't know how the rest of your class is written.

load nibs in cocoa

How can I load a nib inside of another window?
I tried initWithWindowName,
if (mmController == NULL)
mmController = [[mainMenu alloc] initWithWindowNibName:#"mainMenu"];
[mmController showWindow:self];
but it opens a new window.
I also tried loadNibNamed
[NSBundle loadNibNamed:#"mainGame" owner:self];
and it succeeded, but when I try to use the same method to get back to the main menu,
[NSBundle loadNibNamed:#"mainMenu" owner:self];
it doesn't work. It does nothing at all...
Any ideas?
I tried initWithWindowName,
You mean initWithWindow¹Nib²Name³:, which takes the name (3) of a nib (2) containing a window (1).
if (mmController == NULL)
This should be nil, not NULL, since you are comparing an Objective-C object pointer.
mmController = [[mainMenu alloc] initWithWindowNibName:#"mainMenu"];
What is mainMenu here? It must be a class, but what is it a subclass of?
[mmController showWindow:self];
From this message and the previous message, I'm guessing mainMenu is a subclass of NSWindowController.
Guessing should not be required. You should name your classes specifically, so that anybody can tell what the class is and its instances are merely by the class name.
Brevity is a virtue, but if you need to go long, go long. We've got modern tools with name completion. The tab key can eliminate the sole advantage of an abbreviated name.
but it opens a new window.
Yes. You created a window by loading it from a nib, and then you told the window controller to show that window. Showing a new window is the expected result.
I also tried loadNibNamed
[NSBundle loadNibNamed:#"mainGame" owner:self];
and it succeeded, but when I try to use the same method to get back to the main menu,
There is no “get back”. Loading a nib is simply creating objects by loading them from an archive. You can load the same nib multiple times, and loading a nib does not somehow undo the results of loading a previous nib.
You may want to read the Resource Programming Guide, which covers nibs as well as image and sound files, and the Bundle Programming Guide.
If you want to hide the window you loaded from the mainGame nib, do that. The term for this in AppKit is “ordering out” (as opposed to “ordering in”, which “ordering front” and “ordering back” are specific ways of doing).
[NSBundle loadNibNamed:#"mainMenu" owner:self];
it doesn't work. It does nothing at all...
Are you trying to load the MainMenu nib that came with your project? If so, make sure you get the case right—you don't want your app to be broken for people who run it from a case-sensitive volume, nor do you want it to be broken for people who use the default case-insensitive file-system.
If that's not what you're trying to do, then it isn't clear what you are trying to do. MainMenu is normally the nib containing the main menu (the contents of the menu bar); naming any other nib “mainMenu” or anything like that is going to cause confusion at best and problems at worst. If this is supposed to be some other nib, you should give it a different name.
Either way, this is not what you need to do. If you want to hide the window you loaded from mainGame, then you need to hide that window, not load a different nib.
Moreover, once the window is loaded, do not load it again (unless you close and release it). Once you have loaded it, you can simply order it back in. Most probably, you will want to both make it key and order it front.
On the Mac, you are not limited to one window at a time; indeed, your app has multiple windows (at least three), no matter what you do. The APIs are built around your ability to show multiple windows.
See the Window Programming Guide for more information.
How can I load a nib inside of another window?
As Justin Meiners already told you, you may want NSViewController for that, although you can go without and just load the nib containing the view directly using loadNibNamed:.
Be warned that NSViewController is not nearly as powerful/featureful as Cocoa Touch's UIViewController.
You'll want to read the View Programming Guide for this.

Resources