Get international Dialling Code for the User’s Current Location

In an app I’m working on, users are supposed to enter their phone number including the international dialling code. I know this could be confusing for some users that are not so sure about the dialling code so I wanted to insert it automatically.

So I’ve created HMDiallingCode, a light weigh library that gets theĀ dialling code of the user’s current location. It uses CoreLocation and reverse geocoding to determine the country of the user, then retrieve it’s international dialling code from a plist.

The code is available on GitHub atĀ

Set post body in RestKit manually

In some cases while using RestKit, you might want to set the post body (request params) manually with a JSON string instead of assigning an NSDictionary to it. Here’s the simplest way to do it.

RKClient *client = [RKClient sharedClient];
NSString *postBody = @"{\"key\":\"value\"}";
NSData *postBodyData = [postBody dataUsingEncoding:NSUTF8StringEncoding];
RKRequest *request = [client post:@"/endpooint"
                           params:[RKRequestSerialization serializationWithData:postBodyData MIMEType:RKMIMETypeJSON]