Saturngod

What's on my mind

iOS macro

Yesterday , I was fixing the Sar for iPhone 5. iPhone 4s and iPhone 5 are just change the height. For landscape , iPhone 4 is 480 and iPhone 5 is 568. So, Myanmar Keyboard have a problem with iPhone 5 in landscape mode. it couldn’t show full.

I need to change width in landscape mode. I don’t want to put so many condition on all of code for landscape mode. I already declare width , height , x , y , padding in marco value.

Example:

#define L_START_X 3
#define L_WIDTH 44

If it’s iphone 5 , i just need to change the #define value. Simple. So, I need to put condition in #define.

First I create the the marco in .pch file like following.

#define isIphone ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)

#define isIphone5 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].size.height > 480)

After that I change L_START_X and L_WIDTH like following.

#define L_START_X (isIphone5 ? 15:3)
#define L_WIDTH (isIphone5 ? 50:44)

So, I don’t need to write extra code for iPhone 5. Just change in marco. Simple ? Yes, it’s very simple to update for iPhone 5 if you are using macro value for static value.

In App Purchases

I read about the In App Purchases tutorial from Introduction to In App Purchases. Another good tutorial is In App Purchases walkthrough . I tried to use raywenderlich example. He is using NSNotification. I prefer to use block NSNotification , so I changed some code from his tutorial and put it on github.

I love my new library https://github.com/saturngod/IAPHelper . It’s more easier to use In App Purchases than Native. It already support ARC.

I need to do subscription method in the library and still not start yet.