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

  • SEARCH
  • Home
  • 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 8883141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:44:39+00:00 2026-06-14T20:44:39+00:00

When searching the iTunes store, I’ve hit a little problem. I’m trying to change

  • 0

When searching the iTunes store, I’ve hit a little problem. I’m trying to change the text of my label to “FREE” when the price is 0.00, as opposed to displaying the price. The problem is, my comparison of the two NSDecimalNumbers fails. Here’s where I am currently at.

NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setCurrencyCode:self.searchResult.currency];
NSString *price = [formatter stringFromNumber:self.searchResult.price];

NSDecimalNumber *free = [[NSDecimalNumber alloc] initWithFloat:0.00f];

NSLog(@"Price:%@",price);
NSLog(@"Free:%@",free);
NSLog(@"self.searchResult.price: %@", self.searchResult.price);

if (self.searchResult.price == free) {
    NSString *freeText = [NSString stringWithFormat:@"FREE"];
    self.priceLabel.text = freeText;
}
else {
    self.priceLabel.text = price;
}
NSLog(@"priceLabel:%@", self.priceLabel.text);

What’s really weird is that the Console even says that both free and del.searchResult.price are the same:

2012-11-24 20:01:16.178 StoreSearch[1987:c07] Price:$0.00
2012-11-24 20:01:16.178 StoreSearch[1987:c07] Free:0
2012-11-24 20:01:16.178 StoreSearch[1987:c07] self.searchResult.price: 0
2012-11-24 20:01:16.179 StoreSearch[1987:c07] priceLabel:$0.00

I’m a little confused by this to be frank. Any help would be appreciated. If you could explain why this has happened so that I can learn not to do it again, then I’d be even more grateful!

Regards,
Mike

  • 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-06-14T20:44:40+00:00Added an answer on June 14, 2026 at 8:44 pm

    you got NSNumber and another NSNumber (NSDecimalNumber) and you do a pointer equal check you either need need to call isEqual or compare the primitive float values

    == with objects doesnt compare the value but the object pointer (the memory address)


    if(searchResult.price.floatValue == free.floatValue)
    

    note that a float is inprecise and generally should not be used for any calculation or comparison. It is ok in this case though

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

Sidebar

Related Questions

I'm using the iTunes API and I have a problem. I'm searching in den
searching around trying to find a way to add index on suffix of a
Searching for a while now, but haven't found a suitable answer to my problem.
An app I recently had approved for sale on the iTunes store has been
iTunes offers a JSON API for searching against app names (e.g., find all apps
I've tried searching CPAN. I found Mac::iTunes , but not a way to assign
Searching on Stackoverflow and writing this question has taken more time than the change
After searching for a long time for a simple way of changing the text
Resolved There was a problem on Apple's side of the App Store, which resolved
I want to do testing on an app which is provided free through iTunes.

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.