I am trying to use Parse.com SDK in my Mac OSX app written in swift. I have followed the Quickstart Guide and used a bridging header but when I launch the app I am shown this message and the object is not created on launch.
Failed to set (contentViewController) user defined inspected property on (NSWindow): You have to call setApplicationId:clientKey: on Parse to configure Parse.
Any Ideas?
Thanks
I just ran into the same issue, for some reason the viewDidLoad() on the view controllers are executing before the app delegate's applicationDidFinishLaunching: method.
Although Parse recommends having their methods setup in the app delegate, setting up the app id/client key on your initial view's viewDidLoad will let you use parse normally.
Related
After writing UI tests with XCTest, I'm trying to change the server the build points to in the Settings app in the simulator. This is so automated tests run in the right place. Is there a way to do this with accessibility and UI testing code?
How can I change this URL?
Edit: #oletha 's answer is perfect. Here's the solution I used in Objective-C:
I set the launch argument to be configServer=#"URL"
for (NSString *launchArgument in [[NSProcessInfo processInfo] arguments]) { if ([launchArgument hasPrefix:#"configServer"]) { return [launchArgument componentsSeparatedByString:#"="].lastObject; } }
You can send a launch argument to the app by setting the launchArguments property before launching the app. You can then set up your app to read the launch argument during launch and set the URL of your mock server when it is launched with that launch argument.
// test code
let app = XCUIApplication()
app.launchArguments = ["UITESTS"]
app.launch()
// app code
if NSProcessInfo.processInfo().arguments.contains("UITESTS") {
// set different server URL
}
You probably want to add the URL switching code in applicationDidFinishLaunching on your app delegate.
As per Xcode 8.2 you cannot automate UI outside your own app's target, so you cannot interact with the Settings app on the device. I feel this is a bug and filed a radar (http://www.openradar.me/27802551), you might want to do the same.
I imagine the URL you're trying to change is stored somewhere in your preferences. If that's the case you could change it dynamically during the execution of your tests using SBTUITestTunnel. This is a 3rd party library that allows to interact with your application from UI Tests, enabling network mocking and monitoring, data injection and more. For your use case it allows to easily update NSUserDefaults.
I just upgraded Xcode to 8.0 (8A218a) and am converting my project in Swift 2.3 to Swift 3.0. The only issue left now is this error:
"Exception while running ibtool: Cannot find value transformer with
name UTIToIconTransformer"
The UTIToIconTransformer is defined something like:
#objc(UTIToIconTransformer) class UTIToIconTransformer : ValueTransformer {
// ...
}
The code worked fine when it was in Swift 2.3. The binding using this value transformer is set like this:
If I remove this binding, the app runs, and the row titles are shown correctly.
I have tried calling NSValueTransformer.setValueTransformer() in the app delegate's +initialize(), in applicationDidFinishLaunching and in the value transformer's +initialize(), as suggested here, here at StackOverflow and here at NShipster (Though I don't think the statement of "Typically, the singleton instance would be registered in the +initialize method of the value transformer subclass, so it could be used without further setup." complies with the Apple's doc.), all without success.
In the Apple's doc, it says
Value transformers are typically registered by an application’s delegate
class, in response to receiving a initialize: class message. This allows
registration to occur early in the application startup process, providing
access to the value transformers as nib files load.
Availability in Interface Builder
Your NSValueTransformer subclasses are not automatically listed in the
Interface Builder bindings inspector. When inspecting a binding you can enter
the name that the value transformer is registered with, but the functionality
will not be present in Interface Builder’s test mode. When your application
is compiled and run the transformer will be used.
But registering in the AppDelegate's override class func initialize() didn't help. In Xcode 7 and Swift 2.3, it even worked without the registration.
Finally I solved the problem by removing the NSOutlineView from the storyboard and setting up a new one.
I have another project which also has an outlineview binded with an NSTreeController, and that project has no problem after the Xcode 8.0 upgrade. Then I tried creating a new ValueTransformer with a new name, with no luck.
I guess there may be something wrong with the storyboard, so I tried recreating the outline view. Then Xcode doesn't complain that it can't find the transformers!
There is a helper app for my Project, both main App and helper app are in sandbox. The main App may be not running so i can not post distributed notification in helper App. And i found that helper App has no permission to set Userdefaults of main App.
So the only thing i can do is to open main App in the helper App with a parameter.
I can use below to do this.
[[NSWorkspace sharedWorkspace]launchAppWithBundleIdentifier:#"com.mainApp" options:0 additionalEventParamDescriptor:nil launchIdentifier:nil];
So how can i pass and get the parameter between the two apps?
Use app groups, so both apps will share access to special container (with a settings plist file for example).
I'm trying to experiment with web view by using swift. I created a simple Xcode project, placed a web view within my application interface and connected it to my app delegate.swift with an outlet called "myview". By executing
self.myview.mainFrameURL = "http://www.google.com"
from within applicationDidFinishLaunching(), I would expect the Google's homePage to be loaded. However, this doesn't happen: the web view does not show anything. What am I doing wrong?
1) Add the NSAppTransportSecurity in your plist https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
2) check in your project settings that "Sandbox" is enabled and that internet connections are allowed
You will have to call loadRequest() to make it load a page.
So basically:
[self.myWebView loadRequest: [NSURLRequest requestWithURL:
[NSURL URLWithString: #"http://www.google.com"]]]
After digging into the console logs, I found the solution to my problem. I'm not sure if I can share it though, since I'm using a beta OS X version and this restriction could have been introduced to improve apps' security, even if from what I can see it can be disabled.
I'm trying to understand what the "App Controller" is in a document based application. Apple doesn't mention it here. In the book I'm reading (Cocoa Programming for Mac OS X fourth edition), the author creates an app controller for handling a NSWindowController subclass that acts as a prefernce window. The app controller is a direct subclass of NSObject, so it appears that this isn't some standard Cocoa class.
Is this what app controller does? Handling shared windows in a document based application? Does it do something else?
[The AppController] is responsible for setting up all of the initial view controllers, the window and serving as the handler for OS<->Application messages.
This is taken from an answer to a similar question here.