Multi Value Settings not Initializing with Default - ios

I've got an app that used a multi value menu in the settings bundle to configure the rate at which the on-screen map is refreshed. The panel is set up like this:
When I run the app on my phone, I immediately go to the settings app and the menu reads "1 sec" as I expect. When I return to my app and attempt to initiate the map update the app crashes with "fatal error: unexpectedly found nil while unwrapping an Optional value" and highlights an EXC_BREAKPOINT, when I step back through the code I am taken to the settings for my multi value menu. Also, if I go to the settings app first and manually re-selct the same value the app runs perfectly. The highlighted code looks like this:
Have I incorrectly set up the default value?

Based on the fact that there is an error unwrapping the optional, I bet that NSUserDefaults.standardUserDefaults.stringForKey("mapUpdate") is nil. You should double check that.
If that's the case, you'll need to register your plist file for use with NSUserDefaults. See How to set initial values for NSUserDefault Keys? for defailts on how to do that.

Related

SetValue in Swift from Firebase removes old value's

In the documentation it says that I should use this code to set new value's:
self.ref.child("users").child(user.uid).setValue(["username": username])
This way, I can set an username. However, if I want to add another value later on, like XP points, I use the following line of code:
var XPPoints = 1
self.ref.child("users").child(user.uid).setValue(["XPPoints": XPPoints])
This, however, deletes the username value, or any other value that was stored before. It replaces all value's.
I tried also the second thing the docs are saying at: https://firebase.google.com/docs/database/ios/read-and-write#basic_write which is this line of code:
self.ref.child("users/(user.uid)/username").setValue(username)
This will crash my app instantly when starting up. My question is: How can I add data, and not replacing the old value's?
Edit:
Fixed it by changing the code to:
self.ref.child("users/\(user.uid)/username").setValue(username)
Your solution shouldn't fix the problem you are having. You need to use updateChildValues instead of setValue. This adds the values instead of overwriting everything in the referenced node.

How to search Crashlytics custom keys

Using their handy guide, I'm able to set custom keys in crash data that appears in the Crashlytics dashboard for a particular crash. The docs (and placeholder text in the web site's TextBox) say you can search by key to find a crash like you can using other data like method name, line number etc. I can't get the search to ever find a crash by a key value. I've tried searching on both the custom key's name and value and it never finds it. I hard coded a simple key to the value "hello" just to make sure it wasn't a search case sensitivity type issue but no luck. Anyone ever able to successfully search by custom key?
In the text field that says Search issue title, subtitle or key, you need to put the search query in this format:
key:<key> value:<value>
eg
key:id value: b329e5d2-dd2a-4bfb-95e3-1e5ffc9153dc
Where in the code I've created a custom key named id
Apparently, you just have to wait. 15 minutes or so after the crash had appeared on the dashboard site, the search by key value worked fine. Must be their search index service had to cache/process the new data?

Strange values displayed in Xcode debugger

I'm currently using Xcode version 7.2.1, and I'm getting weird values displayed for most values in the debugger. The weird thing is it's always the same value. Other than a few values, all variables are listed as containing the value "00:30:00". The best way to show this is to give you an example.
I have tried restarting Xcode, clean and build, re-booting, and even re-installing Xcode, but I can't seem to escape this weird value. If I put in print statements, all the values show up correctly in the console. Is there any way I can get them to be correct in the debugger? Thanks.
Edit:
This is kind of interesting. If I move the mouse pointer over one of the entries, you can see that it displays "00:30:00", but if I inspect the value, it displays the correct date value.
I finally figured it out! I must have typed something in the "Edit Summary Format..." popup. It took it as a literal format string and displayed it for all string values from thereafter. Once I removed that, everything went back to normal.

How to reset the PrimaryLanguageOverride?

I have been going through the process of localizing my apps and in doing so I temporarily set the language to Chinese like this:
ApplicationLanguages.PrimaryLanguageOverride = "zh-CN";
However, after commenting out the line and rebuilding / re-deploying, now my app is still stuck in Chinese instead of what my development machine's default language at the OS level (English)!
How do I reset this to go back to the default OS setting?
Just assign an empty string to the PrimaryLanguageOverride property :
ApplicationLanguages.PrimaryLanguageOverride = string.Empty;
The PrimaryLanguageOverride setting is persisted between sessions. It
should not be set each time the app is loaded. It should only be set
based on user input presented in settings UI. The property can be read
at any time. If the property has never been set, it returns an empty
string.
So if you set the property to an empty string, the app will use the default language.

access a watch item even if not debugging step by step in the Delphi IDE

Is it possible to see the list of watches with the realtime value when I am not at a breakpoint?
I have defined an integer Mycounter in the public section of a TDatamodule.
I add it to the Watch list.
I can see its value being updated in the watch list only as I am debugging line by line or I am at a rbeakpoint.
Is there a way to keep seeing its value in the watch list even when the control goes back to the VCL thread (=when I press F9)?
As David said, a watch is not possible but you could get close by adding a data breakpoint to your variable and have it dump it's value to the Event Log each time it changes.
Steps
Get the address of the variable you like to track.
Add a databreakpoint
Open the Event Log debugging window
Get the address of a variable
I have used the variable I in my example. As per your example, this should be #Mycounter
Adding the Data Breakpoint
Use the address of the variable
Uncheck the Break checkbox
Evaluate the expression PInteger($45622C)^
Log the result
Viewing the results
There is no way to do this from the IDE. Watch evaluation requires all the threads in the process to be suspended so that the debugger can read the memory and perform the evaluation.
If you want to see values being refreshed without the debugger breaking, you would most likely have to add code to your application to instrument the values of interest. For example, add code to your application output debug messages (e.g. OutputDebugString(), CodeSite etc.) whenever the value changed. You would of course need to view the information in a separate viewer.

Resources