This is pretty basic stuff but what I’m doing doesn’t feels right so I’m asking the experts.
I have a boolean method that checks if the user is on iphone 5
- (BOOL)isTall
{
CGRect bounds = [[UIScreen mainScreen] bounds];
CGFloat height = bounds.size.height;
CGFloat scale = [[UIScreen mainScreen] scale];
return (([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) && ((height * scale) >= 1136));}
I’ve placed it in another class called stuff.m and I’m importing it to every other class i’m using and firing it up like this:
- (void)viewDidLoad {
[super viewDidLoad];
DataManager *testMe = [[DataManager alloc]init];
if(test.isTall)
NSLog(@"Hey");
Is that the proper way to go? seems like there should be a better way doing so without allocating testMe in every class.
You can define it in your
UIApplicationDelegateImport it to your class of choice.
And from within a codeblock you just do this!