Thursday, 27 March 2014

Box all your numbers in new literal syntax with find and replace

Xcode provides no shortcut to box your variables to use new literal syntax, and doing it by hand is seriously time taking.

A small approach to help is to use the "Find and Replace" option of Xcode (⌘ + ⌥ + F).

What to find? : Any word
What to replace with? @( matched word )

How to do it? with magic.. ;)
Use \1 in your replacement string to get the matched word.
Note: On Xcode 6+, Use $1 instead.

See the screenshot below. Hope this helps.

For Xcode 6+, 

If you have used any other solutions, please share them in comments.

Tuesday, 11 March 2014

Ask user to allow access to his address book

This code refers to ONLY asking for the address book permission and not doing any related manipulation. The code has been tested for iOS 7.

Note: If ABAddressBookGetAuthorizationStatus() returns a value other than kABAuthorizationStatusNotDetermined, NO access alert is shown.

Possible values from ABAddressBookGetAuthorizationStatus() is given by: