iPhone : How to check device using MACRO?

I want to check whether the device is iPhone or iPad using the macro.

I have a file Constant.h where I have given values using #define.

Now, I want to check device using #ifdef #endif.

Follwing method can be possible only in the .m file.

But I have only one .h only.

- (BOOL) isPad{ 
        return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
       return NO;

So above method is not useful for me ?

Is there any way to do this ? Or any other way?


You can't check it by macro, because macro is expanded during compilation. So you need to know device type at compile time.

If you want to support both devices at runtime, you need to check device type and use appropriate set of constants.

I have simple answer to this question.

#define isiPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? YES : NO)

This will returns 1 if device is iPad and 0 if device is iPod or iPhone.

Need Your Help

jquery mobile openlayer search

javascript jquery json mobile

hye all, i have problem with jquery mobile openlayer search;

Twitter Widget not showing correctly in firefox

firefox twitter widget

http://www.myprettyvintage.com is having an issue with the twitter widget in the sidebar.