I am wokring on dogspot, which is an application for reviewing dog friendly spots. One of the feature is ability to rate the spots by users.

Now I create read-only app - a kind of radar for finding dog-friendly spots nearby and showing it on map.



Backend: My python/django api is returning float representing friendly_rate.

IOS: There is a lot of cool libs for ratings, e.g:




BUT: This have to be read-only app for now. So I decided to mocke rating with static stars. First idea: use static star images. Better idea: use emoji 😍! I am using Google Maps iOS SDK. I was afraid it will have problems with rendering snippet containg emoji but it worked like a charm!

I am rounding float, and want display only integer rating. Then I need only display ⭐️ as many times as value of rating.

[@"" stringByPaddingToLength:[@"⭐️" length]*abs(roundf([marker[@"friendly_rate"]floatValue]))
                  withString: @"⭐️" startingAtIndex:0]

Emoji [@"⭐️" length] is 2 not 1! I added labs, because my backend returns -1.00 for non-rated spots.

Another aproach, prepare text stars on backend in django-rest-frameworks serializers to_represenation method

ret['friendly_rate_stars'] = '*'*int(round(instance.friendly_rate))

and then just make simply replacment:

[marker[@"friendly_rate_stars"] stringByReplacingOccurrencesOfString:@"*" withString:@"⭐️"]