I am working on a Cocoa macOS Swift project built using Swift 4 and Xcode 9, and I want to achieve the behavior of an application changing the first window that appears based on a UserDefaults variable. I have seen examples of this done in iOS applications, but after testing some of the available code, it seems that in this case the iOS examples do not work for macOS. In my application's delegate, I can check the value of this variable, but how would I efficiently and properly act upon it?
Ideally, if a certain condition is met Window 2 would appear at launch and Window 1 would not appear. If that condition is not met, the application would display Window 1 at launch. Thanks in advance!
Related
Hello I installed Alamofire 5.0 via pod and I try to run it on the real phone.
The project is empty only Alamofire and a contentView say hello world.
if a run it on simulator it work perfect, if I run on the real phone I get the following warning. (I authorized in general setting the app)
any solution? I don't know what is this
/private/var/containers/Bundle/Application/C526B7F7-4337-4D36-A9EB-C56913D97329/FlyWeatherX.app/Frameworks/Alamofire.framework/Alamofire: code signature invalid for '/private/var/containers/Bundle/Application/C526B7F7-4337-4D36-A9EB-C56913D97329/FlyWeatherX.app/Frameworks/Alamofire.framework/Alamofire'
thanks for the help
Check the version of your ios on your phone is it matching the version of ios on xCode or not.
also if your iphone under ios 13 then
first - choose from xcode your exact iphone version from the building tap
second - delete the SceneDelegate file and then go to AppDelegate and remove the last two functions then before the first function just implement the view by writing :-> var window: UIWindow?
then run the project and see what is the next ..
I'm currently learning Swift as well as XCode 6 and have been following this tutorial on creating a Tip Calculator. I believe I have followed the tutorial on point, since I have downloaded the example project file and compared it to my own and don't see any differences.
However, whenever I run the iPhone simulation on the provided example project compared to my own project, there's a striking difference in how the content is displayed on the simulator vs. the storyboard - things get cut off, don't appear, wrong location, etc.) :
-how the storyboard looks like --
I searched through Stack Overflow and have tried the following - cleaning the rebuild folder, 'resolve auto layout issues', unchecking 'auto layout', refreshed constraints in order to insure that it was running the correct files after editing. Those helped adjust the simulation to look as close as possible to storyboard, but now I am not sure what to do. I also tried changing the width to 'compact' and kept height to 'any' but still to no avail.
And it doesn't seem to be just this project, any project I create using storyboard - even as simple as dragging and dropping labels doesn't seem to correlate properly. I feel like I'm missing something stupidly fundamental, but I can't figure out what.
So my question is as an XCode newbie -
1.) What is the purpose of keeping the simulation to all 'inferred' size/orientation/etc. if it won't translate properly to any of the different simulation types? - iPhone 6 looks quites different from the iPhone 4 simulations and more. Shouldn't the iOS's point system make what I do in storyboard dynamic so as to transpose properly onto any iPhone?
2.) Is there some specific action I should be taking to make what I see on the storyboard translate properly to the simulator?
i am totally new to iphone and i am trying to create a universal app.
Now I am creating an empty application. According to all tutorials , by checking universal option it should auto create appdelegates for both iphone and ipad.
But all i can see is only one appdelegate . Kindly tell me how can i create both.
Best Regards
Brayden is correct in answering that you almost never need multiple app delegates. All the delegate usually does is handle the moments when the application launches, suspends or terminates. Back in the days when iPhones ran iOS 4.0, and iPads ran iOS 3.2, you might need very different code in the delegate because only iOS 4.0 supported multitasking. Those days are long gone, and your delegate should probably act the same on all devices.
Yes, you sometimes do reach a point where your program must behave differently on iPhone and iPad. Check the idiom at that time and no earlier. Otherwise you're just duplicating code to no purpose.
My most recent app contains almost no special checks for iPhone or iPad. It doesn't even use different XIBs. Instead, my custom views implement layoutSubviews to fill the space available.
That said, once you understand app delegates, maybe you will find a situation where you need them to be different. If you are absolutely certain that your iPhone and iPad behavior will be so wildly divergent, you will need to:
Manually create a new class (preferably inheriting from the existing AppDelegate class)
In your main.m, send the class name of your new delegate to UIApplicationMain depending on the idiom.
See this answer to "Can I create App Delegate file in my project?" to see the changes to main.m.
You really should only be using one AppDelegate for a Universal application. You can use this to share common things that you'll do in there. What exactly do you need multiple AppDelegates for? If you need to do something specific to a device type (i.e. - iPhone or iPad) then you can do a ternary expression like below:
(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? NSLog(#"iPad") : NSLog(#"iPhone");
Is there anyway to test the navigation functionality in MonoTouch using the iPhone simulator? Or will I need to write a wrapper class with timer events?
If you have the current beta version you can simulate other positions as well. There are buttons in XCode to choose from some predefined positions or your own positions.
In the simulator there is a menu item called 'Debug' -> 'Location' where you can choose your positions as well.
You should also be able to create a whole list of positions which are simulated.
While Debugging in XCode:
Location simulation
Now you can test your location-based features in your app without leaving your desk. You can now select from preset locations and routes within the iOS Simulator and pick a custom latitude and longitude with accuracy while you're running your simulated app.
Source: http://developer.apple.com/technologies/ios5/
I don't know much about mono touch but I do know that in the simulator there is no way to test a locationManager without a wrapper class as you suggested. The delegate methods will never be called because the pseudo position is always fixed.
Here are my issues,
When I install my application on my test device it has the behaviour I want.
However if I close it with the IPhone main button and restart with the icon, it starts back from the view where I left it, whereas I would like it to restart from my main view controller (my start view).
In the same way, I load some animations with viewDidLoad in certain views. I want them to show only the first time the view is loaded each time the application is launched. Right now animations only works the first time the application is launched after installation, then they don't screen anymore when I launch again the application.
Does anyone have a clue ?
Thank you very much for your help.
(Sorry if this topic is a bit easy for you guys :D, I'm quite new at it !)
No problem about being new! This is happening because, for devices from iOS 4.0 on up, your app will support multitasking by default. To disable this features, Add the key
UIApplicationExitsOnSuspend
to your Info.plist file, and set its value to YES. Good luck!
In addition to Sam's answer above, you can also add a key named:
Application does not run in background and set the value to YES.
Both work fine, however.