Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Tiny Objective-C library to easily compare version strings

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 LICENSE
Octocat-spinner-32 NEVersionCompare.h
Octocat-spinner-32 NEVersionCompare.m
Octocat-spinner-32 README
Octocat-spinner-32 README.markdown


A tiny Obj-c library for easy version comparisons. Current version: 1.0.0


  1. Drag&drop the NEVersionCompare folder to your XCode project
  2. Import the .h file using: #import "NEVersionCompare.h"

You're done!

Typical Usage

This is how you create a typical NEVersionCompare object:

NEVersionCompare *myVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@""];

Advanced Use Case on iOS project

Popup an Alert View to your iOS app user when you release a new version and redirect them to the AppStore

// Use Case: Test version at application opening time
// File: AppDelegate.m
// Requirement: Your class has to register to UIAlertViewDelegate by using <UIAlertViewDelegate>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
/*  Test cases //
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@"1"];
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@"1.0"];
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@"1.3"];
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@"1.399"];
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@"1.0.33"];
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@""];
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@"1.0.3"];
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@"I made a mistake!!! :)"];
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
    // This line gets the current Application version number ( useful to compare against new versions ) 
    NEVersionCompare *appVersion = [[NEVersionCompare alloc] initWithFullTextVersion:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];

    // Typically get the latest available version from a .txt file somewhere on your server, 
    // Remember to take care if Internet is available or not!
    NSString *onlineVersionString = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@""] encoding:NSUTF8StringEncoding error:nil];
    NEVersionCompare *updatedVersion = [[NEVersionCompare alloc] initWithFullTextVersion:onlineVersionString];

    // Or simply enter by hand ( not recommended though )
    // NEVersionCompare *updatedVersion = [[NEVersionCompare alloc] initWithFullTextVersion:@""];

    NSLog(@"Compare gave the result: %i ", [appVersion compareWith:updatedVersion withBuild:NO]);

    if([appVersion compareWith:updatedVersion] == NEVersionSmallerThan) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Your Version is outdated" 
                                                      message:@"A newer, greater version is available on the appStore, please click \"Open AppStore\" to go to the update process. Enjoy!" 
                                                      otherButtonTitles:@"Open AppStore", nil];
        [alertView show];

// Then you can easily implement UIAlertView delegate to open the AppStore with your application

#pragma mark -
#pragma mark UIAlertViewDelegate implementation

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"A button was clicked: %i", buttonIndex);
    if(buttonIndex == 1) {
        // Opens the appStore
        NSURL *appStore = [[NSURL alloc] initWithString:@"itms-apps://{APPLICATION-NAME}"];
        [[UIApplication sharedApplication] openURL:appStore];

Supported Patterns

Pretty much all patterns are supported, except that you have to use periods (".") as a separator Like:

  • XXX
  • XXX.Whateverwillnotbetakenintoaccountanyway
Something went wrong with that request. Please try again.