Main window doesn't run properly on Snow Leopard - cocoa

My app developed in Xcode 4.5 on Mountain Lion runs flawlessly on Lion and ML.
My Snow Leopard tester reports that when the app starts, it is disabled. By that he means none of the controls are active and the red, yellow, green 'traffic light' is greyed out. If another app is opened that covers my app, when the covering app is moved, any control, or part of a control it covered is not there.
The menu bar is responsive, and my preferences panel works. The app can be shut down from the menu, I don't know if it can be shut from the keyboard.
Another app that uses the same serial code works fine.
I need help with putting together a plan to solve it. I don't know how to trace this.

Fundamentally, the problem is that you're expecting data to be in NSUserDefaults. On first launch, NSUserDefaults returns nil for the keys you access, and passing this nil result through later code causes exceptions to be thrown. The solution is to register defaults with NSUserDefaults upon application startup:
#implementation AppController
+ (void)initialize
{
NSDictionary *defaultValues = #{#"SomeKey" : #"DefaultValue"};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}
#end

Related

Incompatibility 10.10 to 10.8

I have an app developped under Xcode7 in 10.10
I changed the deployment target system to 10.8 because of the IT situation of another school.
The 10.8 app runs fine under 10.10, but on an 10.8 machine, I only see a window grayed out in the face of the MainMenu.xib included the menus, but inactive. Its reaction are as in IB. The previous login windows called at startup are not shown.
In the console I only see a warning about 'Invalid color System labelColor'.
Explanation:
I reduced my project to the Start nib window and the MainMenu.xib. I looked for labelColor in every single nib and xib file with BBedit.
When I compile, I look in the content of the compiled app and can find a MainMenu.nib (not xib) with a single String Item labelColor.
Runnig the app in 10.10 is fine, but in 10.9 the warning appears.
Explanation 2:
Problem fixed: The labelColor is inserted in 10.10/Xcode7 with an NSBox inserted in IB. Obviously this was changed when I transfered the rather old project to Xcode7. I don't know if this is changeble.

NSPopover sample code does not detach window

I have not been able to get my NSPopover to detach to a window in my own projects, so to simplify I tried the Apple sample.
I downloaded a fresh copy of the Apple sample project: http://developer.apple.com/library/mac/samplecode/Popover/Introduction/Intro.html
It behaves the same, which is to say I can't drag the window to detach it either.
The project seems to provide all the correct windows and controllers and implements the detachableWindowForPopover: delegate method. However the method is never called.
Does anyone know the secret to detachable NSPopovers?
Found the answer while typing the question…
Mac OS X 10.10 Yosemite has a new delegate method:
(BOOL)popoverShouldDetach:(NSPopover *)popover
The default behavior on Yosemite is NO (should not detach). So delegates must implement this method in order for windows to be detachable. The sample project does not implement this method, so when compiled on Yosemite it will not detach (and also produces several deprecation warnings -- maybe I should have taken that hint that it needs an update).
Adding:
- (BOOL)popoverShouldDetach:(NSPopover *)popover {
return YES;
}
To MyWindowController.m fixes the problem.

Xcode signal SIGABRT

I received this warning from Xcode, though I have not changed a single character in the appdelegates (I´m new to Xcode). Nothing seems to work.
Here is the line it breaks:
return UIApplicationMain(argc, argv, nil, NSStringFromClass([Tre01AppDelegate class]));
I´ve changed the document version, restarted Xcode, the iOS simulator and the computer.
The problem I was working on while this error popped up, was embedding a webView, which I embedded in a new view controller (then I added the .h and .m-files for this controller, and set up the code for loading a website...). It all looked good and connected then the above came up.
Why is the appdelegate important to my web view, which is located in another viewcontroller? Do I have to initialize the new viewcontroller in the app delegate?
Many thanks, I know – I´m not very specific in adressing the problem, but I´m quite new to Xcode...

Out of the blue I can't get security scoped bookmarks

Blimey, this Sandboxing makes me despair: I have an app that's been released on Apple's store (so, in theory, it's gone through review...), it's a slide show player - nothing too fancy - the user can drag and drop images onto an NSTableView or select through NSOpenPanel. Anyway, I thought I'd use it myself so I recompiled a copy onto my laptop and all of a sudden I'm not allowed security bookmarking:
QuickSlide(1412) deny mach-lookup com.apple.scopedbookmarksagent.xpc
The above appears whenever I drag and drop images or select them through the NSOpenPanel.
I have the following entitlements:
The code I'm using to generate the bookmarks is:
-(NSData*)genSec:(NSURL*)aURL
{
NSError *error;
NSData *secData = [aURL bookmarkDataWithOptions:(NSURLBookmarkCreationWithSecurityScope | NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess | NSURLBookmarkCreationPreferFileIDResolution)
includingResourceValuesForKeys:nil relativeToURL:nil error:&error];
if (error) {
[self setReport: [NSString stringWithFormat:#"Can't access %# due to SandBoxing",aURL]];
return nil;
}
return secData;
}
Sure enough, the report method is also fired along with the Console logging.
It's never done this before in the months I did of development. I've also tried it on my dev Mac Pro crate, tried code-signing with different or no signing, and even downloaded it from the App Store (tried twice with 2 different accounts); all with the same result. I've also used the very handy Receigen app to check the entitlements in the compiled bundle. I'm running 10.7.5. The only thing that stops it from throwing errors is if I un-check the 'enable sandboxing' option in Xcode and compile.
Argghhh. Can someone point out the blindingly obvious mistake that somehow has slipped through 2 beta-testers, me, and an App Store reviewer...?!!!!
It has to be something obvious doesn't it?
UPDATE: I got a colleague to download a fresh copy to his laptop and there was no problem with sandboxing. I'd still appreciate it if anyone can shed some light on what's happening to my installs...
Todd.
Sure enough it seems from your entitlements that it is something obivous. You need to add this one as well:
com.apple.security.files.bookmarks.app-scope
I don't know why it was working before and now isn't, but I'm positive you need to declare this entitlement for security scoped bookmarks to work.

Xcode/Interface Builder crash

Iam using Xcode 4.4 on Mountain Lion and unable to do any IB related tasks.
Dragging a control to a xib file, connecting an IBoutlet to code, whatever I do , Xcode crashes
Any clues will be appreciated
Your situation sounds remarkably similar to what happened to me yesterday:
Xcode Interface Builder crashes when I edit storyboard
It would be worth looking at the console log to see if the reports are the same. If they are, experiment with the 'Use auto layout' checkbox.

Resources