• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: More elegance than a long if/else
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More elegance than a long if/else


  • Subject: Re: More elegance than a long if/else
  • From: Bryan Vines <email@hidden>
  • Date: Fri, 10 Mar 2017 10:24:02 -0600

Would integer division work better than the modulus operator?

batteryIcon.image = UIImage(named:"\(min(10, (Int(_myBatteryLevel) / 10) + 1))")

--
Bryan Vines

> On Mar 10, 2017, at 9:54 AM, Jeff Kelley <email@hidden> wrote:
>
> I realized after sending that 100 won’t be correct, so you’ll need
> something like this:
>
> batteryIcon.image = UIImage(named: "\(min(10, (_myBatteryLevel % 10) + 1))")
>
>
> Jeff Kelley
>
> email@hidden | @SlaunchaMan <https://twitter.com/SlaunchaMan> |
> jeffkelley.org


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: More elegance than a long if/else
      • From: Quincey Morris <email@hidden>
References: 
 >More elegance than a long if/else (From: "Eric E. Dolecki" <email@hidden>)
 >Re: More elegance than a long if/else (From: Jeff Kelley <email@hidden>)
 >Re: More elegance than a long if/else (From: "Eric E. Dolecki" <email@hidden>)
 >Re: More elegance than a long if/else (From: Jeff Kelley <email@hidden>)

  • Prev by Date: struts and springs layout
  • Next by Date: Re: More elegance than a long if/else
  • Previous by thread: Re: More elegance than a long if/else
  • Next by thread: Re: More elegance than a long if/else
  • Index(es):
    • Date
    • Thread