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 7051647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:17:19+00:00 2026-05-28T03:17:19+00:00

I want to check if user is using the latest version of the app.

  • 0

I want to check if user is using the latest version of the app. If so, i should color the background of some cells.

This is the code i’m using:

appDelegate.m

NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastVer"];

method where i want to check:

NSString *lastVersion = (NSString *) [[NSUserDefaults standardUserDefaults] objectForKey:@"lastVer"];
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
lastVersion = @"1.3.4";
if(![lastVersion isEqualToString:version]){
    cell.backgroundColor = [UIColor yellowColor]; ; 
    cell.imageView.image = [UIImage imageNamed:@"image.png"];

  } 
  else { 
       cell.imageView.image = nil;
       cell.backgroundColor = [UIColor whiteColor];
  }
}

Am i doing it right? Is my code checking for the latest version or? How can i simulate this behavior in the simulator \ on device?

What i want to do is check if the user is using the latest version of the app, in order to call in another NSUserDefaults key to show the cells of my tableView with a different background color.

EDIT

Code i’m using to change the cells background if the user is using the latest version of my app and if the user has used the app less than three times:

    NSString *cellValue = cell.textLabel.text;
    NSNumber *runNumber = (NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"runNum"]; 
    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastVer"];
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

    if (!runNumber) { 
                runNumber = [NSNumber numberWithInt:0]; 
                [[NSUserDefaults standardUserDefaults] setObject:runNumber forKey:@"runNum"]; 
                [[NSUserDefaults standardUserDefaults] synchronize]; 
            } 

    if([lastVersion isEqualToString:version]){ //check if the user is using the latest version
       if ([runNumber intValue] < 4) { //check if user has used the app less than 3 times 
           if ([cellValue isEqual: "someText"] ){ 
               cell.backgroundColor = [UIColor yellowColor]; ; 
               cell.imageView.image = [UIImage imageNamed:@"image.png"];
              } 
            else { 
            cell.imageView.image = nil;
            cell.backgroundColor = [UIColor whiteColor];
            } 
        }   
        else {
           cell.imageView.image = nil;
           cell.backgroundColor = [UIColor whiteColor]; 
        }
 }
}
  • 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-28T03:17:19+00:00Added an answer on May 28, 2026 at 3:17 am

    this code will not set anything..

    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastVer"];
    lastVersion = @"1.3.4";
    

    you need a setter:

    [[NSUserDefaults standardUserDefaults] setObject: @"1.3.4" forKey:@"lastVer"];//in memory
    [[NSUserDefaults standardUserDefaults] synchronize];//to disk
    

    and a getter:

    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:@"lastVer"];
    

    edit:

    remember that lastVersion is a pointer and you just set it to point somewhere else, that doesn’t set it in stdUserDefaults and it doesn’t synchronize it to disk.

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

Sidebar

Related Questions

I want to let user login via facebook. I'm using this code: <?php require
I want to check to see if a user has rated my app on
i want code to check whether the user in logged in or not. I
Basically I want to check the extended permissions the user has granted my app.
I want to check the HTML tags the user is using in a rich
i want to check for user liked my page or not using isFan() API
I want to check if user is logged in CodeIgniter by using my library
im using asp.net with c#, I want to check whether a user is on
Within my ASP.NET App I am using a Method to check user permissions to
I want to check the login name of a user using windows authentication. I

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.