Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4010504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:00:31+00:00 2026-05-20T09:00:31+00:00

Some time ago, I read that comparing version numbers can be done using the

  • 0

Some time ago, I read that comparing version numbers can be done using the following code snippet:

NSString *vesrion_1 = @"1.2.1";
NSString *version_2 = @"1.2.0";

if ([version_1 compare:version_2 options:NSNumericSearch] == NSOrderedAscending) {
...
}

This seems to work fine, but one user is having a problem, which is due to a seemingly incorrect version number comparison.

My question is, is it safe under all circumstances to use this technique to compare version numbers? Is it possible that the above comparison results in different outcomes on different machines?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:00:32+00:00Added an answer on May 20, 2026 at 9:00 am

    I don’t know of anything built in that will do it, but I have heard that the Sparkle framework has a version comparator.

    Browsing quickly through the source reveals that the SUStandardVersionComparator object seems to be in charge of it. It conforms to the <SUVersionComparison> protocol,which means you could probably just use it like this:

    NSString *versionA = @"1.2.1";
    NSString *versionB = @"1.2.0";
    id <SUVersionComparison> comparator = [SUStandardVersionComparator defaultComparator];
    NSInteger result = [comparator compareVersion:versionA toVersion:versionB];
    if (result == NSOrderedSame) {
      //versionA == versionB
    } else if (result == NSOrderedAscending) {
      //versionA < versionB
    } else {
      //versionA > versionB
    }
    

    (note: code untested and typed in a browser. Caveat Implementor)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some time ago, I came across a piece of code, that used some piece
Some time ago I put together a time based library that could be used
Some time ago I wrote a little piece of code to ask about on
I learned some time ago about Decision Trees and Decision tables. I feel that
Some time ago I got this error when building ANY Visual Studio Deployment project.
some time ago I found an article ( Roles: Composable Units of Object Behavior
Background: Some time ago, I built a system for recording and categorizing application crashes
I remember some rules from a time ago (pre-32bit Intel processors), when was quite
I need to deploy a few files that were checked in sometime ago (can't
Since some time, my Delphi debugger became much slower than I was used to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.