SBFormattedPhoneNumber issue in iOS4.0 - iphone

I am using the below code in my application which works perfectly in iPhoneOS 3.1.3 but not working in iOS 4.0. Any body affected by using this.
NSString *currentPhoneNumber = [[NSUserDefaults standardUserDefaults] objectForKey:#"SBFormattedPhoneNumber"];

It appears that the SBFormattedPhoneNumber key/value data has been removed from the NSUserDefaults object as of 4.0. No device number retrieval love; can't really say that the writing wasn't on the wall based upon Dylan's response to this thread.

Related

dictionaryHasDefinitionForTerm issues in xcode 4.5

fourLetterWord = #"isdjfiodjof";
if ([UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:fourLetterWord]) {
self.display.text = fourLetterWord;
return;
}
else
fourLetterWord = #"";
This string is getting accepted. I do not know what I am doing wrong here, but before 4.5 this worked fine. Is this an issue with xcode 4.5, or is there something wrong with my code?
I just had the same issue and start working around it.[UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:fourLetterWord]) method doensn't work in the simulator for some reasons, Apple need to fix it.
BUT if you TEST YOUR APP IN THE DEVICE [UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:fourLetterWord]) method runs and gives you the right result.
it's kinda slow though.
hope helps.
dictionaryHasDefinitionForTerm: always returns YES if no dictionary has been downloaded yet (because if there is no dictionary, it can't know whether the word is in it).
The download is automatically offered when you actually show a dictionary popover in any app. I think the download-on-demand feature was introduced in iOS 6, along with dictionaries in languages other than English.
My experience is that this works fine on my iPad running iOS 5.1.1 but returns TRUE every time on my iPod running iOS 6.1.3. I've logged it as a bug with Apple.
Update: omz is right. Once I had downloaded Apple's dictionary onto my iOS6 iPod then it validates the word correctly. It was so long ago that I installed iOS5 on my iPad I had no memory of whether I'd installed it manually or if it was done for me. Regardless, it requires a manual install on iOS6 for this method to be of use.

How to maintain app settings when user updates to new version

When we update an application, the settings which are selected by the user in the old version should be kept after updating to the newer version.
Let me explain this with an simple example:
Version 1.0 of my app has a switch that is ON by default but the user can set OFF. In the App Store I am going to publish next version— 1.1—with some modification but it also has the same switch. When the user updates it from the device the switch value should stay OFF.
How can I achieve this kindly reply me with your valuable comments...
Thanx in advance...
You can simply use NSUserDefaults
App 1.1 can easily read what App 1.0 wrote.
When you update your app to a newer version, then the UserDefault have no change (If dont remove app).
Then what we have to do is detect whether your app is updated to a newer version. What I did in my app is maintain a variable in UserDefault like "CurrentAppVersion", then when app is launched I check the currentVersion which getting from app Bundle, if they are difference and up, then I migrate my settings to a new version and update "CurrentAppVersion" to a new version also.
Reference:
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
NSString *currentAppVersion = [userDefault objectForKey:#"CurrentAppVersion"];
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleVersion"];
NSLog(#"current version: %#, appversion: %#", currentAppVersion, appVersion);
if ([currentAppVersion isEqualToString:appVersion] == NO) {
// Your app has just updated to new version, migrate your app settings.
} else {
// NO, do nothings with your app settings.
}
Hope it help your much, :)
The contents in Application Documents directory and Library directory will not change after app update. So what you should do is just write the settings (say a string "SWITCH:YES") to your Documents directory just like
[string writeToFile:<#(NSString *)#> atomically:<#(BOOL)#> encoding:<#(NSStringEncoding)#> error:<#(NSError **)#>];
see this post Retaining data after updating application
Your 1.1 version just needs to read the saved user settings written by the 1.0 version. This is one reason that putting a versioning mechanism in your saved user data is a good idea, to make this type of upgrade simple.
for sure you are saving your switch value some where on your first version so you can get it and apply it in the next version .. for me when I make update to an app I usually build a backward computability class inside it I retrieve all the user settings and content and call it for the first time the app run and then I apply the old settings on the new version. Good luck

Debugging CoreLocation app in real IOs device

I'm developing an application that uses CoreLocation Framework to track user movements. I'm caching the information into a DB to make use of it later, etc. The problem I'm facing is that this kind of application is not to be tested on the Simulator, but on a real device with real data, but I don't find a way to at least access the data my application is generating and storing into its DB. I'd like to know some tips or hints related to the way of testing&debugging this kind of application.
Thanks!
If you want to access the application's data you can follow the steps on this post. If you are using an SQLite database, I'd suggest you to use the SQLite Manager plugin for Firefox, it works great.
I hope it helps
Cheers!
You need to adopt locationManager:didUpdateToLocation:fromLocation: of CLLocationManagerDelegate. You will receive newLocation in this callback.
newLocation.coordinate - that's what you need.
You can test on the iPhone simulator using a CLLocationManager simulator and that way you'll have access to the data in your DB. There are several CLLocationManager simulators out there that run on the iPhone simulator see this answer on SO.

Would [NSUserDefaults resetStandardUserDefaults] cause app to crash?

I've gotten a few reports of my latest update crashing on launch from some users.
The previous versions of my app had a Settings.bundle where I had a few settings that could be changed. In the latest version I removed it and the code that retrieved values from it. I did notice that I forgot to remove a call to [NSUserDefaults resetStandardUserDefaults] in my app delegates applicationWillEnterForeground method.
Would calling this cause the app to crash in some cases? I've not been able to reproduce it and haven't received any crash logs from the users who reported the issues yet so I can't see where it's crashing or what it's crashing from. Other users who have upgraded haven't had a problem so I'm not sure why it would affect some people and not others.

NSURLRequest, NSURLConnection version infomation

I'm implementing background fetching similar to this example. However, I also need to support devices with older iOS versions (3.0 and up). So, my question is: What versions will support this?
Also, I've been using the technique of attempting the create the object and checking if it is null as a means of insuring backward compatibility. However, if there is a way of checking the version directly, that would be great also.
At a glance I don't see anything in that code that isn't available with ios 3.0. Therefore you should be OK.
NSURLConnection is Available in iOS 2.0 and later
When you build just ensure you set your iOS Deployment Target to 3.0
The above code appears to be 3.0 compatible. If you do need to know the version of the OS you can call:
[[UIDevice currentDevice] systemVersion]
Also, I looked a the example you're using and there appears to be a significant memory leak. The line:
mutData = [[[NSMutableData alloc] init] retain];
Sets the retain count of mutData to 2, which probably means it won't ever get released.