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Ā https://github.com/HeshamMegid/HMDiallingCode

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.

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