Text Size
Thursday, July 02, 2015

IOS and LAMP Web Developer Blog by Mike Zriel

IOS Xcode

IOS Xcode

Last Updated on Monday, 01 June 2015 08:28

OS_IOS8 IS_IOS7 IS_IPHONE5 IS_IPAD Detect

BY: Mike Zriel

Detect is you are using iOS7 and detect is you are using an iPhone5 size screen

Detect if is iPad added

In your {AppName}-Prefix.pch, add the following lines

#define IS_IOS8 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1)
#define IS_IPHONE5 ([[UIScreen mainScreen] bounds].size.height == 568)
#define IS_IOS7 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
#define IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

now in your code you just use if statements:

if( IS_IOS8) {
  // write ios8 code

} else if ( IS_IOS7 ) {
   // write code for ios7
} else {
  // otherwise do this
}

if ( IS_PHONE5 ) {
   // write code for iPhone5
} else {
  // otherwise do this
}

if ( IS_PAD ) {
   // write code for iPad
} else {
  // otherwise do this
}


// OR

int i = (IS_IOS8) 66:44 // example 1
int x = (IS_IOS7) 107:106; // example 2
int y = (IS_PHONE5) 205:204; // example 3
int z = (IS_IPAD) 1024:320; // example 4

Any comments on IS_IOS8, IS_IO7 or IS_PHONE5 or IS_PAD, please leave below.

 
Swift

Swift

Last Updated on Tuesday, 07 April 2015 12:32

For loops in swift

BY: Mike Zriel

The two main ways to loop in swift are below:

for var i = 0; i < 5; i++ {

   println(i);

}
Output:
0 
1
2
3
4

and to enumerate an Array for example:

var myArray:Array = [2,4,6,7];

for (index, i ) in enumerate(myArray) {

   println("\(index): \(x)");

}
Output:
0: 2
1: 4
2: 6
3: 7
 
Copyright © 2015 by Mike Zriel - Zriel.com