Tagged: find a substring within a string xcode
Building an App on iOS 8 still compatible with iOS7
My new app 20 Saxophone Tricks of the Trade by Mario Cerra has been available on the App Store for over a week now.
We’ve had many downloads apparently with no issues. Yesterday a user wrote us an email saying the app was crashing right after launching. I knew right away it had something to do with the user’s device or IOS.
I downloaded the app from the App Store on an iPad running IOS 7.1.1 and the app crashed right away. I tried it in XCode with the iPad 2 simulator and the app run perfectly but, as soon I connected my iPad with IOS 7 and run it from XCode the app crashed again with an uncaught exemption error.
Long story short, after a few break points I found the issue was in a line where I’ve used containsString to find if a substring is contained in a string, which is an iOS 8 only method. Although the app was set to build for ios 7.1 and up the xcode compiler gave me no warning notice.
The solution is to use the rangeOfString method that is compatible with iOS 7:
[yourString rangeOfString:@”whatever-you-are-looking-for string”].location == NSNotFound
That solved the problem.
To submit a new version of the app to the App Store you must change the version number and build number of the app, archive it and submit it.
Now the app is back on waiting for review on the App Store.
I also added a note in the description for the current version of the app so users still running IOS 7 will wait for the update before buying it.
– (NSString*) archivoFullPath: (NSString *)archivo {
NSMutableString* result = [NSMutableString stringWithString: mDecksURLFolder];
if (!([archivo rangeOfString:@”http”].location == NSNotFound)) {
return archivo;
} else {
[result appendString: archivo];
return result;
}
}